comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Time conversion for .nc file
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Time conversion for .nc file [message #86489 is a reply to message #86486] Wed, 13 November 2013 09:26 Go to previous messageGo to previous message
lecacheux.alain is currently offline  lecacheux.alain
Messages: 325
Registered: January 2008
Senior Member
Le mercredi 13 novembre 2013 16:44:01 UTC+1, David Fanning a écrit :
> Madhavan Bomidi writes:
>
>
>
>> I have date & UTC time in tow columns as [YYYYMMDD HRMISE], where YYYY - Year, MM - Month, DD - day, HR - Hours, MI - Minutes, SE - Seconds. Now, I wanted to convert to the "time" variable according to NetCDF convention. I mean to say that I wanted to convert my date & UTC time values to "time" in seconds since 1970-01-01 00:00:00 (in UTC). Can anyone help me how I can use SYSTIME function available in IDL?
>
>
>
> I wouldn't use the SYSTIME function. I would use the JULDAY function. I
>
> would read the two columns of data as a single string array. Then, I
>
> would do something like this (using a scalar string as an example, but
>
> this will work for a string array, too):
>
>
>
> str = '20131113 083122'
>
> year = Fix(StrMid(str,0,4))
>
> mon = Fix(StrMid(str,4,2))
>
> day = Fix(StrMid(str,6,2))
>
> hour = Fix(StrMid(str,9,2))
>
> min = Fix(StrMid(str,11,2))
>
> sec = Fix(StrMid(str,13,2))
>
> jultime = JulDay(mon,day,year,hour min,sec) - JulDay(1,1,1970,0,0,0)
>
> ncdfTime = jultime * 24 * 60 * 60
>
> print, ncdfTime
>
>
>
> Cheers,
>
>
>
> David
>
> --
>
> David Fanning, Ph.D.
>
> Fanning Software Consulting, Inc.
>
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
>
> Sepore ma de ni thue. ("Perhaps thou speakest truth.")

You might also use string C format:

jd = 0d0
reads, '20131113 083122', jd, FORMAT='(C(CYI4,CMOI2,CDI2,1x,CHI2,CMI2,CSI2))'
jd -= Julday(1,1,1970,0,0,0)
jd *= 86400d0
ncdfTime = jd

Date string arrays can be handled in the same way.
alx.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: IDL refuse to acknowledge anything but integers...
Next Topic: Derivatives

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Thu Oct 09 20:00:28 PDT 2025

Total time taken to generate the page: 0.57122 seconds