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

Home » Public Forums » archive » Re: array of Julian Days
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: array of Julian Days [message #63521] Wed, 12 November 2008 10:13 Go to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Bulrush writes:

> On Nov 12, 9:37=A0am, David Fanning <n...@dfanning.com> wrote:
>> Bulrush writes:
>>> With the while loop, I got only 8 values, each increased just +1, e.g.
>>> 264,265,266... even if I set the step as 8. And become dead loop,
>>> looping all the day non-stop for that the same 8 values.
>>
>> Your while loop ran all day long because you never
>> changed the conditional variable. Thus, it started
>> true and it remained true. (It's probably still true
>> now!)
> Here is the updated code. How can I stop then. Why the days are not
> increasing steps of 8, and just increasing with an increment of 1?
> JDays = LINDGEN(366)
> Daystep = 265
> ; collect the days
>
> WHILE Daystep LE 363 Do Begin
> arr =D WHERE((JDays LE Daystep+8) AND (JDays GT Daystep),count)
> IF count GT 0 THEN Days =JDays[arr] ELSE days = [-1]
> print, days
> ENDWHILE

You can stop it by making the control variable "daystep"
greater than 363. You don't change it's value anywhere
in this loop, so it *stays* less than 363 forever and ever.

If you put a breakpoint in your code and step through this
a couple of times, I think eventually you will discover the
problem. :-)

Cheers,

David

--
David Fanning, Ph.D.
Coyote's Guide to IDL Programming (www.dfanning.com)
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: array of Julian Days [message #63524 is a reply to message #63521] Wed, 12 November 2008 09:09 Go to previous messageGo to next message
Wasit.Weather is currently offline  Wasit.Weather
Messages: 62
Registered: February 2008
Member
On Nov 12, 9:37 am, David Fanning <n...@dfanning.com> wrote:
> Bulrush writes:
>> With the while loop, I got only 8 values, each increased just +1, e.g.
>> 264,265,266... even if I set the step as 8. And become dead loop,
>> looping all the day non-stop for that the same 8 values.
>
> Your while loop ran all day long because you never
> changed the conditional variable. Thus, it started
> true and it remained true. (It's probably still true
> now!)
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Here is the updated code. How can I stop then. Why the days are not
increasing steps of 8, and just increasing with an increment of 1?
JDays = LINDGEN(366)
Daystep = 265
; collect the days

WHILE Daystep LE 363 Do Begin
arr = WHERE((JDays LE Daystep+8) AND (JDays GT Daystep),
count)
IF count GT 0 THEN Days = JDays[arr] ELSE days = [-1]
print, days
ENDWHILE
Re: array of Julian Days [message #63526 is a reply to message #63524] Wed, 12 November 2008 07:37 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Bulrush writes:

> With the while loop, I got only 8 values, each increased just +1, e.g.
> 264,265,266... even if I set the step as 8. And become dead loop,
> looping all the day non-stop for that the same 8 values.

Your while loop ran all day long because you never
changed the conditional variable. Thus, it started
true and it remained true. (It's probably still true
now!)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: array of Julian Days [message #63528 is a reply to message #63526] Wed, 12 November 2008 07:21 Go to previous messageGo to next message
Wasit.Weather is currently offline  Wasit.Weather
Messages: 62
Registered: February 2008
Member
On Nov 12, 3:08 am, Reimar Bauer <R.Ba...@fz-juelich.de> wrote:
> Bulrush schrieb:
>
>
>
>
>
>> On Nov 11, 4:12 pm, David Fanning <n...@dfanning.com> wrote:
>>> Reimar Bauer writes:
>>>> Anyway I want also give some hints. idl has builtin step methods (oh,
>>>> david what is the right word for that)
>>> "Stride", I think. ;-)
>
>>> Cheers,
>
>>> David
>>> --
>>> David Fanning, Ph.D.
>>> Coyote's Guide to IDL Programming (www.dfanning.com)
>>> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
>
>> Thank you all.
>> Actually these are strings included in data names. I wanted to extract
>> 263+8, 263+8+8, 263+8+8+8... until upper limit is reached at 361. Then
>> I would loop for these as string in data names, find the 8-day
>> composite data.
>
>> Thanks
>
> looks like you want to built an index vector with a stride of 8.
>
> Reimar- Hide quoted text -
>
> - Show quoted text -

Yes, I tried FOR loop steps, Array steps, and the last one works for
me.
It is really exciting to know the "stride"

Thank you all.
My problem related with topic has been solved. But I am curios on the
While loop, still :)
With the while loop, I got only 8 values, each increased just +1, e.g.
264,265,266... even if I set the step as 8. And become dead loop,
looping all the day non-stop for that the same 8 values.

This is really great place to enjoy.
:)
Re: array of Julian Days [message #63535 is a reply to message #63528] Wed, 12 November 2008 01:08 Go to previous messageGo to next message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
Bulrush schrieb:
> On Nov 11, 4:12 pm, David Fanning <n...@dfanning.com> wrote:
>> Reimar Bauer writes:
>>> Anyway I want also give some hints. idl has builtin step methods (oh,
>>> david what is the right word for that)
>> "Stride", I think. ;-)
>>
>> Cheers,
>>
>> David
>> --
>> David Fanning, Ph.D.
>> Coyote's Guide to IDL Programming (www.dfanning.com)
>> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
>
> Thank you all.
> Actually these are strings included in data names. I wanted to extract
> 263+8, 263+8+8, 263+8+8+8... until upper limit is reached at 361. Then
> I would loop for these as string in data names, find the 8-day
> composite data.
>
> Thanks

