Weekday & Weekend Waves?
CsCs
I am new to IGOR and need some assistance. I have minute-by-minute date/time and concentration data for a chemical species over several months as follows:
2015-06-02 17:47:00 329.19
2015-06-02 17:48:00 329.19
2015-06-02 17:49:00 329.19
2015-06-02 17:50:00 329.12
2015-06-02 17:51:00 329.13
I would like to create a graph to show the statistics of the data when binned by the time of day in hourly intervals.
My task is similar to the following: http://www.igorexchange.com/node/2771 and the solution made available by user hrodstein works perfectly.
However, in addition, I would like to separate my data into weekday and weekend waves, to make two graphs rather than a single graph encompassing all of the dates.
With a quick search I came across the following: http://www.igorexchange.com/node/5538 but being new to IGOR, I do not know how to apply it.
Any assistance would be greatly appreciated.
Thank you,
CsCs
If you have not already done it, do the first half of the Igor guided tour by choosing Help->Getting Started. It is indispensable and will save you a lot of time.
I'll try to explain how it works.
In Igor, date/time data is stored as seconds since 1904-01-01. Given a wave containing date/time data, we want to create two waves: one containing weekday date/time values and the other containing weekend values.
To create the waves we use the Extract operation. The Extract operation creates a new wave, or overwrites an old wave, by selecting those elements of a source wave that meet a specified criterion. Here is an example that splits a wave up into negative and non-negative waves:
•Extract/O rawData, nonNegative, rawData >=0 // Create non-negative wave
•Extract/O rawData, negative, rawData <0 // Create negative wave
•Print nonNegative
nonNegative[0]= {3,7,0,9}
•Print negative
negative[0]= {-4,-8,-1}
The first Extract command loops over each point of the input wave, named rawData in this case, and, if the point matches the expression (rawData >=0), it stored the point's value in the output wave, named nonNegative in this case. Here is what Igor is doing expressed in pseudo code. This occurs internally in Igor:
Variable numPoints = numpnts(rawData)
Variable i
for(i=0; i<numPoints; i+=1)
if (rawData[i] >= 0)
<store point i's value in the next available point of the output wave
endif
endfor
Hopefully you now understand what Extract does. If not, read this post again.
So we have seen how to split a wave into a non-negative wave and a negative wave using the expressions "rawData>=0" and "rawData<0". But we want to split a date/time wave into weekday and weekend waves. For that we need an expression that tells us if a given date/time value falls on a week day or a weekend. There is no such built-in function in Igor so I wrote the IsWeekday function at http://www.igorexchange.com/node/5538. Using that function, we can then use Extract to create weekday and weekend waves.
That is what the Demo function at http://www.igorexchange.com/node/5538 is doing. It first creates sample data named xData and yData. It then uses Extract to create four waves: xDataWeekday, yDataWeekday, xDataWeekend and yDataWeekend.
It then displays the weekday and weekend XY pairs in a graph.
You should be able to use the code from http://www.igorexchange.com/node/5538 as follows:
1. Copy the code from http://www.igorexchange.com/node/5538 to the clipboard.
2. Open the Igor procedure window (Windows->Procedures->Procedure Window) and paste the code into it.
3. Remove the first four lines of the Demo function. They create sample data but you have real data.
4. Replace the names xData and yData with the names of your X (date/time) and Y waves.
5. Execute the Demo function from the command line.
If this is too confusing to follow, take a time out, put your current task aside, and go through the first half of the Igor guided tour by choosing Help->Getting Started. This will give you the necessary background information and skills. Then reread this post.
July 13, 2015 at 10:50 pm - Permalink