ReadWrite/
ncdf_getmask.pro
get the land/sea mask array from a NetCDF file
ncdf_getmask
Read NetCDF file
result = ncdf_getmask(fileid, ADDSCL_BEFORE=scalar: 0 or 1, MASKNAME=string, USEASMASK=scalar string, MISSING_VALUE=scalar, INVMASK=scalar: 0 or 1, TESTOP=scalar string, for example 'GT 0.5', _EXTRA=_EXTRA)
Return value
the land/sea mask 2D or 3D array or -1 in case of error or mask absence
Parameters
fileid
in
required
type: salar string or long
if fileid is a scalar string then it is the name of the file (with
the full path) to be opened (in that case, the file will be opened
and closed within ncdf_getmask).
if fileid is a scalar then it is the id of the file return by a call
to ncdf_open outside of ncdf_getmask (in that case, the file will
NOT be opened and closed within ncdf_getmask)
Keywords
ADDSCL_BEFORE
type: scalar: 0 or 1
default: 0
put 1 to apply add_offset ad scale factor on data before looking for
missing values when using USEASMASK keyword
MASKNAME
type: string
A string giving the name of the variable in the file
that contains the land/sea mask
USEASMASK
type: scalar string
A string giving the name of the variable in the file
that will be used to build the land/sea mask. In this case the
mask is based on the first record (if record dimension
exists). The mask is build according to operator defined by TESTOP
keyword (default NE) and the testing values defined as
1) the second word of TESTOP if existing
2) MISSING_VALUE keyword
3) attribute missing_value or _fillvalue of the variable USEASMASK
4) !Values.f_nan (can be used only with NE and EQ operators)
MISSING_VALUE
type: scalar
To define (or redefine if the attribute is already existing) the
missing values used with USEASMASK keyword. Note that this value is
not used if TESTOP keyword is given and contains 2 words.
INVMASK
type: scalar: 0 or 1
default: 0
Inverse the land/sea mask (that should have 0/1 values for land/sea): mask = 1-mask
TESTOP
type: scalar string, for example 'GT 0.5'
default: 'NE'
a string describing the type of test that will be done to define the
mask. The test is performed on the variable specified by USEASMASK
keyword.
TESTOP can contain 1 or 2 words. The first word is the operator
definition: "EQ" "NE" "GE" "GT" "LE" "LT" (default is NE). The
second word define the testing value. If TESTOP contains only 1
word, then the test value is denifed by
1) MISSING_VALUE keyword
2) attribute missing_value or _fillvalue of the variable USEASMASK
3) !Values.f_nan (can be used only with NE and EQ operators)
_EXTRA
to be able to call ncdf_getmask with _extra keyword
Examples
IDL> mask = ncdf_getmask('HadISST1_1m_187001_200702_sst_reg1m.nc',useasmask = 'sst', missing_value = -1.00000e+30)
IDL> mask = ncdf_getmask('meshmaskORCA2.nc', maskname = 'tmask')
IDL> mask = ncdf_getmask('t106.nc', useasmask = 'SLM', testop = 'le 0.5')
Version history
Version
$Id: ncdf_getmask.pro 361 2008-07-07 14:23:42Z smasson $
History
August 2007: Sebastien Masson (smasson@lodyc.jussieu.fr)
Produced by IDLdoc 2.0.