National Oceanic and
Atmospheric Administration
United States Department of Commerce

Contouring to Outline a Mask

Contouring to Outline a Mask


I want to contour a mask consistingof 0's and 1's but it doesn't match the grid cells.


The command "CONTOUR/OVER mask" (fig a) uses a standard iso-line algorithmto draw contour lines, which leads to a smooth path between grid points.In this case we want to see the outline of the grid cells that make upthe mask (fig b).


A straightforward contour of a mask grid of 0's and 1's does not producea nice representation of the mask because the contour lines do not "squareup" at the boundaries between grid cells.


You will need the script mask_outline.jnl which is part of the Ferret distribution. It regrids the mask to a new grid whichwhen contoured produces squared off boundaries.


 yes? use etopo60
yes? set region/x=90w:20e/y=15s:55n
yes? shade rose

yes? let ocean_mask = IF rose LT 0 THEN 1 ELSE 0
yes? GO mask_outline ocean_mask
yes? ovmo ! think "overlay mask outline"

! If the final line segments at the north and east of the plot are missing

yes? cancel region
yes? ovmo

! Use "yes? SHOW ALIAS ovmo" to see or modify the contour command

The technique used is to define a modified mask grid as follows: ('+' toindicate the corners of the boundaries between grid cells) Say the originalgrid of 0's and 1's looks like this:

 0 1 1

+ + + +

0 0 1

We define a new mask which contains clusters of 4 points a small distance,EPSILON, from one another immediately surrounding the cell corners. (theoriginal values are in parentheses):

 (0) (1) (1)

0 0 1 1 1 1

+ + + +

0 0 0 0 1 1

(0) (0) (1)

When the value 0.5 is contoured on this mask, the contour lines will passwithin EPSILON of the true corners.