National Oceanic and
Atmospheric Administration
United States Department of Commerce

Setting a new missing-value flag

Setting a new missing-value flag

Question:

How can I set a new missing flag for my data?

Solution:

The missing data flag can be changed to any new value with these commands:

yes? ! the data is 0 at locations that should be missing

yes? LET new_var = IF old_var EQ 0 THEN 9999
yes? SET VAR/BAD=9999 new_var

yes? ! It's a good idea not to lose the units or title from the original variable:

yes? SET VAR/units="`old_var,RETURN=units`" new_var
yes? SET VAR/title="`old_var,RETURN=title`" new_var

Or, say you have data with the default missing-data flag -1.e+34, and you want to write data to be used in another program where it would be convenient for the missing-data flag to be 1000:

yes? USE coads_climatology
yes? LET/units="`sst,RETURN=units`"/title="`sst,RETURN=title`"/BAD=1000 \
sst_out = IF sst THEN sst ELSE 1000
yes? LIST/CLOBBER/FORMAT=tab/FILE=sst.dat/x=330:360/y=10:30/L=1 sst_out

Now, the above is not always convenient if we want to keep the original variable name.   Often when using Ferret to "fix" variables, the original name is important. 

Use SET VAR/NAME=  to rename the original variable, and then define the "fixed" variable using its original name.

yes? USE my_data.nc
yes? SHOW DATA
currently SET data sets:
1> ./my_data.nc (default)
name title I J K L
SST SEA SURFACE TEMPERATURE 1:180 1:90 ... 1:3

yes? SET VAR/NAME=s_input sst
yes? LET sst = IF sst NE 0 THEN sst

And, we can copy all the attributes of the input variable to the new variable:

yes? SET ATT/LIKE= s_input sst
yes? SHOW ATTRIBUTE/ALL  u    ! check what you have done