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

Home » Public Forums » archive » Re: CalDat
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: CalDat [message #25026] Wed, 16 May 2001 01:11 Go to next message
Martin Schultz is currently offline  Martin Schultz
Messages: 515
Registered: August 1997
Senior Member
m.hadfield@niwa.cri.nz ("Mark Hadfield") writes:

> But what about this:
>
> CALDAT, double(2529161.36), Month, Day, Year, Hour, Minute, second
> print, Month, Day, Year, Hour, Minute, second
> ; 7 4 2212 18 0
> 0.00000000
>
> i.e. CALDAT gives the same result for double(2529161.36) as it does for
> 2529161.36.

Well, of course it should. The number 2529161.36 cannot be accurately
represented as float. You can test this with
IDL> print,float(2529161.36d0),format='(f15.6)'
2529161.250000


> I suggest that there is nothing wrong with CALDAT, but that floats have
> inadequate precision to represent Julian dates. The following shows that
> they are only accurate to ~0.3 days.
>
> ma = machar() & print, 2529161.36*ma.eps
> ; 0.301500
>

That hits the nail right on.

Martin

--
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
[[ 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: CalDat [message #25031 is a reply to message #25026] Tue, 15 May 2001 15:09 Go to previous messageGo to next message
m.hadfield is currently offline  m.hadfield
Messages: 36
Registered: April 2001
Member
"Ben Tupper" <pemaquidriver@tidewater.net> wrote in message
news:3B017E66.BD5C9F6D@tidewater.net...
> As single precision:
>
> IDL> CALDAT, 2529161.36, Month, Day, Year, Hour,
> Minute, Second
> IDL> PRINT, Month, Day, Year, Hour, Minute, Second
> 7 4 2212 18
> 0 0.00000000
>
> As double precision:
>
> IDL> CALDAT, 2529161.36d, Month, Day, Year, Hour,
> Minute, Second
> IDL> PRINT, Month, Day, Year, Hour, Minute, Second
> 7 4 2212 20
> 38 23.999989

I get the same results on my machine (which is not surprising as it's the
same IDL version). But what about this:

CALDAT, double(2529161.36), Month, Day, Year, Hour, Minute, second
print, Month, Day, Year, Hour, Minute, second
; 7 4 2212 18 0
0.00000000

i.e. CALDAT gives the same result for double(2529161.36) as it does for
2529161.36.

If you look inside CALDAT you will see that there is no difference in the
way it handles floats and doubles, and also that its constants are doubles
and longs. So for most purposes a float argument is promoted to double in
the calculation.

I suggest that there is nothing wrong with CALDAT, but that floats have
inadequate precision to represent Julian dates. The following shows that
they are only accurate to ~0.3 days.

ma = machar() & print, 2529161.36*ma.eps
; 0.301500


---
Mark Hadfield
m.hadfield@niwa.cri.nz http://katipo.niwa.cri.nz/~hadfield
National Institute for Water and Atmospheric Research


--
Posted from clam.niwa.cri.nz [202.36.29.1]
via Mailgate.ORG Server - http://www.Mailgate.ORG
Re: CalDat [message #25122 is a reply to message #25026] Wed, 16 May 2001 08:48 Go to previous message
Ben Tupper is currently offline  Ben Tupper
Messages: 186
Registered: August 1999
Senior Member
Thanks Mark and Martin,

I don't think the earlier discussion regarding float->double conversion had
sunk in.

It would be nice if the documentation for CalDat made the behavior clear.

Ben



Martin Schultz wrote:

> m.hadfield@niwa.cri.nz ("Mark Hadfield") writes:
>
>> But what about this:
>>
>> CALDAT, double(2529161.36), Month, Day, Year, Hour, Minute, second
>> print, Month, Day, Year, Hour, Minute, second
>> ; 7 4 2212 18 0
>> 0.00000000
>>
>> i.e. CALDAT gives the same result for double(2529161.36) as it does for
>> 2529161.36.
>
> Well, of course it should. The number 2529161.36 cannot be accurately
> represented as float. You can test this with
> IDL> print,float(2529161.36d0),format='(f15.6)'
> 2529161.250000
>
>> I suggest that there is nothing wrong with CALDAT, but that floats have
>> inadequate precision to represent Julian dates. The following shows that
>> they are only accurate to ~0.3 days.
>>
>> ma = machar() & print, 2529161.36*ma.eps
>> ; 0.301500
>>
>
> That hits the nail right on.
>
> Martin
>
> --
> [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
> [[ 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 [[
> [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[

--
Ben Tupper
248 Lower Round Pond Road
POB 106
Bristol, ME 04539

Tel: (207) 563-1048
Email: PemaquidRiver@tidewater.net
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: HDF-EOS and IDL
Next Topic: Widget_Label growth (Re: widget_control,draw_widget)

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

Current Time: Wed Oct 08 11:33:17 PDT 2025

Total time taken to generate the page: 0.00797 seconds