Expressions

A GrADS expression consists of operators, operands, and parentheses. Parentheses are used to control the order of operation -- this is especially important when using the logical operators.

Operators are:

Logical Operators (introduced in Version 2.1.1.b0 for GRIDDED data only):

Operands are:

variable specifications, functions, and constants.

Usage Notes

Operations between two variables are done on equivalent grid points in each grid. Missing data values in either grid give a result of a missing data value at that grid point. Dividing by zero gives a result of a missing data value at that grid point.

Operations cannot be done between grids that have different scaling in their varying dimensions -- i.e., grids that have different rules for converting the varying dimensions from grid space to world coordinate space. This can only be encountered when you are attempting operations between grids from different files that have different scaling rules.

If one grid has more varying dimensions than the other, the grid with fewer varying dimensions is 'expanded' and the operation is performed.

Expression evaluation in GrADS is recursive, so that multiple expressions may be nested together.

(GrADS version 2.0.a7+) Variable specifications can include a dimension expression to set time as an offset from the variable's initial time.

(GrADS version 2.1.1.b0+) The result of a logical operation is boolean -- an answer to a yes/no question. If the expression is true the result is 1, if the expression is false the answer is -1 (instead of zero). This is slightly different from the usual convention, but it is implemented this way in GrADS to make it easier to use logical operators with the maskout() function. An if() function has also been implemented to use logical operators in expressions of the form if-then-else. Note: the logical operators have not yet been implemented for station data.

Examples

Examples Using Logical Operators