[Thread Prev][Thread Next][Index]

Re: [ferret_users] Problem IF statement



Hi Paul,
No, it's not new. it's always been the case.
http://www.pmel.noaa.gov/maillists/tmap/ferret_users/fu_2003/msg00447.html

And of course you can always set any value as the missing-value
use coads_climatology
let/bad=9999 sst_limited = if sst lt 10 then SST
shade/L=2 sst_limited
I'll add a quick note about that in the Users Guide.

Ansley

On 9/29/2010 10:41 AM, Paul Young wrote:
Hi Ansley,

Is the "else bad value" new? I always thought that  "else 0" was implied if else was left out....?


On Sep 29, 2010, at 11:41 AM, Ansley Manke wrote:

Hi-
Continuing what Paul suggests, to when using IF to mask a variable, there is no need for the ELSE in definitions like this


use coads_climatology
let sst_limited = if sst lt 10 then SST  ! There is an implied "else bad-value"
shade/L=2 sst_limited



On 9/29/2010 9:41 AM, Paul Young wrote:
Hi,

Not sure if this will help, but, if you're just looking for where SSTs are a certain value, you can just use an 'IF' statement without the need for looping.

e.g. Create a variable that contains the SST if SST < 10C, and -999 if not:

use coads_climatology
let sst_limited = if sst lt 10 then SST else (-999)              !Just keep SSTs that are less than 10C

shade/lev=(-2,10,1) sst_limited[l=1] 
shade/over/palette=black/lev=(-999) sst_limited[l=1]     !Black out unwanted SSTs

(No idea why you'd do this particular example!)

...You can get more sophisticated with masking etc (e.g. using SSTs to mask some other variable) - see the user guide for more on this.

Hope this helps,

Paul




On Sep 29, 2010, at 9:41 AM, K Wheel wrote:

Hello,
 
I have a problem with my ferret-script. It includes a REPEAT and IF statement, although I think the fault is in the IF part. 
 
The following code has been set up:
 
REPEAT/i=1:362 \
( REPEAT/j=1:292 \
  ( IF SST[X=i, Y=j, L=1] EQ 0 \
      THEN \
        LET SST[X=i, Y=j, L=1] = 1/0 \
    ENDIF \
  ) \
)
 
Which gives the following output in:
!-> REPEAT: I=1
!-> REPEAT: J=1
 **ERROR: command syntax: SST[X=i,Y=j,L=1]
IF SST[X=i,Y=j,L=1] EQ 0     THEN   LET SST[X=i,Y=j,L=1] = 1/0   ENDIF
Command file, command group, or REPEAT execurtion aborted.
 
Does anyone have an idea why the IF does not recognise SST[X=1,Y=1,L=1] ?
 
Thank you!
 



[Thread Prev][Thread Next][Index]

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

Privacy Policy | Disclaimer | Accessibility Statement