array of Julian Days [message #63557] |
Tue, 11 November 2008 13:18  |
Wasit.Weather
Messages: 62 Registered: February 2008
|
Member |
|
|
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
|
|
|
Re: array of Julian Days [message #63584 is a reply to message #63557] |
Fri, 14 November 2008 07:07  |
Wasit.Weather
Messages: 62 Registered: February 2008
|
Member |
|
|
On Nov 13, 3:32 am, Reimar Bauer <R.Ba...@fz-juelich.de> wrote:
> 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- Hide quoted text -
>
> - Show quoted text -
Thank David. I found the way to stop the loop.
|
|
|