Integrate area under 2d set of data

Hello,

Apologies in advance for what feels like an Igor Amateur question on the Igor Pro forum.

I have a series of XY data acquired at regular time intervals which I have imported into Igor as a 2D wave (they are spectral files of wavelength versus intensity, acquired every x minutes for y hours). Igor lets me make pretty 3D gizmo plots of these data, which I show off to my colleagues and supervisor. Thanks, Igor! The 2D wave is scaled to the wavelength range as the y-values and time as the x-values, with intensity as the values inside the table (z-values?).

But now my supervisor wants me to integrate the intensity over a specified wavelength range and plot the result as a function of time. I need to be able to easily specify the wavelength and time ranges to be integrated over. Also, these data aren't easily described by curve-fitting (and there's 300-odd rows that would have to be fit), so I'd prefer to integrate numerically if possible.

I've tried using the integrate function with no luck, and looked at the areaXY help section, but it states that it is "intended to work on 1D waves only."

Are there any Igor Pro pros out there willing to help out a new user? I can upload or email the project file if requested.

Thanks!
Hello Joel,

For an arbitrary set of data defined by a 2D wave you could apply various integration tricks that are variations on 1D integration. In the following example, I use Integrate1D() which is not necessarily the most efficient way to get the answer but it might just impress your supervisor. So, assuming that your spectral data are stored in the wave my2DSpectralWave in the current data folder here is a modified 2D integration example:


Function do2dIntegration(xmin,xmax,ymin,ymax)
Variable xmin,xmax,ymin,ymax

Variable/G globalXmin=xmin
Variable/G globalXmax=xmax
Variable/G globalY

return Integrate1d(userFunction2,ymin,ymax,1) // Romberg integration
End

Function userFunction1(inX)
Variable inX

NVAR globalY=globalY
Wave my2DSpectralWave

return Interp2d(my2DSpectralWave,inX,globalY)
End

Function userFunction2(inY)
Variable inY

NVAR globalY=globalY
globalY=inY
NVAR globalXmin=globalXmin
NVAR globalXmax=globalXmax

return integrate1D(userFunction1,globalXmin,globalXmax,1) // Romberg integration
End

You can change the Romberg integration to either Trapezoidal or Gaussian Quadrature.

I hope this helps,

A.G.
WaveMetrics, Inc.
I'm not quite sure what you are trying to achieve, but maybe it is related to our data processing.

We usally collect waveform data as a function of something. This gives also 2d waves where the x dimension is time and the y dimension is something. The z or data dimension is intensity (or voltage which is basically the same).
We then extract a trace of a specific signal out of the 2d wave. This results in a 1d wave where the data unit is the integral intensity of the traced signal and the x unit is something.
I attached a zip file which contains two procedure files that we use for this purpose.
Place them in your user procedures folder and load the Get2DArea2.4.ipf into Igor e.g. by double clicking it. The other one gets then included automatically.
A few words how to use it (there is no documentation):

Choose a 2d wave from the wave selector. This displays the first column of the 2d wave.
You can now switch through the columns using the slider.
Place a cursor on both sides of the signal you want to integrate (or trace).
Press either the Live Area button or the Get_mdint3 button.
The former simply integrates the signal for each column using the area function.
The latter uses also the area function, but lets you additionaly choose a background subtraction method and stores the wave in the current data folder and prints the name of the wave in the history:
Entering a value < 0 doesn't subtract any background, a value >=0 chooses the entered value as the point index for the start of background intervall which has the same size as the signal intervall (if possible).
Entering exactly -56 interpolates the background from the start and the end value of the signal intervall.

Hope this helps.
integrate.zip (7.92 KB)
Thanks to both of you for your speedy comments!

awirsing, that does exactly what I was hoping it would do. I transposed my data (using Duplicate and MatrixTranspose) to make it plot the way I wanted it to, but other than that it was a piece of delicious, delicious cake. Many thanks!