GRDMATH
Section: Misc. Reference Manual Pages (l)
Updated: DATE
Index
Return to Main Contents
NAME
grdmath - Reverse Polish calculator for grd files
SYNOPSIS
grdmath [ -Ixinc[m|c][/yinc[m|c]] -Rwest/east/south/north -V]
operand [ operand ] OPERATOR [ operand ] OPERATOR ... = outgrdfile
DESCRIPTION
grdmath will perform operations like add, subtract, multiply, and divide on one or more grd files or constants using
Reverse Polish syntax (e.g., Hewlett-Packard calculator-style). Arbitrarily complicated expressions may therefore
be evaluated; the final result is written to an output grd file. When two grd files are
on the stack, each element in file A is modified by the corresponding element in file B.
However, some operators only require one operand (see below). If no grdfiles are used in the
expression then options -R, -I must be set (and optionally -F).
- operand
-
If operand can be opened as a file it will be read as a grd file. If not a file, it is interpreted
as a numerical constant or a special symbol (see below).
- outgrdfile is a 2-D grd file that will hold the final result.
-
- OPERATORS
-
Choose among the following operators:
Operator n_args Returns
#include "grdmath_man.i"
- SYMBOLS
-
The following symbols have special meaning:
PI 3.1415926...
E 2.7182818...
X Grid with x-coordinates
Y Grid with y-coordinates
OPTIONS
- -I
-
xinc [and optionally yinc] is the grid spacing. Append m to indicate minutes, c to indicate seconds.
#include "explain_-R.txt"
- -F
-
Select pixel registration. [Default is grid registration].
#include "explain_-V.txt"
EXAMPLES
To multiply test.grd by 10.0, try
grdmath test.grd 10.0 MUL = test10.grd
To take log10 of the average of 2 files, use
grdmath file1.grd file2.grd ADD 0.5 MUL LOG10 = file3.grd
Given the file ages.grd, which holds seafloor ages in m.y., use the relation
depth(in m) = 2500 + 350 * sqrt (age) to estimate normal seafloor depths:
grdmath ages.grd SQRT 350 MUL 2500 ADD = depths.grd
To find the angle a (in degrees) of the largest principal stress from the stress tensor given by the
three files s_xx.grd s_yy.grd, and s_xy.grd from the relation tan (2*a) = 2 * s_xy / (s_xx - s_yy), try
grdmath 2 s_xy.grd MUL s_xx.grd s_yy.grd SUB DIV ATAN2 2 DIV = direction.grd
BUGS
Files that has the same name as some operators, e.g., ADD, SIGN, =, etc. cannot be read
and must not be present in the current directory. Piping of files are not allowed.
The stack limit is hard-wired to 50.
SEE ALSO
gmt, grd2xyz, grdedit, grdinfo, xyz2grd
#include "refs.i"
Index
- NAME
-
- SYNOPSIS
-
- DESCRIPTION
-
- OPTIONS
-
- EXAMPLES
-
- BUGS
-
- SEE ALSO
-
This document was created by
man2html,
using the manual pages.
Time: 07:11:10 GMT, January 07, 2025