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.
September 23, 2024 at 01:29 pm - Permalink
Variable startTime, endTime, resultCountVariable i, jVariable area, startIdx, endIdxwave integrationResult// Calculate the number of integration intervalsresultCount = floor(totalDuration / xInterval)// Create a new wave to store integration results. N should be equal to the resultCountMake /N=(resultCount) integrationResults = 0// Perform integration for each interval. More like define start and end times for x waves with intervalsfor (i = 0; i < resultCount; i++)startTime = x1 + i * xIntervalendTime = startTime + 300 //300 in seconds, ie 5 minutes integration time// Ensure we stay within the bounds of the yWavestartIdx = round(startTime)endIdx = round(endTime)if (startIdx < 0 || endIdx >= numpnts(yWave))Print "Time interval out of bounds."edit integrationResultsendif// Perform trapezoidal integration of yWavearea = 0for (j = startIdx; j < endIdx - 1; j++)area += 0.5 * (yWave[j] + yWave[j + 1]) * (1) // Assuming x increments by 1 secondendforintegrationResults[i] = areaendforedit integrationResultsOctober 11, 2024 at 12:30 pm - Permalink