Grid Algebra Expressions

Operation or Function

Syntax

Examples

Comments

Addition

+

A + B

Adds two arguments. The arguments can be a set of values in a specified grid or aggregate or a constant.

Subtraction

-

A - B

Subtracts two arguments. The arguments can be a set of values in a specified grid or aggregate or a constant.

Multiplication

*

A * B

Multiplies two arguments. The arguments can be a set of values in a specified grid or aggregate or a constant.

Division

/

A / B

Divides two arguments. The arguments can be a set of values in a specified grid or aggregate or a constant.

Negation (unary minus)

-

-A

Makes the specified argument negative. The argument can be a set of values in a specified grid or aggregate or a constant.

Absolute value

ABS(arg)

ABS(2 * B - A)

Result is the absolute value of the argument. The argument can be a set of values in a specified grid or aggregate or a constant.

Exponentiation

arg^power

A^2

Result is the argument (arg) taken to the specified power. The argument can be a set of values in a specified grid or aggregate or a constant.

Square Root

SQRT(arg)

SQRT(A)

Results in the square root of the argument. The argument can be a set of values in a specified grid or aggregate or a constant.

Minimum of a list of values

MIN(arg1, arg2, ...)

MIN(A, B, C)

Create an output grid or aggregate which contains the minimum of the values in the specified grids or aggregatest.

Maximum of a list of values

MAX(arg1, arg2, ...)

MAX(A, B, C)

Create an output grid or aggregate which contains the maximum of the values in the specified grids or aggregates.

Mean of a list of values

MEAN(arg1, arg2, ...)

MEAN(A, B, C)

Create an output grid or aggregate which contains the mean of the values in the specified grids or aggregates.

Median of a list of values

MEDIAN(arg1, arg2, ...)

MEDIAN(A, B, C)

Create an output grid or aggregate which contains the mean of the values in the specified grids or aggregates.

Standard deviation of a list of values

STD(arg1, arg2, ...)

STD(A, B, C)

Create an output grid or aggregate which contains the standard deviation of the values in the specified grids or aggregates.

NO_DATA test

IS_NO_DATA(arg)

IS_NO_DATA(A)

For each value in the grid or aggregate, returns true if the value is NO_DATA otherwise it returns false.

Size of grid or aggregate

SIZE(arg)

SIZE(A)

The number of points or stations in the grid or aggregate including NO_DATA points or stations.

Size of grid or aggregate excluding NO_DATA values

DSIZE(arg)

DSIZE(A)

The number of points or stations in the grid or aggregate excluding NO_DATA points or stations.

Size of grid or aggregate including only NO_DATA values

NDSIZE(arg)

NDSIZE(A)

The number of NO_DATA points or stations in the grid or aggregate.

Station elevation

ELEV(aggr)

ELEV(A)

Returns an aggregate of the elevations of the stations within the specified aggregate.

Merge aggregates

MERGE(arg1, arg2, ...)

MERGE(A,B,C)

Create an output aggregate which consists of the union of the specified aggregates (arg1, arg2, ...).

Equality

==

IF (A == B, A * B, A - B)

Indicates equality.

Not equal

!=

IF (A != B, 2 * A, B - A)

Indicates inequality.

Greater than

>

IF (A > B, B, A)

Indicates the logical expression "greater than".

Less than

<

IF (A < B, A + B, B / 4) 

Indicates the logical expression "less than".

Greater than or equal to

>=

IF (A >= B, A / B, 0.25 * A)

Indicates the logical expression "greater than or equal to".

Less than or equal to

<=

IF (A <= B, B / A, 2.718 * B)

Indicates the logical expression "less than or equal to".

Logical AND

&
and

IF (A < B & A > 32, A - 32, A)
IF (A < B and A > 32, A - 32, A)

Indicates the logical expression "and".

Logical OR

|
or

IF (A > B | A > 32, A - 32, B)
IF (A > B or A > 32, A - 32, B)

Indicates the logical expression "or".

Sub-expressions

()

(A + B + C) / (D - E)

The () indicates a sub-expression.

If

IF (logical_test, value_if_true, value_if_false) 

IF (A > 32, 32, A)
IF (A > 87, 87, IF (A < 32, 32, A))

If the argument logical_test is true set to value_if_true otherwise set to value_if_false.

Map - conditional style

MAP(cond1, if_cond1_true, cond2, if_cond2_true, ... condX,  if_condX_true, set_value, default_result)

If condition is true proceed to next condition. If all conditions are true set to set_value otherwise if any are false set to default_result.

Base 10 log

LOG(arg)

LOG(ABS(A))

Returns the base 10 log of the argument (arg).

Natural log

LN(arg)

LN(ABS(B - A))

Returns the natural log of the argument (arg).

Inverse Natural Log

EXP(arg)

EXP(A)

Computes the inverse natural log of the argument (arg).

Random Number

RAND(seed)

27 * RAND(127865)

Create a grid of random numbers. The grid size is determined by the size of the grid component(s). RAND(seed) returns a floating point number between 0 and 1.

Relative Humidity to DewPoint

RHtoDP(rh_grid, temp_grid)

RHtoDP(RelativeHumidity, Temperature)

