This page addresses typical examples of accessing data in waves
Finding an average of values over wave subrange:
In many cases instead of a single value at specific point we need to know an average of values over a range of points (by point, scaled, or calibrated reference). Igor includes several built-in functions for such analysis in 2D waves.
Note:
There are no built-in analogs for matrices, but this can amended with user functions.
function |
calculation details |
notes |
mean (wave, X1, X2) |
does calculation between rounded X1 and X2;
does no interpolation, rather finds closest integer points;
small changes in X1 and X2 will not change value of mean;
uses only values, ignores calibration |
uses scaled calibration of the wave to find positions; default scaled calibration is identical to point number. |
faverage(wave, X1, X2) |
same as mean except that it interpolates values at exact positions X1 and X2;
any changes in X1 and X2 will change the result;
uses X1 - X2
range in calculations. |
same as mean |
faverage(XWave, YWave, X1, X2) |
identical to faverage except it uses calibration from separate XWave instead of internal scaled calibration |
most practical for finding real-world values;
mind wave sizes and origins: do not use time calibration to find wavelength values |
Built-in functions use scaling calibration in calculations of mean and averages. Default scaling calibration is identical to point number. To ensure that you are using a true point reference use pmean funciton in General_Functions procedure file. If this procedure file is not available you can use notation mean(wave, pnt2x(wave,P1), pnt2x(wave, P2)).
Finding data value at calibrated position:
Ironically, it is actually harder to find a single value by calibration reference than an average over the range. Hopefully future version of Igor will include such lookup. For now there are several ways to deal with it.
For spectral data that use shared calibration wave by far the best way is to simly look up point number of calibrated position in a table and use point number in subsequent calculations.
The second alternative is to use functions for finding average above, except for setting both values X1 and X2 to calibration point of interest, for example faverage(MyWave, 255, 255).
If you have access to Igor procedure folder you can load General_functions procedure file and use clb2pos(ClbWave, Val) or clb2pos(DataWave, ClbWave, Value), also described here.
If you cannot use above methods and If you must find accurate point reference programmatically (i.e. in a macro or for multiple waves) it will take essencially tree steps:
- using BinarySearchInterp() function find which point number that corresponds to desired calibration value; this point number is interpolated and likely fractional.
- round fractional point number to an integer point number (i.e 1.9 should become 2, not 1) using round() function.
- use integer point number reference to get the data
All three steps can be accomplished in a single expression MyWave[round(BinarySearchInterp(MyCalibration, 543.2))], where MyWave and MyCalibration are names of waves and 543.2 is the desired position.
|