Integration for x minutes in a timeseries

Hi everyone,

I have two dataset that I will like to compare but they were taken under different conditions.

Dataset A is a timeseries of concentration (y-wave) against time (x-wave), where a data point was taken every 30 seconds.

Dataset B is also a concentration against time but the data was summed up over 5 minutes and taken every 4 hours for one-half of the time and 3 hours for the second half.

The best strategy I can come up with for comparing is to integrate dataset A for 5 minutes through the timeseries

I want to note that I am not looking to do a rolling average, so I want the integrated sum for each of the 5-minute block. For example, 16:00 to 16:05 should output a y-value, and 16:06 to 16:10 should be integrated to output another y-value that is independent of the previous value. For each y-value, x = the integration start time.

Is there an in-built procedure/macro in Igor that can help me do this? I am familiar with rolling averages but not integration. Happy to clarify any questions!

Thank you.

> Is there an in-built procedure/macro in Igor that can help me do this?

Look for command help on the area function and the Integrate operation.

Thank you, jjweimer. I read the command help on the area function and integrate operation. While it did not give me the exact answers I needed, I was able to use it to develop a procedure.

However, the code still does not work as expected. I am not sure what I am missing yet. 
PS: My igor programming skills are at a novice level so I may just be making obvious mistakes.

Function IntegrateWave(yWave, x1, xInterval, totalDuration)
//declare waves and variables used in function
	wave yWave
	int x1, xInterval, totalDuration
    Variable startTime, endTime, resultCount 
    Variable i, j
    Variable area, startIdx, endIdx
    wave integrationResult
    // Calculate the number of integration intervals
    resultCount = floor(totalDuration / xInterval)
    // Create a new wave to store integration results. N should be equal to the resultCount
    Make /N=(resultCount) integrationResults = 0
    // Perform integration for each interval. More like define start and end times for x waves with intervals 
    for (i = 0; i < resultCount; i++)
        startTime = x1 + i * xInterval
        endTime = startTime + 300 //300 in seconds, ie 5 minutes integration time
        // Ensure we stay within the bounds of the yWave
        startIdx = round(startTime)
        endIdx = round(endTime)
        if (startIdx < 0 || endIdx >= numpnts(yWave))
            Print "Time interval out of bounds."
            edit integrationResults
        endif
        // Perform trapezoidal integration of yWave
        area = 0
        for (j = startIdx; j < endIdx - 1; j++)
            area += 0.5 * (yWave[j] + yWave[j + 1]) * (1) // Assuming x increments by 1 second
        endfor
        integrationResults[i] = area
    endfor
    edit integrationResults
End