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

Home » Public Forums » archive » Re: Computing Time
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Computing Time [message #19377] Mon, 20 March 2000 00:00
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
Martin Schultz <martin.schultz@dkrz.de> writes:
>
> JULDAY will give you fractional days as an answer. To convert this back
> into
> days, hours, minutes, etc., you can do:
> days = fix(diff) ; or long() if you desire
> hour = fix( (diff-days)*24. )
> minute = fix( (diff-days-hour/24.)*1440. )
> second = fix( (diff-days-hour/24.-minute/1440.)*86400. )
> just that you may run into roundoff problems here or there. And this is
> why you should probably follow Liam's advice and use the JHU APL
> routines.

Would it be wiser to use FLOOR() instead of FIX(), to handle negative
time differences? This always gets a little sticky.

Craig


--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
Re: Computing Time [message #19382 is a reply to message #19377] Mon, 20 March 2000 00:00 Go to previous message
Martin Schultz is currently offline  Martin Schultz
Messages: 515
Registered: August 1997
Senior Member
loeh@my-deja.com wrote:
>
> Hi,
> I have a couple of measurements and like to calculate the time between
> them. But I am not sure which routine to use.
> I tried the following but the result is confusing
> IDL> diff=JULDAY(3,17,2000,17,30,22)-JULDAY(3,17,2000,15,22,17)
> IDL> print,diff
> 0.088946760
> IDL> CALDAT, diff, Month, Day, Year, Hour, Minute, Second
> IDL> PRINT, Month, Day, Year, Hour, Minute, Second
> 1 1 -4713 14 8
> 5.0000381
> Thanks for help
> Mirko
>

JULDAY will give you fractional days as an answer. To convert this back
into
days, hours, minutes, etc., you can do:
days = fix(diff) ; or long() if you desire
hour = fix( (diff-days)*24. )
minute = fix( (diff-days-hour/24.)*1440. )
second = fix( (diff-days-hour/24.-minute/1440.)*86400. )
just that you may run into roundoff problems here or there. And this is
why you should probably follow Liam's advice and use the JHU APL
routines.

Cheers,
Martin


PS: and to save you from likely headaches: always use DOUBLE if you deal
with time variables (except maybe for storing them in a file)

--
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
[[ Dr. Martin Schultz Max-Planck-Institut fuer Meteorologie [[
[[ Bundesstr. 55, 20146 Hamburg [[
[[ phone: +49 40 41173-308 [[
[[ fax: +49 40 41173-298 [[
[[ martin.schultz@dkrz.de [[
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
Re: Computing Time [message #19387 is a reply to message #19377] Fri, 17 March 2000 00:00 Go to previous message
Brian Jackel is currently offline  Brian Jackel
Messages: 34
Registered: January 1998
Member
loeh@my-deja.com wrote:
>
> Hi,
> I have a couple of measurements and like to calculate the time between
> them. But I am not sure which routine to use.

I've been using CDF_EPOCH for things like this. It lets you convert
year,month,day,hour,minute,second to a double precision value of
the number of milliseconds since Jan01/0000 and back again.



Brian
Re: Computing Time [message #19388 is a reply to message #19387] Fri, 17 March 2000 00:00 Go to previous message
Liam E. Gumley is currently offline  Liam E. Gumley
Messages: 378
Registered: January 2000
Senior Member
loeh@my-deja.com wrote:
> I have a couple of measurements and like to calculate the time between
> them. But I am not sure which routine to use.
> I tried the following but the result is confusing
> IDL> diff=JULDAY(3,17,2000,17,30,22)-JULDAY(3,17,2000,15,22,17)
> IDL> print,diff
> 0.088946760
> IDL> CALDAT, diff, Month, Day, Year, Hour, Minute, Second
> IDL> PRINT, Month, Day, Year, Hour, Minute, Second
> 1 1 -4713 14 8
> 5.0000381

I recommend the JHU/APL time routines:
http://fermi.jhuapl.edu/s1r/idl/s1rlib/time/time.html

Cheers,
Liam.
http://cimss.ssec.wisc.edu/~gumley
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: xloadct
Next Topic: better 3D surfaces ?

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

Current Time: Wed Oct 08 19:34:25 PDT 2025

Total time taken to generate the page: 0.00704 seconds