looks like you want to built an index vector with a stride of 8.

Reimar
Re: array of Julian Days [message #63536 is a reply to message #63535] Wed, 12 November 2008 01:05 Go to previous messageGo to next message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
R.G. Stockwell schrieb:
> "Bulrush" <Wasit.Weather@gmail.com> wrote in message
> news:2a70777d-8578-42bc-9700-9e6be44a2fb4@a3g2000prm.googleg roups.com...
>> Hello,
>> I wanted to generate an array of Jdays of the year, and extract some
>> of them according to 8 days of increment. However the following code I
>> could think of does not work.
>>
>> Any help is appreciated.
>>
>> Jdays = Lindgen (366)
>> Start_day= 265
>> End_day = 361
>>
>> Daystep = 265
>> ; collect the days
>> WHILE Daystep LE 361and Daystep GT 265 Do Begin
>> arr = Where (Jdays LE Daystep+8 and Jdays GT Daystep, count)
>> Days = JDays[arr]
>> EndWhile
>>
>> What is wrong with it? How can I get the job done?
>>
>> Thanks
>
> JD for current dates is quite a large number, but that is besides the point.
> From your example, i don't know if you are trying to extract 8 days,
> or trying to extract a series of 8 day arrays.
>
>
> Here is an example (the simple, select 8 days one):
>
>
> Jdays = Lindgen (366)
> Start_day= 265
> End_day = 361
>
> Daystep = 265
> ; collect the days
> arr = Where (Jdays LE Daystep+8 and Jdays GT Daystep, count)
>
> if count gt 0 then Days = JDays[arr] else days = [-1]
>
> print,days
>
>
>
> Cheers,
> bob
>
>


that arr can be created by arr = lindgen(8) + Daystep + 1 no need for where

cheers
Reimar
Re: array of Julian Days [message #63545 is a reply to message #63536] Tue, 11 November 2008 15:24 Go to previous messageGo to next message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
On Nov 11, 4:51 pm, Reimar Bauer <R.Ba...@fz-juelich.de> wrote:
...
> e.g. array indices can be stepped
> IDL> print, (lindgen(50))[0:49:8]
...

WHAAAAAA??????? When did that happen? I've never seen the stride
notation before! Ahh, now I see it happened in IDL 6.0. I'm such an
oldie. :-)
Re: array of Julian Days [message #63548 is a reply to message #63545] Tue, 11 November 2008 14:37 Go to previous messageGo to next message
Wasit.Weather is currently offline  Wasit.Weather
Messages: 62
Registered: February 2008
Member
On Nov 11, 4:12 pm, David Fanning <n...@dfanning.com> wrote:
> Reimar Bauer writes:
>> Anyway I want also give some hints. idl has builtin step methods (oh,
>> david what is the right word for that)
>
> "Stride", I think. ;-)
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Coyote's Guide to IDL Programming (www.dfanning.com)
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")

Thank you all.
Actually these are strings included in data names. I wanted to extract
263+8, 263+8+8, 263+8+8+8... until upper limit is reached at 361. Then
I would loop for these as string in data names, find the 8-day
composite data.

Thanks
Re: array of Julian Days [message #63549 is a reply to message #63548] Tue, 11 November 2008 14:35 Go to previous messageGo to next message
Wasit.Weather is currently offline  Wasit.Weather
Messages: 62
Registered: February 2008
Member
On Nov 11, 4:12 pm, David Fanning <n...@dfanning.com> wrote:
> Reimar Bauer writes:
>> Anyway I want also give some hints. idl has builtin step methods (oh,
>> david what is the right word for that)
>
> "Stride", I think. ;-)
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Coyote's Guide to IDL Programming (www.dfanning.com)
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")

Thank you all.
Actually these are strings included in data names. I wanted to extract
263+8, 263+8+8, 263+8+8+8... until upper limit is reached at 361. Then
I would loop for these as string in data names, find the 8-day
composite data.

Thanks
Re: array of Julian Days [message #63551 is a reply to message #63549] Tue, 11 November 2008 14:12 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Reimar Bauer writes:

> Anyway I want also give some hints. idl has builtin step methods (oh,
> david what is the right word for that)

"Stride", I think. ;-)

Cheers,

David
--
David Fanning, Ph.D.
Coyote's Guide to IDL Programming (www.dfanning.com)
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: array of Julian Days [message #63554 is a reply to message #63551] Tue, 11 November 2008 13:57 Go to previous messageGo to next message
R.G. Stockwell is currently offline  R.G. Stockwell
Messages: 363
Registered: July 1999
Senior Member
"Bulrush" <Wasit.Weather@gmail.com> wrote in message
news:2a70777d-8578-42bc-9700-9e6be44a2fb4@a3g2000prm.googleg roups.com...
> Hello,
> I wanted to generate an array of Jdays of the year, and extract some
> of them according to 8 days of increment. However the following code I
> could think of does not work.
>
> Any help is appreciated.
>
> Jdays = Lindgen (366)
> Start_day= 265
> End_day = 361
>
> Daystep = 265
> ; collect the days
> WHILE Daystep LE 361and Daystep GT 265 Do Begin
> arr = Where (Jdays LE Daystep+8 and Jdays GT Daystep, count)
> Days = JDays[arr]
> EndWhile
>
> What is wrong with it? How can I get the job done?
>
> Thanks

JD for current dates is quite a large number, but that is besides the point.
From your example, i don't know if you are trying to extract 8 days,
or trying to extract a series of 8 day arrays.


Here is an example (the simple, select 8 days one):


Jdays = Lindgen (366)
Start_day= 265
End_day = 361

Daystep = 265
; collect the days
arr = Where (Jdays LE Daystep+8 and Jdays GT Daystep, count)

if count gt 0 then Days = JDays[arr] else days = [-1]

print,days



Cheers,
bob
Re: array of Julian Days [message #63555 is a reply to message #63554] Tue, 11 November 2008 13:51 Go to previous messageGo to next message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
Bulrush schrieb:
> Hello,
> I wanted to generate an array of Jdays of the year, and extract some
> of them according to 8 days of increment. However the following code I
> could think of does not work.
>
> Any help is appreciated.
>
> Jdays = Lindgen (366)
> Start_day= 265
> End_day = 361
>
> Daystep = 265
> ; collect the days
> WHILE Daystep LE 361and Daystep GT 265 Do Begin
> arr = Where (Jdays LE Daystep+8 and Jdays GT Daystep, count)
> Days = JDays[arr]
> EndWhile
>
> What is wrong with it? How can I get the job done?
>
> Thanks


Do you ask us to debug your code ?

I don't want to be ignorant but a breakpoint and by stepping yourself
through the code line by line does help you more than a ready to go
solution from us.

Anyway I want also give some hints. idl has builtin step methods (oh,
david what is the right word for that)

e.g a for loop can step
IDL> for i=0,50,8 do print,i
0
8
16
24
32
40
48


e.g. array indices can be stepped
IDL> print, (lindgen(50))[0:49:8]
0 8 16 24 32 40
48

cheers
Reimar
Re: array of Julian Days [message #63606 is a reply to message #63521] Thu, 13 November 2008 01:32 Go to previous message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
David Fanning schrieb:
> Bulrush writes:
>
>> On Nov 12, 9:37=A0am, David Fanning <n...@dfanning.com> wrote:
>>> Bulrush writes:
>>>> With the while loop, I got only 8 values, each increased just +1, e.g.
>>>> 264,265,266... even if I set the step as 8. And become dead loop,
>>>> looping all the day non-stop for that the same 8 values.
>>> Your while loop ran all day long because you never
>>> changed the conditional variable. Thus, it started
>>> true and it remained true. (It's probably still true
>>> now!)
>> Here is the updated code. How can I stop then. Why the days are not
>> increasing steps of 8, and just increasing with an increment of 1?
>> JDays = LINDGEN(366)
>> Daystep = 265
>> ; collect the days
>>
>> WHILE Daystep LE 363 Do Begin
>> arr =D WHERE((JDays LE Daystep+8) AND (JDays GT Daystep),count)
>> IF count GT 0 THEN Days =JDays[arr] ELSE days = [-1]
>> print, days
>> ENDWHILE
>
> You can stop it by making the control variable "daystep"
> greater than 363. You don't change it's value anywhere
> in this loop, so it *stays* less than 363 forever and ever.
>
> If you put a breakpoint in your code and step through this
> a couple of times, I think eventually you will discover the
> problem. :-)

Wasn't that the initial idea two days before ?

I think we should also establish a while loop for you doing our
suggestion. We know you can't escape from that loop ;)


Reimar
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: convert 003 and 033 to strings
Next Topic: Workbench: Run idl several times

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

Current Time: Wed Oct 08 11:34:32 PDT 2025

Total time taken to generate the page: 0.01093 seconds