const (expr, value, <-u|-a>)
This is a powerful function that allows the user to change the missing values of a variable, set all the non-missing values of a variable to a constant, or set all possible values of a variable (both valid and missing) to a constant.
expra valid grads expression
valuea constant, either an integer or floating point value
-uall missing data are set to
value; non-missing data are unchanged
-aall data are set to
value, both missing and non-missing
Default behaviour is to set all non-missing data equal to
value; missing data are unchanged
constfunction operates on both gridded and station data.
valueis given as an integer, it will still be treated as as floating point.
constfunction assigns a new value to missing data, so that missing data may participate in operations:
const(z, 0, -u)
constfunction is used with the set gxout linefill graphics output option to define a straight horizontal line:
set lon -90set lat -90 90set gxout linefillset lev 500d const(t, -20);t-273
In this example,
constis used to calculate a daily timeseries of the fraction of the globe convered by precipitation greater than
set lon 0 360set lat -90 90set t 1 lastdefine ones = const(const(maskout(p,p-10),1),0,-u)set x 1set y 1display tloop(aave(ones,lon=0,lon=360,lat=0,lat=360))
Notes: The defined variable
1wherever the precip value is greater than
0whever the precip value is less than
10. This is done via nested functions; first
maskoutsets all values less than
10to missing, then
constsets all non-missing values to
constis used with the
-uflag to set all the missing data values to
aavefunction calculates an area weighted average. Since we are averaging zeros and ones, the result is the fraction of the area where there are ones. See the
tloopfunction for a description of how to perform time series of areal averages.