[Thread Prev][Thread Next][Index]

Re: [ferret_users] count consecutive events



Peter Szabo a écrit :
I see now. anyway, it is really easy after you follow me. Leave @loc function (the last line i wrote in my previous letter), then you only have to use some if-then cycles to get how many occurence are.

let s2=if conseq eq 2 then 1; let howmany2=s2[i=@sum] !and so on... so howmany2 will give you the number of events of 2 consecutive values.

or use the @evnt.
Sorry again Peter but this not the right answer.
Using your code, you get 7 events of 2 consecutives values of 1.
You should find 4.

yes? use v1.nc
yes? let conseq=v1[i=@cda:1]
yes? let s2=if conseq eq 2 then 1
yes? list v1,conseq,s2
yes? let howmany2=s2[i=@sum]
yes? list howmany2
           VARIABLE : S2[I=@SUM]
           FILENAME : v1.nc
           X        : 0.5 to 52.5
        7.000

Publish on mailling list if you can find the exact result which are for the file attached v1.nc
5 events of 1 consecutive values at 1
4 events of 2 consecutive values at 1
1 event  of 3 consecutive values at 1
3 events of 4 consecutive values at 1

Patrick




On Fri, Jun 20, 2008 at 3:21 PM, Brockmann Patrick <Patrick.Brockmann@xxxxxx <mailto:Patrick.Brockmann@xxxxxx>> wrote:

    Peter Szabo a écrit :

        Hi Patrick,

        try something like this in the beginning of your script (the
        leftover is not necessary):

        let b = If a le 0.45 then 1
        !i changed it intentionally. you will have missing values
        instead of 1 at the right points

        let conseq=b[i=@cda:1] !with @cda you will have the data in a
        format like ,,5,4,3,2,1,,,, instead of ,,1,1,1,1,1,,,,

        let whereis5=conseq[i=@loc:5]
        !the @loc finds the start of the consecutive events. in this
        case 5.

        Is this what you wanted?

    Not at all.
    I would like the result as follows

    5 events of 1 consecutive values at 1
    4 events of 2 consecutive values at 1
    1 event  of 3 consecutive values at 1
    3 events of 4 consecutive values at 1

    Ok thank you anyway.
    Good try.

    Patrick

-- LSCE/IPSL, Laboratoire CEA-CNRS-UVSQ
    Data Analysis and Visualization Engineer
    IPSL Global Climate Modelling Group
    --



Attachment: v1.nc
Description: Binary data


[Thread Prev][Thread Next][Index]

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

Privacy Policy | Disclaimer | Accessibility Statement