Re: Problem with for-slope [message #48634 is a reply to message #48612] |
Wed, 03 May 2006 04:41   |
Benjamin Luethi
Messages: 22 Registered: December 2004
|
Junior Member |
|
|
Hi,
You see the mistake right away if you put in k=17:
time_LM_1h_oV(17,l)= time_LM(17,i)
but you declared
time_LM_1h_oV=FLTARR(12, 0.25*nline_LM+1)
To solve this problem use
time_LM_1h_oV(k-5,l)= time_LM(k,i)
Or a lot better: let IDL do the work for you without any loops
(look up "subscript ranges" in the IDL help)
time_LM_1h_oV = time_LM[5:*,0:*:4]
t2m_LM_1h_oV = t2m_LM[5:*,0:*:4]
...
Ben
On Wed, 03 May 2006 09:52:43 +0200, Nexia <weckerb@uni-mainz.de> wrote:
> Hello,
>
> i´m pretty new to this group and in programming, so please excuse
> stupid questions of if something simliar has been asked yet.
>
> My programm is getting input from different files
>
> nfiles_LM=17
> file[0]=...
> ....
> file[16]=...
>
> the input is working quite well and doing a selection of several part
> of chosen values (for example, getting each fouth value in time for
> each file k) is working, too.
>
> My Problem: I want to make a choice of stations k (there is input from
> observational stations in the files) to bee used. I only need the last
> 12 files (k=5 to k=16 if I start counting from 0)
>
> FOR k=5, nfiles_LM-1 DO BEGIN ; take the last 12 files
> l=0
> FOR i=0,nline_LM-1, 4. DO BEGIN ; take only every 4th value
> time_LM_1h_oV(k,l)= time_LM(k,i)
> t2m_LM_1h_oV(k,l)= t2m_LM(k,i)
> rh2m_LM_1h_oV(k,l) = rhum_LM(k,i)
> td2m_LM_1h_oV(k,l) = td2m_LM(k,i)
> q2m_LM_1h_oV(k,l) = QV_2M_LM(k,i)
> pres_LM_1h_oV(k,l) = pres_LM(k,i)
> wspeed_LM_1h_oV(k,l)=windspeed_10m_LM(k,i)
> l=l+1
> ENDFOR
> ENDFOR
>
> The declaration was made befor this slope....
> (nfiles_LM-1 = 17, nfiles_LM_oV=12
> time_LM_1h_oV=FLTARR(nfiles_LM_oV, 0.25*nline_LM+1) & t2m_LM_1h_oV =
> time_LM_1h_oV & pres_LM_1h_oV = time_LM_1h_oV & rh2m_LM_1h_oV =
> time_LM_1h_oV & td2m_LM_1h_oV = time_LM_1h_oV & q2m_LM_1h_oV =
> time_LM_1h_oV &wspeed_LM_1h_oV =time_LM_1h_oV)
>
> For this slope I get the error-code: Attempt to subscript TIME_LM_1H_OV
> with K is out of range.
>
> If I select the first 12 files (k=0, nfiles_LM-6) everything is working
> fine like if I take all files (k=0, nfiles_LM-1).
>
> Can anybody tell me, what´s the mistake if I start the slope at k=5?
>
>
> Nexia
>
> P.S.: Please excuse also my very poor english-skill
>
--
-------------+
|
|
|