[Thread Prev][Thread Next][Index]

Re: nested conditional statements



Hi Brent,
In general, you can do the nested conditional using masking:

  let mask = if condition then 1
  repeat/l=1:15  if `mask*(next condition)` then list...

On the mask definition, by default the "else" is missing data, or false.  i.e.
it's the same as "let mask = if condition then 1 else bad". So multiplying
the mask by the next condition is equivalent to an "and" operation.  To get
at the didt(l+1) that you want, use the @shf operator.  So in outline you
would have:

  let aoshift = ao[l=@shf:-1]
  let didt = ao[l=@ddc]

  let didtp1 =aoshift[l=@ddc]
  list/l=1:5 didt, didtp1    ! check that we have l, l+1

  let mask = if didt gt threshold then 1
  repeat/l=1:15 if `mask*(didtp1 gt threshold)` then list...
 
 

Brent A McDaniel wrote:

Greetings,

Hopefully someone can help me out with this simple question.

I have data with 14610 time steps and I want to pick out certain cases
according to the value of the derivative of an index AO.

Here's what I do:

let didt=ao[d=1,l=@ddc]
let threshold=.25

repeat/l=1:14610 if `didt gt threshold` then
save/file=case.slope.25.nc/append utend

and this works fine.

What I want to do is similar but I want the derivative to be over 2 days
(or more).

In psuedo code, something like:

For l=1:14610:1
        if didt(l) > threshold
                if didt(l+1) > threshold
                        then write the data out for l

else continue through the loop.

I hope this makes sense.

If that's not clear on what I'm asking, another example where similar
ability would make life easier is a case study looking for when the index
crosses some threshold.

something like:

for l=1:14610:1
        if ao(l) > threshold
                if ao(l-1) < threshold
                        then write the data at l

else continue through the loop.

I've wanted to be able to do similar things with ferret several times but
have never figured out how to do it.  Any help is appreciated.

Thanks as always,

--Brent

--
Brent A. McDaniel

Dept of Earth and Atmospheric Sciences
Georgia Institute of Technology
Atlanta, Ga.  USA

--
Ansley Manke  Pacific Marine Environmental Laboratory  Seattle WA  (206)526-6246
 


[Thread Prev][Thread Next][Index]

Dept of Commerce / NOAA / OAR / PMEL / TMAP

Contact Us | Privacy Policy | Disclaimer | Accessibility Statement