National Oceanic and
Atmospheric Administration
United States Department of Commerce

Setting a missing value

Setting a missing value

Question:

How can I set a missing value over land ?

Explanation:

Consider the following problem: You have a global data set with values overocean and over land but currently you're only interested in quantities over theocean. Replacing all land values with a correct missing value is necessary ifyou want to use ferret transformations such as @ave.

Solution:

! Use a topography dataset (for example etopo120) to define
! a ocean mask. This mask must be first interpolated onto the
! correct grid i.e.

! topography data set
set data etopo120

! file containing my_var
set data my_file

! set an explicit region for example
define region/x=100W:30E/y=10S:90N NA
set region/@NA

! define an ocean mask
LET ocean = if rose[d=etopo120,gxy=my_var] le 0 then 1

! Note: in this IF construct the "ELSE" clause is omitted. This tells Ferret
! that those values which would satisfy the ELSE condition are undefined
! (i.e. are missing in ocean).

! define a new variable that has a missing values over land
define variable/title="var_ocean" var_ocean = ocean * my_var

! make a two dimensional plot of the values over the ocean only
shade var_ocean

! since there is now a correct missing value over land you can make a plot
! showing the averaged over the ocean only. i.e.

plot var_ocean[x=@ave]

Contributed by Christof Appenzeller of Universitat Bern
Last modified: Nov 6,1996