[Thread Prev][Thread Next][Index]
Re: [ExternalEmail] [ferret_users] accessing statistics symbols in if/then statements
Hi Jenny,
To get the length of and axis use the embedded expression option
RETURN=LSIZE (or whatever axis you want)
let pnum = `p,RETURN=LSIZE`
http://ferret.pmel.noaa.gov/Ferret/documentation/users-guide/variables-xpressions/EMBEDDED-XPRESSIONS#_VPID_184
To do housekeeping just make a small script with all the commands you
want, say, clean.jnl and put it somewhere in the path defined by the
environment variable FER_GO
(If you aren't the admin of the ferret package make you own common area
for regularly used go scripts and add that directory to the FER_GO
variable in your .cshrc or whatever after running the ferret_paths
script.)
Russ
On Tue, 2012-09-25 at 16:29 +1000, Jennifer.Abernethy@xxxxxxxx wrote:
> Hi,
>
> I'm running into a problem accessing the symbol $STAT_NGOOD when I use the statistics command in an if/then statement. It all works great when not used in an if/then statement.
> Can anyone help me make sense of this?
>
>
> This works great:
>
> let p = psl[d=1,t="16-jan-2000":"16-jan-2010"]
> statistics p
> let pnum = ($stat_ngood)
>
> yes? go try_statstest.jnl
> let p = psl[d=1,t="16-jan-2000":"16-jan-2010"]
> statistics p
>
> PSL[D=spsl_soi,T="16-jan-2000":"16-jan-2010"]
> LONGITUDE: 0E
> LATITUDE: 0
> Z: N/A
> TIME: 15-JAN-2000 12:00 to 14-JAN-2010 00:00
> DATA SET: N/A
>
> Total # of data points: 120 (1*1*1*120)
> # flagged as bad data: 0
> Minimum value: -2.2286
> Maximum value: 3.9071
> Mean value: -0.13333 (unweighted average)
> Standard deviation: 1.0054
> let pnum = ($stat_ngood)
> !-> DEFINE VARIABLE pnum = 120
>
>
>
> But then I put it in a if/then statement. Stat_ngood exists, but I can't save it:
>
> let p = psl[d=1,t="16-jan-2000":"16-jan-2010"]
> if `6 LT 10` then (statistics p; show sym stat*; let pnum = ($stat_ngood)) endif
>
> yes? go try_statstest.jnl
> let p = psl[d=1,t="16-jan-2000":"16-jan-2010"]
> if `6 LT 10` then (statistics p ; let pnum = ($stat_ngood)) endif
> !-> if 1 then (statistics p ; let pnum = ) endif
>
> PSL[D=spsl_soi,T="16-jan-2000":"16-jan-2010"]
> LONGITUDE: 0E
> LATITUDE: 0
> Z: N/A
> TIME: 15-JAN-2000 12:00 to 14-JAN-2010 00:00
> DATA SET: N/A
>
> Total # of data points: 120 (1*1*1*120)
> # flagged as bad data: 0
> Minimum value: -2.2286
> Maximum value: 3.9071
> Mean value: -0.13333 (unweighted average)
> Standard deviation: 1.0054
> STAT_MIN = "-2.2286"
> STAT_MAX = "3.9071"
> STAT_MEAN = "-0.13333"
> STAT_STD = "1.0054"
> STAT_NGOOD = "120"
> STAT_NBAD = "0"
> **ERROR: command syntax: PNUM = ???
> DEFINE VARIABLE pnum =
> Command file, command group, or REPEAT execution aborted
>
>
> but it's fine again if I move the statistics command out of the if/then stmt:
>
> !works
> let p = psl[d=1,t="16-jan-2000":"16-jan-2010"]
> statistics p
> if `6 LT 10` then (let pnum = ($stat_ngood)) endif
>
>
>
> I need to have the statistics run in an if/then statement, because my real if test is if the year actually exists in the file (i.e. if it doesn't, can't run stats on it to begin with).
>
> However, the reason I'm using `statistics` is that I need to get the length of p (on the L axis) - any other ways to do this?
>
> Is there also any command that clears all data and symbols, axes, etc in ferret? I see cancel data,symbols etc but it looks like you have to do a bunch of cancel commands, clearing each thing one by one - anything that does it all in one command?
>
> thanks,
> jenny
>
>
[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce /
NOAA /
OAR /
PMEL /
Ferret
Privacy Policy | Disclaimer | Accessibility Statement