[Thread Prev][Thread Next][Index]

Re: [ferret_users] ferret 5.51 does not have repeat/range



Hi Peter,
You can do this without any loops, using the boxcar smoother @SBX instead of the `L`:`L+4`@sum. The boxcar smoother takes the sum of the data over the interval you give it, divided by the sum of the cell sizes. If the underlying L axis is evenly spaced, then we can use @SUM and multiply by 5 to get the sum over 5 days.

   LET precip_sum = 5*precip[L=@SBX:5]
   LET max_precip_5day = precip_sum[L=@max]

If the underlying axis is unevenly spaced, then you'd need to correct for that, something along these lines:

   LET tb = tbox[gt=precip]
   LET box_sum = 5*tb[L=@SBX:5]

   LET precip_sum = box_sum*precip[L=@SBX:5]
   LET max_precip_5day = precip_sum[L=@max]

All of this works best for an odd interval, such as 5. The result of var[L=@SBX:5] at L=3 is the sum of the data at L=1 through L=5. If you wanted an even interval, say 4, then the result of SBX:4 includes data from partial grid cells from the ends of the boxes.

Also, the above assumes that the axis is defined with units of days. If it has other units, like hours for instance, then the simple multiplication by 5 would need to be adjusted to fit those units.

Ansley

Peter Szabo wrote:

Dear Ferreters,

 

I am using ferret 5.51 which is the highest version for cygwin- XP. But this version does not have “repeat/range” command.

 

I count five-days precipitation summary in the period of 90 days in a region. With it I create 86 variables. I want to find the maximum of these variables. It works theoretically. And I also tried without a repeat with 3 variables. It worked.

Here is the problem part of the script:

 

let precip30=precip2*0

repeat/l=1:86 (let precip3`l`=precip2[l=`l`:`l+4`@sum,d=2])

repeat/range=1:86/name=a (if precip3`a` LE precip3`a-1` then (cancel variable precip3`a` ;\

let precip3`a`=precip3`a-1` ) )

let maximum=max(precip385,precip386)

 

I don’t know if I should 1) change to an other OS or 2) I should do something with cygwin and XP or 3) I should find out a better script to find the maximum among many variables.

Any suggestion will be appreciated,

 

Peter Szabo, ELTE


[Thread Prev][Thread Next][Index]

Contact Us
Dept of Commerce / NOAA / OAR / PMEL / TMAP

Privacy Policy | Disclaimer | Accessibility Statement