Converting seconds into time and date
Turtle Sandwich
I am trying to fix my function so that I can convert my time wave, which is in seconds, to a time and date wave (00:00:00 YYYY/MM/DD).
This is the program I have written but IGOR won't allow me to compile this and I think it's because I have the secs2date function. I am an amateur programmer so if anyone can help me fix this, that would be great!
Function time2date(time_wave)
Wave time_wave
variable i
Duplicate/o time_wave time_date_wave
For (i=0; i<(numpnts(time_wave)); i+=1)
date_wave = (secs2date(date_wave[i], -1)[6,9])
Endfor
Appendtotable time_date_wave
End
Wave time_wave // numeric wave in seconds
variable i
// Make a text wave with the same number of rows as the input wave.
Make/O/N=(DimSize(time_wave, 0))/T date_time_text_wave
For (i=0; i<(numpnts(time_wave)); i+=1)
date_time_text_wave = secs2time(time_wave[i], 3) + " " + secs2date(time_wave[i], -2, "/")
Endfor
Appendtotable date_time_text_wave
End
Note that both secs2time and secs2date assume that you are providing a wave containing the number of seconds since 1/1/1904. If your input wave doesn't use the same baseline, you will need to add an offset factor so that you get the correct date in the output wave.
If you haven't done so already, I suggest that you go through the guided tour to familiarize yourself with Igor. Select the Help->Getting Started menu item to get started. The guided tour doesn't cover this specific point, but it introduces you to important concepts you need to understand to use Igor efficiently.
January 28, 2016 at 09:45 am - Permalink
January 28, 2016 at 10:16 am - Permalink
To aclight, I tried running this program you suggested but it gave me a similar error to one of my previous attempts. The date stays the same throughout the entire wave (1904/12/30) and doesn't increase by day/month as I'd like it to.
January 28, 2016 at 01:56 pm - Permalink
Your original complaint was that the function you wrote would not compile. The function I provided above does compile. Since you didn't provide an example of the wave you're passing into the function, it's hard to offer advice about how to solve your problem since we can't reproduce it in the first place.
January 28, 2016 at 02:06 pm - Permalink
Edit junk
What you see is very large numbers. Now do this:
Now you see how Igor interprets those big numbers when it's told that they represent date/time data.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
January 28, 2016 at 05:24 pm - Permalink