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

Home » Public Forums » archive » Re: hours since 1-1-1
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: hours since 1-1-1 [message #44864 is a reply to message #44859] Tue, 26 July 2005 20:00 Go to previous messageGo to previous message
Mark Hadfield is currently offline  Mark Hadfield
Messages: 783
Registered: May 1995
Senior Member
qian wrote:
> Dear IDL users:
>
> Is there an IDL function/program that converts the unidata time unit to
> more readable format?
>
> For example: hours since 1-1-1 17338824 -> Jan 1 1979.

Oh no, not hours since 1-1-1 again! That must be the silliest ever
date-time origin ever invented for modern data! I mean, what calendar
were they using then and why should I have to care?

Anyway, IDL has the JULDAY function, which calculates time in Julian
days, ie time since 12:00 hours on 1 Jan 4713BC. (OK, I withdraw my
comment about 1 Jan 0001 being the silliest ever date-time origin.)

The confusing things you have to remember:

- JULDAY uses the weird month, day, year order for dates.

- The Julian date reaches an integral at 12:00 each day, not at
00:00.

- JULDAY accepts optional hour, minute, second arguments. With them
it returns the true Julian date-time as a double precision floating
point number. Without them it returns the Julian date to be reached
at 12:00 on the day in question as an integer. (Got that?)


Consider the following calculations

IDL> print, julday(1,1,1,0,0,0)
1721423.5
IDL> print, julday(1,1,1979,0,0,0)-julday(1,1,1,0,0,0)
722451.00
IDL> print, 24*(julday(1,1,1979,0,0,0)-julday(1,1,1,0,0,0))
17338824.

It seems that JULDAY agrees with you and with Unidata, that
00:00 on 1 Jan 1979 was 722451 days == 17338824 hours after 00:00 on 1
Jan 0001.

IDL also offers the CALDAT function, to convert Julian date-times to
calendar date-times and the calendar format codes that let it express
real numbers as date-time strings (on the assumption they are Julian
date-times).

So to deal with "hours after 1-1-1" in IDl convert them to Julian
date-times immediately (divide by 24 then add 1721423.5D0) and then use
IDL's built-in facilities thereafter.

--
Mark Hadfield "Kei puwaha te tai nei, Hoea tahi tatou"
m.hadfield@niwa.co.nz
National Institute for Water and Atmospheric Research (NIWA)
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: 2 dimensional array from 3 x 1dimensional arrays
Next Topic: idl command line on windows

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

Current Time: Wed Oct 08 19:35:43 PDT 2025

Total time taken to generate the page: 0.00467 seconds