grdmath man page

grdmath — Reverse Polish Notation (RPN) calculator for grids (element by element)


grdmath [ -Amin_area[/min_level/max_level][+ag|i|s |S][+r|l][ppercent] ] [ -Dresolution[+] ] [ -Iincrement ] [ -M ] [ -N ] [ -Rregion ] [ -V[level] ] [ -bibinary ] [ -dinodata ] [ -fflags ] [ -hheaders ] [ -iflags ] [ -nflags ] [ -r ] [ -x[[-]n] ] operand [ operand ] OPERATOR [ operand ] OPERATOR ... = outgrdfile

Note: No space is allowed between the option flag and the associated arguments.


grdmath will perform operations like add, subtract, multiply, and divide on one or more grid files or constants using Reverse Polish Notation (RPN) syntax (e.g., Hewlett-Packard calculator-style). Arbitrarily complicated expressions may therefore be evaluated; the final result is written to an output grid file. Grid operations are element-by-element, not matrix manipulations. Some operators only require one operand (see below). If no grid files are used in the expression then options -R, -I must be set (and optionally -r). The expression = outgrdfile can occur as many times as the depth of the stack allows in order to save intermediate results. Complicated or frequently occurring expressions may be coded as a macro for future use or stored and recalled via named memory locations.

Required Arguments

If operand can be opened as a file it will be read as a grid file. If not a file, it is interpreted as a numerical constant or a special symbol (see below).
The name of a 2-D grid file that will hold the final result. (See Grid File Formats below).

Optional Arguments

Features with an area smaller than min_area in km^2 or of hierarchical level that is lower than min_level or higher than max_level will not be plotted [Default is 0/0/4 (all features)]. Level 2 (lakes) contains regular lakes and wide river bodies which we normally include as lakes; append +r to just get river-lakes or +l to just get regular lakes. By default (+ai) we select the ice shelf boundary as the coastline for Antarctica; append +ag to instead select the ice grounding line as coastline. For expert users who wish to print their own Antarctica coastline and islands via psxy you can use +as to skip all GSHHG features below 60S or +aS to instead skip all features north of 60S. Finally, append +ppercent to exclude polygons whose percentage area of the corresponding full-resolution feature is less than percent. See GSHHG INFORMATION below for more details. (-A is only relevant to the LDISTG operator)
Selects the resolution of the data set to use with the operator LDISTG ((f)ull, (h)igh, (i)ntermediate, (l)ow, and (c)rude). The resolution drops off by 80% between data sets [Default is l]. Append + to automatically select a lower resolution should the one requested not be available [abort if not found].
x_inc [and optionally y_inc] is the grid spacing. Optionally, append a suffix modifier. Geographical (degrees) coordinates: Append m to indicate arc minutes or s to indicate arc seconds. If one of the units e, f, k, M, n or u is appended instead, the increment is assumed to be given in meter, foot, km, Mile, nautical mile or US survey foot, respectively, and will be converted to the equivalent degrees longitude at the middle latitude of the region (the conversion depends on PROJ_ELLIPSOID). If y_inc is given but set to 0 it will be reset equal to x_inc; otherwise it will be converted to degrees latitude. All coordinates: If = is appended then the corresponding max x (east) or y (north) may be slightly adjusted to fit exactly the given increment [by default the increment may be adjusted slightly to fit the given domain]. Finally, instead of giving an increment you may specify the number of nodes desired by appending + to the supplied integer argument; the increment is then recalculated from the number of nodes and the domain. The resulting increment value depends on whether you have selected a gridline-registered or pixel-registered grid; see App-file-formats for details. Note: if -Rgrdfile is used then the grid spacing has already been initialized; use -I to override the values.
By default any derivatives calculated are in z_units/ x(or y)_units. However, the user may choose this option to convert dx,dy in degrees of longitude,latitude into meters using a flat Earth approximation, so that gradients are in z_units/meter.
Turn off strict domain match checking when multiple grids are manipulated [Default will insist that each grid domain is within 1e-4 * grid_spacing of the domain of the first grid listed].
-R[unit]xmin/xmax/ymin/ymax[r] (more ...)
Specify the region of interest.
-V[level] (more ...)
Select verbosity level [c].
-bi[ncols][t] (more ...)
Select native binary input. The binary input option only applies to the data files needed by operators LDIST, PDIST, and INSIDE.
-dinodata (more ...)
Replace input columns that equal nodata with NaN.
-f[i|o]colinfo (more ...)
Specify data types of input and/or output columns.
-g[a]x|y|d|X|Y|D|[col]z[+|-]gap[u] (more ...)
Determine data gaps and line breaks.
-h[i|o][n][+c][+d][+rremark][+rtitle] (more ...)
Skip or produce header record(s).
-icols[l][sscale][ooffset][,...] (more ...)
Select input columns (0 is first column).
-n[b|c|l|n][+a][+bBC][+c][+tthreshold] (more ...)
Select interpolation mode for grids.
-r (more ...)
Set pixel node registration [gridline]. Only used with -R -I.
-x[[-]n] (more ...)
Limit number of cores used in multi-threaded algorithms (OpenMP required).
-^ or just -
Print a short message about the syntax of the command, then exits (NOTE: on Windows use just -).
-+ or just +
Print an extensive usage (help) message, including the explanation of any module-specific option (but not the GMT common options), then exits.
-? or no arguments
Print a complete usage (help) message, including the explanation of options, then exits.


