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

Home » Public Forums » archive » Re: Bug in IDL's TIMEGEN function
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: Bug in IDL's TIMEGEN function [message #55583] Fri, 24 August 2007 15:19 Go to next message
chris_torrence@NOSPAM is currently offline  chris_torrence@NOSPAM
Messages: 528
Registered: March 2007
Senior Member
Hi Dave,

Good catch! This is indeed a bug. I've just fixed the code for the
next IDL release.

If you want, you can patch your copy of timegen. Go to your $IDL_DIR/
lib/timegen.pro.
Around line 400, replace the following bad lines:
monthArray = (monthArray MOD 12) + 1
IF (step_size LT 0) THEN monthArray = (monthArray + 12) MOD 12
With the following good lines:
if (step_size ge 0) then begin
monthArray = (monthArray mod 12) + 1
endif else begin
monthArray = (((monthArray mod 12) + 12) mod 12) + 1
endelse

Using this version, I get the following results:
IDL> MyTimes = TIMEGEN( units="Months", step_size=-1, $
IDL> start=julday(1,15,2007), final=julday(10,15,2006))
IDL> print, MyTimes - MyTimes(0)
0.00000000 -31.000000 -61.000000 -92.000000

Hope this didn't cause you too many problems.
Cheers,

Chris Torrence
ITT Visual Information Solutions
Re: Bug in IDL's TIMEGEN function [message #55584 is a reply to message #55583] Fri, 24 August 2007 14:24 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Dave Wuertz writes:

> I found a bug in IDL's TIMEGEN function. It really nailed me good, as I
> was using the (erroneous) results from TIMEGEN to compute direct-access
> locations within database files.
>
> First off, I'm running IDL v6.4 on a 32-bit Linux-Intel box.
>
> TIMEGEN returns an incorrect sequence of julian dates when STEP_SIZE=-1,
> and UNITS="Months" when crossing year boundaries as demonstrated in
> the simple example below. Note the results *should* be monotonically
> decreasing.
>
> IDL> MyTimes = TIMEGEN( units="Months", step_size=-1,
> start=julday(1,15,2007), final=julday(10,15,2006))
> IDL> print, MyTimes - MyTimes(0)
> 0.0000000 -396.00000 -61.000000 -92.000000

Yeah, I'd say that was a bug. I'm using the 32-bit version of Windows.

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: Bug in IDL's TIMEGEN function [message #55681 is a reply to message #55583] Mon, 27 August 2007 10:01 Go to previous message
Dave Wuertz is currently offline  Dave Wuertz
Messages: 6
Registered: August 2007
Junior Member
chris_torrence@NOSPAMyahoo.com said the following on 8/24/2007 6:19 PM:
> Hi Dave,
>
> Good catch! This is indeed a bug. I've just fixed the code for the
> next IDL release.
>
> If you want, you can patch your copy of timegen. Go to your $IDL_DIR/
> lib/timegen.pro.
> Around line 400, replace the following bad lines:
> monthArray = (monthArray MOD 12) + 1
> IF (step_size LT 0) THEN monthArray = (monthArray + 12) MOD 12
> With the following good lines:
> if (step_size ge 0) then begin
> monthArray = (monthArray mod 12) + 1
> endif else begin
> monthArray = (((monthArray mod 12) + 12) mod 12) + 1
> endelse
>
> Using this version, I get the following results:
> IDL> MyTimes = TIMEGEN( units="Months", step_size=-1, $
> IDL> start=julday(1,15,2007), final=julday(10,15,2006))
> IDL> print, MyTimes - MyTimes(0)
> 0.00000000 -31.000000 -61.000000 -92.000000
>
> Hope this didn't cause you too many problems.
> Cheers,
>
> Chris Torrence
> ITT Visual Information Solutions
>

Thank you, Chris, for jumping on this and providing a patch so quickly!

Thanks also to David Fanning for testing the behavior on his platform.

-Dave Wuertz
Re: Bug in IDL's TIMEGEN function [message #55683 is a reply to message #55583] Mon, 27 August 2007 09:41 Go to previous message
R.G.Stockwell is currently offline  R.G.Stockwell
Messages: 163
Registered: October 2004
Senior Member
"chris_torrence@NOSPAMyahoo.com" <gorthmog@gmail.com> wrote in message
news:1187993940.201423.291250@r23g2000prd.googlegroups.com.. .
...
> If you want, you can patch your copy of timegen. Go to your $IDL_DIR/
> lib/timegen.pro.
> Around line 400, replace the following bad lines:
> monthArray = (monthArray MOD 12) + 1
> IF (step_size LT 0) THEN monthArray = (monthArray + 12) MOD 12
> With the following good lines:
> if (step_size ge 0) then begin
> monthArray = (monthArray mod 12) + 1
> endif else begin
> monthArray = (((monthArray mod 12) + 12) mod 12) + 1
> endelse


Thanks for the fast fix Chris!

cheers,
bob
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Natural size of explicitly-sized widget
Next Topic: Weighted histogram

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

Current Time: Wed Oct 08 19:39:23 PDT 2025

Total time taken to generate the page: 0.00831 seconds