Waves in Igor

For more details see Waveform model of data, Igor 5 Manual, volume II, p. 87.
Waves are Igor objects you are most likely to work with.

Wave are collections of number that can be manipulated as a group - all numbers at once. For our convenience waves are given nicknames in human language.

A simple wave is a single string (or array) of numbers. It can be visualized as one column in a spreadsheet.

To access specific value you need to indicate the name (nickname) of the wave and which number in the sequence you need.

Indexing in Igor starts from 0, not from 1 as we normally count.
This means that for a wave containing 100 values, index can vary form 0 to 99.

For example:
notation MyExperiment[3] means that you need a value at 4th position in wave called MyExperiment.

Waves can have several dimensions. Simple wave above is a one-dimensional wave (linear). When several sequences of values are combined together they make a two-dimensional wave, or a matrix. Matrix can be visualized as a grid of numbers. See matrices for more details.


Accessing and addressing data in waves

In most cases entire array of data in a wave can be addressed and manipulated as one object by using wave name, such as:
MyResult = MyData
where every point from wave MyData is copied to MyResult if waves have the same size (number of points). If waves are of different size, the smallest size will be copied entirely.

In many cases we need to access a particuar point or subrange of points within a wave. How this is done depends on whether you are reading or writing a value and how do you specify the position(s).

  • addressing data points & ranges
  • writing result into wave
  • reading data from wave

Addressing by position, scaled or calibrated value:

See Calibrations for details on types of calibrations used below.

A particular point or a range of points within a wave can be addressed by either their position in a sequence or by scaled value:

  • To specify position by point number incude that number in square brackets: MyWave[5] or MyWave[5,10].
  • To specify position by scaled calibration incude numbers in round brakets: MyWave(5) or MyWave(5,10).

Practically we rarely use scaled calibration in this group. Default scaled calibration starts with zero and increments by one from point to point. This means that in most cases booth methods will yeild the same result. It is best to take a custom of addressing waves by point number reference whenever possible - always use [ ], unless you have specific reason to use scaled calibration.

In many case, however, we need to access data in one wave that correspond to a particular value of calibration in another wave. An example of this situation is looking for intensity at specific peak/trough wavelength values in an absorption spectrum or a particular shift in Raman spectrum. In such cases point number position has no real world meaning. These situations are examples of addressing by calibrated value.

Because this method involves two separate waves, there is no built-in unary operation like MyWave[5] above (sob!). There are two user functions that allow to find position of a calibrated value:

  • clb2pos(ClbWave, Value) returns a point number of calibration value in ClbWave that is closest to Value. It returns NaN (not a number) if requested Value is outside the range of values in ClbWave.
  • clb2pos(DataWave, ClbWave, Value) does the same search, except that it returns a value in DataWave at found point reference or NaN if such value does not exist.

For more information see page on reading data.


Addressing waves for writing:

While it is more intuitive to read data you will be working with first, it is the output wave (where you put the result) that determines how many dimensions and points will be used in calculation. You are writing to, or assigning values to points in, a wave when it is to the left of = sign.

    You can assign:
  • the entire wave by its name MyWave= ....
  • a single point in a wave - MyWave[5]= ...
  • a sub-range of points within a wave - MyWave[5,15]= ...

No matter how you find which points to assign, Igor will allways start with the smallest point number and increment it through the range while making assignment. For each iteration in this process Igor has symbolic value p, which contains number of a point in the output wave which is being processed at this moment. Value p is counted from zero at the beginning of the wave, i.e in the notation MyWave[5,15]value of p will vary from 5 though 15.

for more information see Indexing and Subranges, Igor 5 Manual, volume II, p. 110


Addressing waves for reading:

Once you specified where to store the result you can specify what kind of calulation to perform. If all points in the result wave directly correspond to points in each of the input waves, you can write caluclation with wave names as it they were numbers:
OutWave = InputWave1 + InputWave2 * InputWave3.

If there is no one-to-one correspondence between points in waves, you will need to specify, in general form, how each point position in one wave will be converted in to point position in another wave. Here variable p generated for every point in the left part of equation can be used in point addressing in the right part of equation:

MyWave1[5,15] = AnotherWave[p] copies only values 5 through 15
MyWave[5,15] = AnotherWave[p-5] copies values and shifts their positions
MyWave[5,15] = AnotherWave[15-p] copies values in reversed order
MyWave[5,15] = AnotherWave[p] - p*2 copies values from 5 to 15 while subtracting a line with slope of 2

Other position reference variables:

In addition to reference value p for every point position, Igor generates symbolic value x for scaled calibration postition. For practical use in this group it is best, however, to always use p because there is unique and straight forward correspondence between p values in different waves: [3] is always refers to the 4th point in any wave. Scaled calibration reference (3.5), however, may point to different locations within the same wave depending on whether scaling has been set or not.

Similar current point references exist in higher dimensions. One practically useful is variable q which refers to current column position in matrices. In simple waves there is only one column and q always equals 0. See Matrices for more information.

Comments