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

Home » Public Forums » archive » timegen
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
timegen [message #86358] Wed, 30 October 2013 13:56 Go to next message
spluque is currently offline  spluque
Messages: 33
Registered: September 2013
Member
Hi,

I'm having a little difficulty generating time sequences with specific start and end values. Say, for instance we need to generate a sequence at 1 seconds and I need to cover the full final day. I thought this would do:

beg_jd=julday(10, 10, 2013, 0)
end_jd=julday(10, 11, 2013, 0)
step_size=0.1
ts=timegen(start=beg_jd, $
final=end_jd + 1 - (float(step_size) / 86400), $
step_size=step_size, units='seconds')

But, checking:

caldat, ts, mo, dd, yyyy, hh, mm, ss
print, yyyy[-1], mo[-1], dd[-1], hh[-1], mm[-1], ss[-1]

prints:

2013 10 11 23 59 59.802656

The last step is missing. What is wrong with this?

Thanks,
Seb
Re: timegen [message #86360 is a reply to message #86358] Wed, 30 October 2013 15:16 Go to previous messageGo to next message
Phillip Bitzer is currently offline  Phillip Bitzer
Messages: 223
Registered: June 2006
Senior Member
This may be pertinent, from the help:

Note: If the step size is not an integer then the last element may not be equal to the FINAL time. In this case, TIMEGEN will return enough elements such that the last element is less than or equal to FINAL.

If you 'caldat' your final time ( end_jd + 1 - (float(step_size) / 86400) ), I suspect this is the issue.

But, I'm not sure why this isn't what you're looking for:

ts=timegen(start=beg_jd, final=end_jd+1,step_size=step_size, units='seconds')
caldat, ts, mo, dd, yyyy, hh, mm, ss
print, yyyy[-1], mo[-1], dd[-1], hh[-1], mm[-1], ss[-1]
2013 10 11 23 59 59.902636

BTW, your original code contains the line
float(step_size)
which is superfluous - step_size is already a float, yes?
Re: timegen [message #86361 is a reply to message #86358] Wed, 30 October 2013 15:38 Go to previous messageGo to next message
suicidaleggroll is currently offline  suicidaleggroll
Messages: 14
Registered: September 2013
Junior Member
On Wednesday, October 30, 2013 2:56:35 PM UTC-6, spl...@gmail.com wrote:
> Hi,
>
>
>
> I'm having a little difficulty generating time sequences with specific start and end values. Say, for instance we need to generate a sequence at 1 seconds and I need to cover the full final day. I thought this would do:
>
>
>
> beg_jd=julday(10, 10, 2013, 0)
>
> end_jd=julday(10, 11, 2013, 0)
>
> step_size=0.1
>
> ts=timegen(start=beg_jd, $
>
> final=end_jd + 1 - (float(step_size) / 86400), $
>
> step_size=step_size, units='seconds')
>
>
>
> But, checking:
>
>
>
> caldat, ts, mo, dd, yyyy, hh, mm, ss
>
> print, yyyy[-1], mo[-1], dd[-1], hh[-1], mm[-1], ss[-1]
>
>
>
> prints:
>
>
>
> 2013 10 11 23 59 59.802656
>
>
>
> The last step is missing. What is wrong with this?
>
>
>
> Thanks,
>
> Seb

Never used timegen...what's so difficult about just doing:

beg_jd=julday(10,10,2013,0)
end_jd=julday(10,11,2013,0)
step_size=0.1/86400d0
ts=dindgen(round((end_jd-beg_jd)/step_size)+1)*step_size+beg _jd
Re: timegen [message #86363 is a reply to message #86360] Wed, 30 October 2013 19:36 Go to previous message
spluque is currently offline  spluque
Messages: 33
Registered: September 2013
Member
On Wed, 30 Oct 2013 15:16:57 -0700 (PDT),
Phillip Bitzer <bitzerp@uah.edu> wrote:

> This may be pertinent, from the help: Note: If the step size is not an
> integer then the last element may not be equal to the FINAL time. In
> this case, TIMEGEN will return enough elements such that the last
> element is less than or equal to FINAL.

> If you 'caldat' your final time ( end_jd + 1 - (float(step_size) /
> 86400) ), I suspect this is the issue.

> But, I'm not sure why this isn't what you're looking for:

> ts=timegen(start=beg_jd, final=end_jd+1,step_size=step_size,
> units='seconds') caldat, ts, mo, dd, yyyy, hh, mm, ss print, yyyy[-1],
> mo[-1], dd[-1], hh[-1], mm[-1], ss[-1] 2013 10 11 23 59 59.902636

> BTW, your original code contains the line float(step_size) which is
> superfluous - step_size is already a float, yes?

Thanks very much for these pointers. I left the float() call with
step_size by accident here. In the actual code, this is part of a
procedure that needs to be quite general for any step_size, so I'm
coercing it to float. You're quite right about the note in the help
page; that's exactly what's going on. To protect against this, the
following seems to do what I need:

step_d=float(step_time) / 86400
times=timegen(start=beg_jd, $
final=end_jd + 1 - (step_d / 2), $
step_size=step_time, units='seconds')

i.e. adding half a step to 'final' ensures that the last step is always
included.

Thanks,

--
Seb
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Map Projection
Next Topic: IDL 8.2 IDLnetURL insight

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

Current Time: Wed Oct 08 13:39:55 PDT 2025

Total time taken to generate the page: 0.00457 seconds