Choose among the following 200 operators. "args" are the number of input and output arguments.

ABS1 1abs (A)
ACOS1 1acos (A)
ACOSH1 1acosh (A)
ACOT1 1acot (A)
ACSC1 1acsc (A)
ADD2 1A + B
AND2 1B if A == NaN, else A
ARC2 1Return arc(A,B) on [0 pi]
AREA0 1Area of each gridnode cell (in km^2 if geographic)
ASEC1 1asec (A)
ASIN1 1asin (A)
ASINH1 1asinh (A)
ATAN1 1atan (A)
ATAN22 1atan2 (A, B)
ATANH1 1atanh (A)
BCDF3 1Binomial cumulative distribution function for p = A, n = B, and x = C
BPDF3 1Binomial probability density function for p = A, n = B, and x = C
BEI1 1bei (A)
BER1 1ber (A)
BITAND2 1A & B (bitwise AND operator)
BITLEFT2 1A << B (bitwise left-shift operator)
BITNOT1 1~A (bitwise NOT operator, i.e., return two's complement)
BITOR2 1A | B (bitwise OR operator)
BITRIGHT2 1A >> B (bitwise right-shift operator)
BITTEST2 11 if bit B of A is set, else 0 (bitwise TEST operator)
BITXOR2 1A ^ B (bitwise XOR operator)
CAZ2 1Cartesian azimuth from grid nodes to stack x,y (i.e., A, B)
CBAZ2 1Cartesian back-azimuth from grid nodes to stack x,y (i.e., A, B)
CDIST2 1Cartesian distance between grid nodes and stack x,y (i.e., A, B)
CDIST22 1As CDIST but only to nodes that are != 0
CEIL1 1ceil (A) (smallest integer >= A)
CHICRIT2 1Chi-squared critical value for alpha = A and nu = B
CHICDF2 1Chi-squared cumulative distribution function for chi2 = A and nu = B
CHIPDF2 1Chi-squared probability density function for chi2 = A and nu = B
COMB2 1Combinations n_C_r, with n = A and r = B
CORRCOEFF2 1Correlation coefficient r(A, B)
COS1 1cos (A) (A in radians)
COSD1 1cos (A) (A in degrees)
COSH1 1cosh (A)
COT1 1cot (A) (A in radians)
COTD1 1cot (A) (A in degrees)
CSC1 1csc (A) (A in radians)
CSCD1 1csc (A) (A in degrees)
CURV1 1Curvature of A (Laplacian)
D2DX21 1d^2(A)/dx^2 2nd derivative
D2DY21 1d^2(A)/dy^2 2nd derivative
D2DXY1 1d^2(A)/dxdy 2nd derivative
D2R1 1Converts Degrees to Radians
DDX1 1d(A)/dx Central 1st derivative
DDY1 1d(A)/dy Central 1st derivative
DEG2KM1 1Converts Spherical Degrees to Kilometers
DENAN2 1Replace NaNs in A with values from B
DILOG1 1dilog (A)
DIV2 1A / B
DUP1 2Places duplicate of A on the stack
ECDF2 1Exponential cumulative distribution function for x = A and lambda = B
ECRIT2 1Exponential distribution critical value for alpha = A and lambda = B
EPDF2 1Exponential probability density function for x = A and lambda = B
ERF1 1Error function erf (A)
ERFC1 1Complementary Error function erfc (A)
EQ2 11 if A == B, else 0
ERFINV1 1Inverse error function of A
EXCH2 2Exchanges A and B on the stack
EXP1 1exp (A)
FACT1 1A! (A factorial)
EXTREMA1 1Local Extrema: +2/-2 is max/min, +1/-1 is saddle with max/min in x, 0 elsewhere
FCDF3 1F cumulative distribution function for F = A, nu1 = B, and nu2 = C
FCRIT3 1F distribution critical value for alpha = A, nu1 = B, and nu2 = C
FLIPLR1 1Reverse order of values in each row
FLIPUD1 1Reverse order of values in each column
FLOOR1 1floor (A) (greatest integer <= A)
FMOD2 1A % B (remainder after truncated division)
FPDF3 1F probability density function for F = A, nu1 = B, and nu2 = C
GE2 11 if A >= B, else 0
GT2 11 if A > B, else 0
HYPOT2 1hypot (A, B) = sqrt (A*A + B*B)
I01 1Modified Bessel function of A (1st kind, order 0)
I11 1Modified Bessel function of A (1st kind, order 1)
IFELSE3 1B if A != 0, else C
IN2 1Modified Bessel function of A (1st kind, order B)
INRANGE3 11 if B <= A <= C, else 0
INSIDE1 11 when inside or on polygon(s) in A, else 0
INV1 11 / A
ISFINITE1 11 if A is finite, else 0
ISNAN1 11 if A == NaN, else 0
J01 1Bessel function of A (1st kind, order 0)
J11 1Bessel function of A (1st kind, order 1)
JN2 1Bessel function of A (1st kind, order B)
K01 1Modified Kelvin function of A (2nd kind, order 0)
K11 1Modified Bessel function of A (2nd kind, order 1)
KEI1 1kei (A)
KER1 1ker (A)
KM2DEG1 1Converts Kilometers to Spherical Degrees
KN2 1Modified Bessel function of A (2nd kind, order B)
KURT1 1Kurtosis of A
LCDF1 1Laplace cumulative distribution function for z = A
LCRIT1 1Laplace distribution critical value for alpha = A
LDIST1 1Compute minimum distance (in km if -fg) from lines in multi-segment ASCII file A
LDIST22 1As LDIST, from lines in ASCII file B but only to nodes where A != 0
LDISTG0 1As LDIST, but operates on the GSHHG dataset (see -A, -D for options).
LE2 11 if A <= B, else 0
LOG1 1log (A) (natural log)
LOG101 1log10 (A) (base 10)
LOG1P1 1log (1+A) (accurate for small A)
LOG21 1log2 (A) (base 2)
LMSSCL1 1LMS scale estimate (LMS STD) of A
LMSSCLW2 1Weighted LMS scale estimate (LMS STD) of A for weights in B
LOWER1 1The lowest (minimum) value of A
LPDF1 1Laplace probability density function for z = A
LRAND2 1Laplace random noise with mean A and std. deviation B
LT2 11 if A < B, else 0
MAD1 1Median Absolute Deviation (L1 STD) of A
MAX2 1Maximum of A and B
MEAN1 1Mean value of A
MEANW2 1Weighted mean value of A for weights in B
MEDIAN1 1Median value of A
MEDIANW2 1Weighted median value of A for weights in B
MIN2 1Minimum of A and B
MOD2 1A mod B (remainder after floored division)
MODE1 1Mode value (Least Median of Squares) of A
MODEW2 1Weighted mode value (Least Median of Squares) of A for weights in B
MUL2 1A * B
NAN2 1NaN if A == B, else A
NEG1 1-A
NEQ2 11 if A != B, else 0
NORM1 1Normalize (A) so max(A)-min(A) = 1
NOT1 1NaN if A == NaN, 1 if A == 0, else 0
NRAND2 1Normal, random values with mean A and std. deviation B
OR2 1NaN if B == NaN, else A
PCDF2 1Poisson cumulative distribution function for x = A and lambda = B
PDIST1 1Compute minimum distance (in km if -fg) from points in ASCII file A
PDIST22 1As PDIST, from points in ASCII file B but only to nodes where A != 0
PERM2 1Permutations n_P_r, with n = A and r = B
PLM3 1Associated Legendre polynomial P(A) degree B order C
PLMg3 1Normalized associated Legendre polynomial P(A) degree B order C (geophysical convention)
POINT1 2Compute mean x and y from ASCII file A and place them on the stack
POP1 0Delete top element from the stack
POW2 1A ^ B
PPDF2 1Poisson distribution P(x,lambda), with x = A and lambda = B
PQUANT2 1The B'th Quantile (0-100%) of A
PQUANTW3 1The C'th weighted quantile (0-100%) of A for weights in B
PSI1 1Psi (or Digamma) of A
PV3 1Legendre function Pv(A) of degree v = real(B) + imag(C)
QV3 1Legendre function Qv(A) of degree v = real(B) + imag(C)
R22 1R2 = A^2 + B^2
R2D1 1Convert Radians to Degrees
RAND2 1Uniform random values between A and B
RCDF1 1Rayleigh cumulative distribution function for z = A
RCRIT1 1Rayleigh distribution critical value for alpha = A
RINT1 1rint (A) (round to integral value nearest to A)
RMS1 1Root-mean-square of A
RPDF1 1Rayleigh probability density function for z = A
ROLL2 0Cyclicly shifts the top A stack items by an amount B
ROTX2 1Rotate A by the (constant) shift B in x-direction
ROTY2 1Rotate A by the (constant) shift B in y-direction
SDIST2 1Spherical (Great circle|geodesic) distance (in km) between nodes and stack (A, B)
SDIST22 1As SDIST but only to nodes that are != 0
SAZ2 1Spherical azimuth from grid nodes to stack lon, lat (i.e., A, B)
SBAZ2 1Spherical back-azimuth from grid nodes to stack lon, lat (i.e., A, B)
SEC1 1sec (A) (A in radians)
SECD1 1sec (A) (A in degrees)
SIGN1 1sign (+1 or -1) of A
SIN1 1sin (A) (A in radians)
SINC1 1sinc (A) (sin (pi*A)/(pi*A))
SIND1 1sin (A) (A in degrees)
SINH1 1sinh (A)
SKEW1 1Skewness of A
SQR1 1A^2
SQRT1 1sqrt (A)
STD1 1Standard deviation of A
STDW2 1Weighted standard deviation of A for weights in B
STEP1 1Heaviside step function: H(A)
STEPX1 1Heaviside step function in x: H(x-A)
STEPY1 1Heaviside step function in y: H(y-A)
SUB2 1A - B
SUM1 1Sum of all values in A
TAN1 1tan (A) (A in radians)
TAND1 1tan (A) (A in degrees)
TANH1 1tanh (A)
TAPER2 1Unit weights cosine-tapered to zero within A and B of x and y grid margins
TCDF2 1Student's t cumulative distribution function for t = A, and nu = B
TCRIT2 1Student's t distribution critical value for alpha = A and nu = B
TN2 1Chebyshev polynomial Tn(-1<t<+1,n), with t = A, and n = B
TPDF2 1Student's t probability density function for t = A, and nu = B
UPPER1 1The highest (maximum) value of A
VAR1 1Variance of A
VARW2 1Weighted variance of A for weights in B
WCDF3 1Weibull cumulative distribution function for x = A, scale = B, and shape = C
WCRIT3 1Weibull distribution critical value for alpha = A, scale = B, and shape = C
WPDF3 1Weibull density distribution P(x,scale,shape), with x = A, scale = B, and shape = C
WRAP1 1wrap A in radians onto [-pi,pi]
XOR2 10 if A == NaN and B == NaN, NaN if B == NaN, else A
Y01 1Bessel function of A (2nd kind, order 0)
Y11 1Bessel function of A (2nd kind, order 1)
YLM2 2Re and Im orthonormalized spherical harmonics degree A order B
YLMg2 2Cos and Sin normalized spherical harmonics degree A order B (geophysical convention)
YN2 1Bessel function of A (2nd kind, order B)
ZCDF1 1Normal cumulative distribution function for z = A
ZPDF1 1Normal probability density function for z = A
ZCRIT1 1Normal distribution critical value for alpha = A


The following symbols have special meaning:

EPS_F1.192092896e-07 (single precision epsilon
XMINMinimum x value
XMAXMaximum x value
XRANGERange of x values
XINCx increment
NXThe number of x nodes
YMINMinimum y value
YMAXMaximum y value
YRANGERange of y values
YINCy increment
NYThe number of y nodes
XGrid with x-coordinates
YGrid with y-coordinates
XNORMGrid with normalized [-1 to +1] x-coordinates
YNORMGrid with normalized [-1 to +1] y-coordinates
XCOLGrid with column numbers 0, 1, ..., NX-1
YROWGrid with row numbers 0, 1, ..., NY-1

Notes on Operators

For Cartesian grids the operators MEAN, MEDIAN, MODE, LMSSCL, MAD, OQUANT, STD, and VAR return the expected value from the given matrix. However, for geographic grids we perform a spherically weighted calculation where each node value is weighted by the geographic area represented by that node.
The operator SDIST calculates spherical distances in km between the (lon, lat) point on the stack and all node positions in the grid. The grid domain and the (lon, lat) point are expected to be in degrees. Similarly, the SAZ and SBAZ operators calculate spherical azimuth and back-azimuths in degrees, respectively. The operators LDIST and PDIST compute spherical distances in km if -fg is set or implied, else they return Cartesian distances. Note: If the current PROJ_ELLIPSOID is ellipsoidal then geodesics are used in calculations of distances, which can be slow. You can trade speed with accuracy by changing the algorithm used to compute the geodesic (see PROJ_GEODESIC).

The operator LDISTG is a version of LDIST that operates on the GSHHG data. Instead of reading an ASCII file, it directly accesses one of the GSHHG data sets as determined by the -D and -A options.
The operator POINT reads a ASCII table, computes the mean x and mean y values and places these on the stack. If geographic data then we use the mean 3-D vector to determine the mean location.
The operator PLM calculates the associated Legendre polynomial of degree L and order M (0 <= M <= L), and its argument is the sine of the latitude. PLM is not normalized and includes the Condon-Shortley phase (-1)^M. PLMg is normalized in the way that is most commonly used in geophysics. The C-S phase can be added by using -M as argument. PLM will overflow at higher degrees, whereas PLMg is stable until ultra high degrees (at least 3000).
The operators YLM and YLMg calculate normalized spherical harmonics for degree L and order M (0 <= M <= L) for all positions in the grid, which is assumed to be in degrees. YLM and YLMg return two grids, the real (cosine) and imaginary (sine) component of the complex spherical harmonic. Use the POP operator (and EXCH) to get rid of one of them, or save both by giving two consecutive = calls.

The orthonormalized complex harmonics YLM are most commonly used in physics and seismology. The square of YLM integrates to 1 over a sphere. In geophysics, YLMg is normalized to produce unit power when averaging the cosine and sine terms (separately!) over a sphere (i.e., their squares each integrate to 4 pi). The Condon-Shortley phase (-1)^M is not included in YLM or YLMg, but it can be added by using -M as argument.
All the derivatives are based on central finite differences, with natural boundary conditions, and are Cartesian derivatives.
Files that have the same names as some operators, e.g., ADD, SIGN, =, etc. should be identified by prepending the current directory (i.e., ./LOG).
Piping of files is not allowed.
The stack depth limit is hard-wired to 100.
All functions expecting a positive radius (e.g., LOG, KEI, etc.) are passed the absolute value of their argument. (9) The bitwise operators (BITAND, BITLEFT, BITNOT, BITOR, BITRIGHT, BITTEST, and BITXOR) convert a grid's single precision values to unsigned 32-bit ints to perform the bitwise operations. Consequently, the largest whole integer value that can be stored in a float grid is 2^24 or 16,777,216. Any higher result will be masked to fit in the lower 24 bits. Thus, bit operations are effectively limited to 24 bit. All bitwise operators return NaN if given NaN arguments or bit-settings <= 0.
When OpenMP support is compiled in, a few operators will take advantage of the ability to spread the load onto several cores. At present, the list of such operators is: LDIST.

Grid Values Precision

Regardless of the precision of the input data, GMT programs that create grid files will internally hold the grids in 4-byte floating point arrays. This is done to conserve memory and furthermore most if not all real data can be stored using 4-byte floating point values. Data with higher precision (i.e., double precision values) will lose that precision once GMT operates on the grid or writes out new grids. To limit loss of precision when processing data you should always consider normalizing the data prior to processing.

Grid File Formats

By default GMT writes out grid as single precision floats in a COARDS-complaint netCDF file format. However, GMT is able to produce grid files in many other commonly used grid file formats and also facilitates so called "packing" of grids, writing out floating point data as 1- or 2-byte integers. (more ...)

Geographical and Time Coordinates

When the output grid type is netCDF, the coordinates will be labeled "longitude", "latitude", or "time" based on the attributes of the input data or grid (if any) or on the -f or -R options. For example, both -f0x -f1t and -R90w/90e/0t/3t will result in a longitude/time grid. When the x, y, or z coordinate is time, it will be stored in the grid as relative time since epoch as specified by TIME_UNIT and TIME_EPOCH in the gmt.conf file or on the command line. In addition, the unit attribute of the time variable will indicate both this unit and epoch.

Store, Recall and Clear

You may store intermediate calculations to a named variable that you may recall and place on the stack at a later time. This is useful if you need access to a computed quantity many times in your expression as it will shorten the overall expression and improve readability. To save a result you use the special operator STO@label, where label is the name you choose to give the quantity. To recall the stored result to the stack at a later time, use [RCL]@label, i.e., RCL is optional. To clear memory you may use CLR@label. Note that STO and CLR leave the stack unchanged.

Gshhs Information

The coastline database is GSHHG (formerly GSHHS) which is compiled from three sources: World Vector Shorelines (WVS), CIA World Data Bank II (WDBII), and Atlas of the Cryosphere (AC, for Antarctica only). Apart from Antarctica, all level-1 polygons (ocean-land boundary) are derived from the more accurate WVS while all higher level polygons (level 2-4, representing land/lake, lake/island-in-lake, and island-in-lake/lake-in-island-in-lake boundaries) are taken from WDBII. The Antarctica coastlines come in two flavors: ice-front or grounding line, selectable via the -A option. Much processing has taken place to convert WVS, WDBII, and AC data into usable form for GMT: assembling closed polygons from line segments, checking for duplicates, and correcting for crossings between polygons. The area of each polygon has been determined so that the user may choose not to draw features smaller than a minimum area (see -A); one may also limit the highest hierarchical level of polygons to be included (4 is the maximum). The 4 lower-resolution databases were derived from the full resolution database using the Douglas-Peucker line-simplification algorithm. The classification of rivers and borders follow that of the WDBII. See the GMT Cookbook and Technical Reference Appendix K for further details.


Users may save their favorite operator combinations as macros via the file grdmath.macros in their current or user directory. The file may contain any number of macros (one per record); comment lines starting with # are skipped. The format for the macros is name = arg1 arg2 ... arg2 : comment where name is how the macro will be used. When this operator appears on the command line we simply replace it with the listed argument list. No macro may call another macro. As an example, the following macro expects three arguments (radius x0 y0) and sets the modes that are inside the given circle to 1 and those outside to 0:

INCIRCLE = CDIST EXCH DIV 1 LE : usage: r x y INCIRCLE to return 1 inside circle

Note: Because geographic or time constants may be present in a macro, it is required that the optional comment flag (:) must be followed by a space.


To compute all distances to north pole:

gmt grdmath -Rg -I1 0 90 SDIST =

To take log10 of the average of 2 files, use

gmt grdmath ADD 0.5 MUL LOG10 =

Given the file, which holds seafloor ages in m.y., use the relation depth(in m) = 2500 + 350 * sqrt (age) to estimate normal seafloor depths:

gmt grdmath SQRT 350 MUL 2500 ADD =

To find the angle a (in degrees) of the largest principal stress from the stress tensor given by the three files, and from the relation tan (2*a) = 2 * s_xy / (s_xx - s_yy), use

gmt grdmath 2 MUL SUB DIV ATAN 2 DIV =

To calculate the fully normalized spherical harmonic of degree 8 and order 4 on a 1 by 1 degree world map, using the real amplitude 0.4 and the imaginary amplitude 1.1:

gmt grdmath -R0/360/-90/90 -I1 8 4 YLM 1.1 MUL EXCH 0.4 MUL ADD =

To extract the locations of local maxima that exceed 100 mGal in the file

gmt grdmath DUP EXTREMA 2 EQ MUL DUP 100 GT MUL 0 NAN =
gmt grd2xyz -s >

To demonstrate the use of named variables, consider this radial wave where we store and recall the normalized radial arguments in radians:

gmt grdmath -R0/10/0/10 -I0.25 5 5 CDIST 2 MUL PI MUL 5 DIV STO@r COS @r SIN MUL =


Abramowitz, M., and I. A. Stegun, 1964, Handbook of Mathematical Functions, Applied Mathematics Series, vol. 55, Dover, New York.

Holmes, S. A., and W. E. Featherstone, 2002, A unified approach to the Clenshaw summation and the recursive computation of very high degree and order normalised associated Legendre functions. Journal of Geodesy, 76, 279-299.

Press, W. H., S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery, 1992, Numerical Recipes, 2nd edition, Cambridge Univ., New York.

Spanier, J., and K. B. Oldman, 1987, An Atlas of Functions, Hemisphere Publishing Corp.

See Also

gmt, gmtmath, grd2xyz, grdedit, grdinfo, xyz2grd


October 20, 2016 5.3.1 GMT