Re: array of Julian Days [message #63521] |
Wed, 12 November 2008 10:13  |
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   |
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   |
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   |
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   |
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   |
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 #63548 is a reply to message #63545] |
Tue, 11 November 2008 14:37   |
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   |
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 #63554 is a reply to message #63551] |
Tue, 11 November 2008 13:57   |
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 #63606 is a reply to message #63521] |
Thu, 13 November 2008 01:32  |
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
|
|
|