Time/ Date manipulation
I have time stamps from two different instruments in different formats that I am trying to align (so that I can later average out data to account for different time resolutions). The first is in a wave in hours with no specified date (ex: 17.12345 h) in UTC, and the second is in wave of MM:DD:YYYY hr:min:sec (ex: 6/21/2018 12:34:56.789) in pacific time. I would like to throw out the date stamp on the second wave and generate an output wave in seconds for each instrument.
The best way I can see to do this would be to have two separate functions to deal with each time. I am new to igor and I'm having a hard time with syntax, I would appreciate any and all suggestions. I have included the files below.
Thanks
To remove the date component of an Igor date/time value, execute something like this:
For details, execute:
August 6, 2018 at 12:29 pm - Permalink
Correction: It should be:
More generally:
// w is assumed to contain Igor date/time values in increasing order.
// Example:
// Make/O/D/N=3 dtWave
// SetScale d, 0, 0, "dat", dtWave // Mark as date/time wave
// dtWave[0] = {Date2Secs(2018,06,21)+5000}
// dtWave[1] = {Date2Secs(2018,06,21)+10000}
// dtWave[2] = {Date2Secs(2018,06,21)+15000}
// Edit dtWave
// ModifyTable format(dtWave)=8 // Display as date/time values
// RemoveDateFromDateTimeWave(dtWave)
// ModifyTable format(dtWave)=7 // Display as time values
Function RemoveDateFromDateTimeWave(w)
Wave w // Assumed to contain Igor date/time values in increasing order
Variable dateTime0 = w[0]
String date0Str = Secs2Date(dateTime0, -2) // In YYYY-MM-DD format
Variable year, month, day
sscanf date0Str, "%d-%d-%d", year, month, day
Variable date0Secs = Date2Secs(year, month, day)
w -= date0Secs
End
After the RemoveDateFromDateTimeWave, the times are displayed in the table as, e.g., "1904-01-01 01:23:20". Since 1904-01-01 is the base of the Igor date/time system, 1904-01-01 is represented as zero seconds.
August 6, 2018 at 02:54 pm - Permalink
hrodstein,
I apologize for the late response, your function worked perfectly for removing the date. I now have hh:mm:ss.xxxx format that I would like to get into seconds since 1904-01-01. Based on some of your other comments, it seems like this is how igor stores the times anyways, but how should I go about displaying those values?
Thank you for your help.
August 9, 2018 at 06:52 am - Permalink
The following command will display the time in seconds. Since the original time date wave was an igor time/date wave, all I had to do was use:
Additional help from hrodstein can be found at this link too https://www.wavemetrics.com/forum/general/timewave-seconds. Again, thank you very much.
August 9, 2018 at 07:06 am - Permalink