Convert a grid of relative humidity to a grid of dewpoints using relative humidity and temperature grids.

DewPoint to Relative Humidity 

DPtoRH(dp_grid, temp_grid)

DPtoRH(DewPoint, Temperature)

Convert a grid of dewpoints to a grid of relative humidity using dewpoint and temperature grids.

Set to Fahrenheit

fahrenheit(arg)
fahr(arg)

RHtoDP(rh_grid, fahr(A + B))

Set the unit type of the argument (arg) to fahrenheit for use by the RHtoDP function.

Set to Celsius

celsius(arg)
cels(arg)

RHtoDP(rh_grid, cels(A + B))

Set the unit type of the argument (arg) to celsius for use by the RHtoDP function.

Set to kelvin

kelvin(arg)
kelv(arg)

RHtoDP(rh_grid, kelv(A + B))

Set the unit type of the argument (arg) to kelvin for use by the RHtoDP function.

Set to rankine

rankine(arg)
rank(arg)

RHtoDP(rh_grid, rank(A + B))

Set the unit type of the argument (arg) to rankine for use by the RHtoDP function.

Del

DEL(arg)

DEL(A)

Gives the gradient of a 2 dimensional function.

Laplacian

LAP(arg)

LAP(A)

Gives the smoothness of a 2 dimensional function by measuring the difference between the value at a point and it's neighbors.

Assignment

=

T = A + B;
T^2 + 5 * T + 6

Used to define temporary variables. Assignments to temporary variables must be followed by a semicolon.

Sine

SIN(arg)

SIN(A - B)

Returns the sine of the argument's result.

Cosine

COS(arg)

COS(A / B)

Returns the cosine of the argument's result.

Tangent

TAN(arg)

TAN(2 * A / (4 * B))

Returns the tangent of the argument's result.

Arctangent

ATAN2(Y, X)

ATAN2(2, -1) = 116.565 degrees

Computes arc tangent of Y / X.

Arcsine

ASIN(arg)

ASIN(B / A)

Returns the arcsine of the argument's result.

Arccosine

ACOS(arg)

ACOS(1 - A)

Returns the arccosine of the argument's result.

Arctangent

ATAN(arg)

ATAN(2B - A)

Returns the arctangent of the argument's result.

comment line

#

# This comment line ignored

 

Precision

PRECISION(A,num_digits)
PREC(A,num_digits)

PREC(79.4772, 2) = 79.48

Round A as specified:
    * if num_digits > 0 round to num_digits decimal places
    * if num_digits = 0, round to nearest integer
    * if num_digits < 0, round to the left of the decimal point
"A" can be a single value or the result of an argument.

Mod

MOD(A, divisor)

MOD(47, 10) = 7

Returns a remainder after dividing A by the divisor. "A" can be a single value or the result of an argument.

Dump to file

DUMP("file.txt","A", ["L"])

dump("testprec.txt","A");
dump("testprec.txt","R2","L");
dump("testprec.txt","R1","L");

Dump value of variable to file indicated. The function can take "L" as a third argument to indicate the contents should be appended to the end of the line of an existing file (L=line append).

Gen

GEN(start_value,end_value,step_size [,hold_count])

GEN(0,100,0.1)

GEN(0,100,0.1,4)

Generates a series of values in order to test equations (example: wind chill equation). Used in conjunction with the DUMP() function to check results.

Floor integer

FLOOR(A)

FLOOR(1.9) = 1
FLOOR(-1.9) = -2

Returns the largest integer <= to A, where A can be a single value or the result of an argument.

Ceil integer

CEIL(A)

CEIL(1.9) = 2
CEIL(-1.9) = -1

Returns the smallest integer >= to A, where A can be a single value or the result of an argument.

Integer

INT(A)

INT(1.9) = 1
INT(-1.9) = -2

Round A down to the nearest integer, where A can be a single value or the result of an argument.

Truncate

TRUNC(A)

TRUNC(1.9) = 1
TRUNC(-1.9) = -1

Truncate A, where A can be a single value or the result of an argument.

Latitude

LATITUDE(A)
LAT(A)

Returns the latitude of every point in the specified grid (A).

Longitude

LONGITUDE(A)
LONG(A)

Returns the longitude of every point in the specified grid (A).

Year

YEAR()

YEAR()=2003 (current year is 2003)

Returns the current year as a four digit number.

Month

MONTH()

MONTH() = 8 (current month is August)

Returns the current month as a number.

Day

DAY()

DAY()=5 (current day of the month is 5)

Returns the day of the month as a number.

Hour

HOUR()

HOUR() = 10 (current hour is 10 o'clock)

Returns the current hour in local time.

Minute

MINUTE()

MINUTE() = 30 (current time is half past the hour)

Returns the current minute for the local time.

Width

WIDTH()

Returns the width of the specified grid (or default/current grid if no grid specified) in number of columns.

Height

HEIGHT()

Returns the height of the specified grid (or default/current grid if no grid specified) in number of rows.

All

ALL(expressions)

IF(ALL(A > 50), A + 10, A)

Returns 1 if all the values in the specified expression are true.

Any

ANY(expressions)

IF(ANY(A > 50), A + 10, A)

Returns 1 if any of the values in the specified expression are true.



Main Menu