1GRDMATH(1) GMT GRDMATH(1)
2
3
4
6 grdmath - Reverse Polish Notation (RPN) calculator for grids (element
7 by element)
8
10 grdmath [ -Amin_area[/min_level/max_level][+ag|i|s |S][+r|l][ppercent]
11 ] [ -Dresolution[+] ] [ -Iincrement ] [ -M ] [ -N ] [ -Rregion ] [
12 -V[level] ] [ -bibinary ] [ -dinodata ] [ -fflags ] [ -hheaders ] [
13 -iflags ] [ -nflags ] [ -r ] [ -x[[-]n] ] operand [ operand ] OPERATOR
14 [ operand ] OPERATOR ... = outgrdfile
15
16 Note: No space is allowed between the option flag and the associated
17 arguments.
18
20 grdmath will perform operations like add, subtract, multiply, and
21 divide on one or more grid files or constants using Reverse Polish
22 Notation (RPN) syntax (e.g., Hewlett-Packard calculator-style). Arbi‐
23 trarily complicated expressions may therefore be evaluated; the final
24 result is written to an output grid file. Grid operations are ele‐
25 ment-by-element, not matrix manipulations. Some operators only require
26 one operand (see below). If no grid files are used in the expression
27 then options -R, -I must be set (and optionally -r). The expression =
28 outgrdfile can occur as many times as the depth of the stack allows in
29 order to save intermediate results. Complicated or frequently occur‐
30 ring expressions may be coded as a macro for future use or stored and
31 recalled via named memory locations.
32
34 operand
35 If operand can be opened as a file it will be read as a grid
36 file. If not a file, it is interpreted as a numerical constant
37 or a special symbol (see below).
38
39 outgrdfile
40 The name of a 2-D grid file that will hold the final result.
41 (See GRID FILE FORMATS below).
42
44 -Amin_area[/min_level/max_level][+ag|i|s|S][+r|l][+ppercent]
45 Features with an area smaller than min_area in km^2 or of hier‐
46 archical level that is lower than min_level or higher than
47 max_level will not be plotted [Default is 0/0/4 (all features)].
48 Level 2 (lakes) contains regular lakes and wide river bodies
49 which we normally include as lakes; append +r to just get
50 river-lakes or +l to just get regular lakes. By default (+ai)
51 we select the ice shelf boundary as the coastline for Antarc‐
52 tica; append +ag to instead select the ice grounding line as
53 coastline. For expert users who wish to print their own Antarc‐
54 tica coastline and islands via psxy you can use +as to skip all
55 GSHHG features below 60S or +aS to instead skip all features
56 north of 60S. Finally, append +ppercent to exclude polygons
57 whose percentage area of the corresponding full-resolution fea‐
58 ture is less than percent. See GSHHG INFORMATION below for more
59 details. (-A is only relevant to the LDISTG operator)
60
61 -Dresolution[+]
62 Selects the resolution of the data set to use with the operator
63 LDISTG ((f)ull, (h)igh, (i)ntermediate, (l)ow, and (c)rude). The
64 resolution drops off by 80% between data sets [Default is l].
65 Append + to automatically select a lower resolution should the
66 one requested not be available [abort if not found].
67
68 -Ixinc[unit][+e|n][/yinc[unit][+e|n]]
69 x_inc [and optionally y_inc] is the grid spacing. Optionally,
70 append a suffix modifier. Geographical (degrees) coordinates:
71 Append m to indicate arc minutes or s to indicate arc seconds.
72 If one of the units e, f, k, M, n or u is appended instead, the
73 increment is assumed to be given in meter, foot, km, Mile, nau‐
74 tical mile or US survey foot, respectively, and will be con‐
75 verted to the equivalent degrees longitude at the middle lati‐
76 tude of the region (the conversion depends on PROJ_ELLIPSOID).
77 If y_inc is given but set to 0 it will be reset equal to x_inc;
78 otherwise it will be converted to degrees latitude. All coordi‐
79 nates: If +e is appended then the corresponding max x (east) or
80 y (north) may be slightly adjusted to fit exactly the given
81 increment [by default the increment may be adjusted slightly to
82 fit the given domain]. Finally, instead of giving an increment
83 you may specify the number of nodes desired by appending +n to
84 the supplied integer argument; the increment is then recalcu‐
85 lated from the number of nodes and the domain. The resulting
86 increment value depends on whether you have selected a grid‐
87 line-registered or pixel-registered grid; see App-file-formats
88 for details. Note: if -Rgrdfile is used then the grid spacing
89 has already been initialized; use -I to override the values.
90
91 -M By default any derivatives calculated are in z_units/ x(or
92 y)_units. However, the user may choose this option to convert
93 dx,dy in degrees of longitude,latitude into meters using a flat
94 Earth approximation, so that gradients are in z_units/meter.
95
96 -N Turn off strict domain match checking when multiple grids are
97 manipulated [Default will insist that each grid domain is within
98 1e-4 * grid_spacing of the domain of the first grid listed].
99
100 -Rxmin/xmax/ymin/ymax[+r][+uunit] (more ...)
101 Specify the region of interest.
102
103 -V[level] (more ...)
104 Select verbosity level [c].
105
106 -bi[ncols][t] (more ...)
107 Select native binary input. The binary input option only applies
108 to the data files needed by operators LDIST, PDIST, and INSIDE.
109
110 -dinodata (more ...)
111 Replace input columns that equal nodata with NaN.
112
113 -f[i|o]colinfo (more ...)
114 Specify data types of input and/or output columns.
115
116 -g[a]x|y|d|X|Y|D|[col]z[+|-]gap[u] (more ...)
117 Determine data gaps and line breaks.
118
119 -h[i|o][n][+c][+d][+rremark][+rtitle] (more ...)
120 Skip or produce header record(s).
121
122 -icols[+l][+sscale][+ooffset][,...] (more ...)
123 Select input columns and transformations (0 is first column).
124
125 -n[b|c|l|n][+a][+bBC][+c][+tthreshold] (more ...)
126 Select interpolation mode for grids.
127
128 -r (more ...)
129 Set pixel node registration [gridline]. Only used with -R -I.
130
131 -x[[-]n] (more ...)
132 Limit number of cores used in multi-threaded algorithms (OpenMP
133 required).
134
135 -^ or just -
136 Print a short message about the syntax of the command, then
137 exits (NOTE: on Windows just use -).
138
139 -+ or just +
140 Print an extensive usage (help) message, including the explana‐
141 tion of any module-specific option (but not the GMT common
142 options), then exits.
143
144 -? or no arguments
145 Print a complete usage (help) message, including the explanation
146 of all options, then exits.
147
149 Choose among the following 209 operators. "args" are the number of
150 input and output arguments.
151
152 ┌──────────┬──────┬─────────────────────┐
153 │Operator │ args │ Returns │
154 ├──────────┼──────┼─────────────────────┤
155 │ABS │ 1 1 │ abs (A) │
156 ├──────────┼──────┼─────────────────────┤
157 │ACOS │ 1 1 │ acos (A) │
158 ├──────────┼──────┼─────────────────────┤
159 │ACOSH │ 1 1 │ acosh (A) │
160 ├──────────┼──────┼─────────────────────┤
161 │ACOT │ 1 1 │ acot (A) │
162 ├──────────┼──────┼─────────────────────┤
163 │ACSC │ 1 1 │ acsc (A) │
164 ├──────────┼──────┼─────────────────────┤
165 │ADD │ 2 1 │ A + B │
166 ├──────────┼──────┼─────────────────────┤
167 │AND │ 2 1 │ B if A == NaN, else │
168 │ │ │ A │
169 ├──────────┼──────┼─────────────────────┤
170 │ARC │ 2 1 │ Return arc(A,B) on │
171 │ │ │ [0 pi] │
172 ├──────────┼──────┼─────────────────────┤
173 │AREA │ 0 1 │ Area of each │
174 │ │ │ gridnode cell (in │
175 │ │ │ km^2 if geographic) │
176 ├──────────┼──────┼─────────────────────┤
177 │ASEC │ 1 1 │ asec (A) │
178 ├──────────┼──────┼─────────────────────┤
179 │ASIN │ 1 1 │ asin (A) │
180 ├──────────┼──────┼─────────────────────┤
181 │ASINH │ 1 1 │ asinh (A) │
182 ├──────────┼──────┼─────────────────────┤
183 │ATAN │ 1 1 │ atan (A) │
184 ├──────────┼──────┼─────────────────────┤
185 │ATAN2 │ 2 1 │ atan2 (A, B) │
186 ├──────────┼──────┼─────────────────────┤
187 │ATANH │ 1 1 │ atanh (A) │
188 ├──────────┼──────┼─────────────────────┤
189 │BCDF │ 3 1 │ Binomial cumulative │
190 │ │ │ distribution func‐ │
191 │ │ │ tion for p = A, n = │
192 │ │ │ B, and x = C │
193 ├──────────┼──────┼─────────────────────┤
194 │BPDF │ 3 1 │ Binomial probabil‐ │
195 │ │ │ ity density func‐ │
196 │ │ │ tion for p = A, n = │
197 │ │ │ B, and x = C │
198 └──────────┴──────┴─────────────────────┘
199
200
201 │BEI │ 1 1 │ bei (A) │
202 ├──────────┼──────┼─────────────────────┤
203 │BER │ 1 1 │ ber (A) │
204 ├──────────┼──────┼─────────────────────┤
205 │BITAND │ 2 1 │ A & B (bitwise AND │
206 │ │ │ operator) │
207 ├──────────┼──────┼─────────────────────┤
208 │BITLEFT │ 2 1 │ A << B (bitwise │
209 │ │ │ left-shift opera‐ │
210 │ │ │ tor) │
211 ├──────────┼──────┼─────────────────────┤
212 │BITNOT │ 1 1 │ ~A (bitwise NOT │
213 │ │ │ operator, i.e., │
214 │ │ │ return two's com‐ │
215 │ │ │ plement) │
216 ├──────────┼──────┼─────────────────────┤
217 │BITOR │ 2 1 │ A | B (bitwise OR │
218 │ │ │ operator) │
219 ├──────────┼──────┼─────────────────────┤
220 │BITRIGHT │ 2 1 │ A >> B (bitwise │
221 │ │ │ right-shift opera‐ │
222 │ │ │ tor) │
223 ├──────────┼──────┼─────────────────────┤
224 │BITTEST │ 2 1 │ 1 if bit B of A is │
225 │ │ │ set, else 0 (bit‐ │
226 │ │ │ wise TEST operator) │
227 ├──────────┼──────┼─────────────────────┤
228 │BITXOR │ 2 1 │ A ^ B (bitwise XOR │
229 │ │ │ operator) │
230 ├──────────┼──────┼─────────────────────┤
231 │CAZ │ 2 1 │ Cartesian azimuth │
232 │ │ │ from grid nodes to │
233 │ │ │ stack x,y (i.e., A, │
234 │ │ │ B) │
235 ├──────────┼──────┼─────────────────────┤
236 │CBAZ │ 2 1 │ Cartesian │
237 │ │ │ back-azimuth from │
238 │ │ │ grid nodes to stack │
239 │ │ │ x,y (i.e., A, B) │
240 ├──────────┼──────┼─────────────────────┤
241 │CDIST │ 2 1 │ Cartesian distance │
242 │ │ │ between grid nodes │
243 │ │ │ and stack x,y │
244 │ │ │ (i.e., A, B) │
245 ├──────────┼──────┼─────────────────────┤
246 │CDIST2 │ 2 1 │ As CDIST but only │
247 │ │ │ to nodes that are │
248 │ │ │ != 0 │
249 ├──────────┼──────┼─────────────────────┤
250 │CEIL │ 1 1 │ ceil (A) (smallest │
251 │ │ │ integer >= A) │
252 ├──────────┼──────┼─────────────────────┤
253 │CHICRIT │ 2 1 │ Chi-squared criti‐ │
254 │ │ │ cal value for alpha │
255 │ │ │ = A and nu = B │
256 ├──────────┼──────┼─────────────────────┤
257 │CHICDF │ 2 1 │ Chi-squared cumula‐ │
258 │ │ │ tive distribution │
259 │ │ │ function for chi2 = │
260 │ │ │ A and nu = B │
261 ├──────────┼──────┼─────────────────────┤
262 │CHIPDF │ 2 1 │ Chi-squared proba‐ │
263 │ │ │ bility density │
264 │ │ │ function for chi2 = │
265 │ │ │ A and nu = B │
266 └──────────┴──────┴─────────────────────┘
267
268 │COMB │ 2 1 │ Combinations n_C_r, │
269 │ │ │ with n = A and r = │
270 │ │ │ B │
271 ├──────────┼──────┼─────────────────────┤
272 │CORRCOEFF │ 2 1 │ Correlation coeffi‐ │
273 │ │ │ cient r(A, B) │
274 ├──────────┼──────┼─────────────────────┤
275 │COS │ 1 1 │ cos (A) (A in radi‐ │
276 │ │ │ ans) │
277 ├──────────┼──────┼─────────────────────┤
278 │COSD │ 1 1 │ cos (A) (A in │
279 │ │ │ degrees) │
280 ├──────────┼──────┼─────────────────────┤
281 │COSH │ 1 1 │ cosh (A) │
282 ├──────────┼──────┼─────────────────────┤
283 │COT │ 1 1 │ cot (A) (A in radi‐ │
284 │ │ │ ans) │
285 ├──────────┼──────┼─────────────────────┤
286 │COTD │ 1 1 │ cot (A) (A in │
287 │ │ │ degrees) │
288 ├──────────┼──────┼─────────────────────┤
289 │CSC │ 1 1 │ csc (A) (A in radi‐ │
290 │ │ │ ans) │
291 ├──────────┼──────┼─────────────────────┤
292 │CSCD │ 1 1 │ csc (A) (A in │
293 │ │ │ degrees) │
294 ├──────────┼──────┼─────────────────────┤
295 │CURV │ 1 1 │ Curvature of A │
296 │ │ │ (Laplacian) │
297 ├──────────┼──────┼─────────────────────┤
298 │D2DX2 │ 1 1 │ d^2(A)/dx^2 2nd de‐ │
299 │ │ │ rivative │
300 ├──────────┼──────┼─────────────────────┤
301 │D2DY2 │ 1 1 │ d^2(A)/dy^2 2nd de‐ │
302 │ │ │ rivative │
303 ├──────────┼──────┼─────────────────────┤
304 │D2DXY │ 1 1 │ d^2(A)/dxdy 2nd de‐ │
305 │ │ │ rivative │
306 ├──────────┼──────┼─────────────────────┤
307 │D2R │ 1 1 │ Converts Degrees to │
308 │ │ │ Radians │
309 ├──────────┼──────┼─────────────────────┤
310 │DDX │ 1 1 │ d(A)/dx Central 1st │
311 │ │ │ derivative │
312 ├──────────┼──────┼─────────────────────┤
313 │DDY │ 1 1 │ d(A)/dy Central 1st │
314 │ │ │ derivative │
315 ├──────────┼──────┼─────────────────────┤
316 │DEG2KM │ 1 1 │ Converts Spherical │
317 │ │ │ Degrees to Kilome‐ │
318 │ │ │ ters │
319 ├──────────┼──────┼─────────────────────┤
320 │DENAN │ 2 1 │ Replace NaNs in A │
321 │ │ │ with values from B │
322 ├──────────┼──────┼─────────────────────┤
323 │DILOG │ 1 1 │ dilog (A) │
324 ├──────────┼──────┼─────────────────────┤
325 │DIV │ 2 1 │ A / B │
326 ├──────────┼──────┼─────────────────────┤
327 │DUP │ 1 2 │ Places duplicate of │
328 │ │ │ A on the stack │
329 └──────────┴──────┴─────────────────────┘
330
331
332
333
334
335 │ECDF │ 2 1 │ Exponential cumula‐ │
336 │ │ │ tive distribution │
337 │ │ │ function for x = A │
338 │ │ │ and lambda = B │
339 ├──────────┼──────┼─────────────────────┤
340 │ECRIT │ 2 1 │ Exponential distri‐ │
341 │ │ │ bution critical │
342 │ │ │ value for alpha = A │
343 │ │ │ and lambda = B │
344 ├──────────┼──────┼─────────────────────┤
345 │EPDF │ 2 1 │ Exponential proba‐ │
346 │ │ │ bility density │
347 │ │ │ function for x = A │
348 │ │ │ and lambda = B │
349 ├──────────┼──────┼─────────────────────┤
350 │ERF │ 1 1 │ Error function erf │
351 │ │ │ (A) │
352 ├──────────┼──────┼─────────────────────┤
353 │ERFC │ 1 1 │ Complementary Error │
354 │ │ │ function erfc (A) │
355 ├──────────┼──────┼─────────────────────┤
356 │EQ │ 2 1 │ 1 if A == B, else 0 │
357 ├──────────┼──────┼─────────────────────┤
358 │ERFINV │ 1 1 │ Inverse error func‐ │
359 │ │ │ tion of A │
360 ├──────────┼──────┼─────────────────────┤
361 │EXCH │ 2 2 │ Exchanges A and B │
362 │ │ │ on the stack │
363 ├──────────┼──────┼─────────────────────┤
364 │EXP │ 1 1 │ exp (A) │
365 ├──────────┼──────┼─────────────────────┤
366 │FACT │ 1 1 │ A! (A factorial) │
367 ├──────────┼──────┼─────────────────────┤
368 │EXTREMA │ 1 1 │ Local Extrema: │
369 │ │ │ +2/-2 is max/min, │
370 │ │ │ +1/-1 is saddle │
371 │ │ │ with max/min in x, │
372 │ │ │ 0 elsewhere │
373 ├──────────┼──────┼─────────────────────┤
374 │FCDF │ 3 1 │ F cumulative dis‐ │
375 │ │ │ tribution function │
376 │ │ │ for F = A, nu1 = B, │
377 │ │ │ and nu2 = C │
378 ├──────────┼──────┼─────────────────────┤
379 │FCRIT │ 3 1 │ F distribution │
380 │ │ │ critical value for │
381 │ │ │ alpha = A, nu1 = B, │
382 │ │ │ and nu2 = C │
383 ├──────────┼──────┼─────────────────────┤
384 │FLIPLR │ 1 1 │ Reverse order of │
385 │ │ │ values in each row │
386 ├──────────┼──────┼─────────────────────┤
387 │FLIPUD │ 1 1 │ Reverse order of │
388 │ │ │ values in each col‐ │
389 │ │ │ umn │
390 ├──────────┼──────┼─────────────────────┤
391 │FLOOR │ 1 1 │ floor (A) (greatest │
392 │ │ │ integer <= A) │
393 ├──────────┼──────┼─────────────────────┤
394 │FMOD │ 2 1 │ A % B (remainder │
395 │ │ │ after truncated │
396 │ │ │ division) │
397 └──────────┴──────┴─────────────────────┘
398
399
400
401
402 │FPDF │ 3 1 │ F probability den‐ │
403 │ │ │ sity function for F │
404 │ │ │ = A, nu1 = B, and │
405 │ │ │ nu2 = C │
406 ├──────────┼──────┼─────────────────────┤
407 │GE │ 2 1 │ 1 if A >= B, else 0 │
408 ├──────────┼──────┼─────────────────────┤
409 │GT │ 2 1 │ 1 if A > B, else 0 │
410 ├──────────┼──────┼─────────────────────┤
411 │HYPOT │ 2 1 │ hypot (A, B) = sqrt │
412 │ │ │ (A*A + B*B) │
413 ├──────────┼──────┼─────────────────────┤
414 │I0 │ 1 1 │ Modified Bessel │
415 │ │ │ function of A (1st │
416 │ │ │ kind, order 0) │
417 ├──────────┼──────┼─────────────────────┤
418 │I1 │ 1 1 │ Modified Bessel │
419 │ │ │ function of A (1st │
420 │ │ │ kind, order 1) │
421 ├──────────┼──────┼─────────────────────┤
422 │IFELSE │ 3 1 │ B if A != 0, else C │
423 ├──────────┼──────┼─────────────────────┤
424 │IN │ 2 1 │ Modified Bessel │
425 │ │ │ function of A (1st │
426 │ │ │ kind, order B) │
427 ├──────────┼──────┼─────────────────────┤
428 │INRANGE │ 3 1 │ 1 if B <= A <= C, │
429 │ │ │ else 0 │
430 ├──────────┼──────┼─────────────────────┤
431 │INSIDE │ 1 1 │ 1 when inside or on │
432 │ │ │ polygon(s) in A, │
433 │ │ │ else 0 │
434 ├──────────┼──────┼─────────────────────┤
435 │INV │ 1 1 │ 1 / A │
436 ├──────────┼──────┼─────────────────────┤
437 │ISFINITE │ 1 1 │ 1 if A is finite, │
438 │ │ │ else 0 │
439 ├──────────┼──────┼─────────────────────┤
440 │ISNAN │ 1 1 │ 1 if A == NaN, else │
441 │ │ │ 0 │
442 ├──────────┼──────┼─────────────────────┤
443 │J0 │ 1 1 │ Bessel function of │
444 │ │ │ A (1st kind, order │
445 │ │ │ 0) │
446 ├──────────┼──────┼─────────────────────┤
447 │J1 │ 1 1 │ Bessel function of │
448 │ │ │ A (1st kind, order │
449 │ │ │ 1) │
450 ├──────────┼──────┼─────────────────────┤
451 │JN │ 2 1 │ Bessel function of │
452 │ │ │ A (1st kind, order │
453 │ │ │ B) │
454 ├──────────┼──────┼─────────────────────┤
455 │K0 │ 1 1 │ Modified Kelvin │
456 │ │ │ function of A (2nd │
457 │ │ │ kind, order 0) │
458 ├──────────┼──────┼─────────────────────┤
459 │K1 │ 1 1 │ Modified Bessel │
460 │ │ │ function of A (2nd │
461 │ │ │ kind, order 1) │
462 ├──────────┼──────┼─────────────────────┤
463 │KEI │ 1 1 │ kei (A) │
464 ├──────────┼──────┼─────────────────────┤
465 │KER │ 1 1 │ ker (A) │
466 └──────────┴──────┴─────────────────────┘
467
468
469 │KM2DEG │ 1 1 │ Converts Kilometers │
470 │ │ │ to Spherical │
471 │ │ │ Degrees │
472 ├──────────┼──────┼─────────────────────┤
473 │KN │ 2 1 │ Modified Bessel │
474 │ │ │ function of A (2nd │
475 │ │ │ kind, order B) │
476 ├──────────┼──────┼─────────────────────┤
477 │KURT │ 1 1 │ Kurtosis of A │
478 ├──────────┼──────┼─────────────────────┤
479 │LCDF │ 1 1 │ Laplace cumulative │
480 │ │ │ distribution func‐ │
481 │ │ │ tion for z = A │
482 ├──────────┼──────┼─────────────────────┤
483 │LCRIT │ 1 1 │ Laplace distribu‐ │
484 │ │ │ tion critical value │
485 │ │ │ for alpha = A │
486 ├──────────┼──────┼─────────────────────┤
487 │LDIST │ 1 1 │ Compute minimum │
488 │ │ │ distance (in km if │
489 │ │ │ -fg) from lines in │
490 │ │ │ multi-segment ASCII │
491 │ │ │ file A │
492 ├──────────┼──────┼─────────────────────┤
493 │LDIST2 │ 2 1 │ As LDIST, from │
494 │ │ │ lines in ASCII file │
495 │ │ │ B but only to nodes │
496 │ │ │ where A != 0 │
497 ├──────────┼──────┼─────────────────────┤
498 │LDISTG │ 0 1 │ As LDIST, but oper‐ │
499 │ │ │ ates on the GSHHG │
500 │ │ │ dataset (see -A, -D │
501 │ │ │ for options). │
502 ├──────────┼──────┼─────────────────────┤
503 │LE │ 2 1 │ 1 if A <= B, else 0 │
504 ├──────────┼──────┼─────────────────────┤
505 │LOG │ 1 1 │ log (A) (natural │
506 │ │ │ log) │
507 ├──────────┼──────┼─────────────────────┤
508 │LOG10 │ 1 1 │ log10 (A) (base 10) │
509 ├──────────┼──────┼─────────────────────┤
510 │LOG1P │ 1 1 │ log (1+A) (accurate │
511 │ │ │ for small A) │
512 ├──────────┼──────┼─────────────────────┤
513 │LOG2 │ 1 1 │ log2 (A) (base 2) │
514 ├──────────┼──────┼─────────────────────┤
515 │LMSSCL │ 1 1 │ LMS scale estimate │
516 │ │ │ (LMS STD) of A │
517 ├──────────┼──────┼─────────────────────┤
518 │LMSSCLW │ 2 1 │ Weighted LMS scale │
519 │ │ │ estimate (LMS STD) │
520 │ │ │ of A for weights in │
521 │ │ │ B │
522 ├──────────┼──────┼─────────────────────┤
523 │LOWER │ 1 1 │ The lowest (mini‐ │
524 │ │ │ mum) value of A │
525 ├──────────┼──────┼─────────────────────┤
526 │LPDF │ 1 1 │ Laplace probability │
527 │ │ │ density function │
528 │ │ │ for z = A │
529 ├──────────┼──────┼─────────────────────┤
530 │LRAND │ 2 1 │ Laplace random │
531 │ │ │ noise with mean A │
532 │ │ │ and std. deviation │
533 │ │ │ B │
534 └──────────┴──────┴─────────────────────┘
535
536 │LT │ 2 1 │ 1 if A < B, else 0 │
537 ├──────────┼──────┼─────────────────────┤
538 │MAD │ 1 1 │ Median Absolute │
539 │ │ │ Deviation (L1 STD) │
540 │ │ │ of A │
541 ├──────────┼──────┼─────────────────────┤
542 │MAX │ 2 1 │ Maximum of A and B │
543 ├──────────┼──────┼─────────────────────┤
544 │MEAN │ 1 1 │ Mean value of A │
545 ├──────────┼──────┼─────────────────────┤
546 │MEANW │ 2 1 │ Weighted mean value │
547 │ │ │ of A for weights in │
548 │ │ │ B │
549 ├──────────┼──────┼─────────────────────┤
550 │MEDIAN │ 1 1 │ Median value of A │
551 ├──────────┼──────┼─────────────────────┤
552 │MEDIANW │ 2 1 │ Weighted median │
553 │ │ │ value of A for │
554 │ │ │ weights in B │
555 ├──────────┼──────┼─────────────────────┤
556 │MIN │ 2 1 │ Minimum of A and B │
557 ├──────────┼──────┼─────────────────────┤
558 │MOD │ 2 1 │ A mod B (remainder │
559 │ │ │ after floored divi‐ │
560 │ │ │ sion) │
561 ├──────────┼──────┼─────────────────────┤
562 │MODE │ 1 1 │ Mode value (Least │
563 │ │ │ Median of Squares) │
564 │ │ │ of A │
565 ├──────────┼──────┼─────────────────────┤
566 │MODEW │ 2 1 │ Weighted mode value │
567 │ │ │ (Least Median of │
568 │ │ │ Squares) of A for │
569 │ │ │ weights in B │
570 ├──────────┼──────┼─────────────────────┤
571 │MUL │ 2 1 │ A * B │
572 ├──────────┼──────┼─────────────────────┤
573 │NAN │ 2 1 │ NaN if A == B, else │
574 │ │ │ A │
575 ├──────────┼──────┼─────────────────────┤
576 │NEG │ 1 1 │ -A │
577 ├──────────┼──────┼─────────────────────┤
578 │NEQ │ 2 1 │ 1 if A != B, else 0 │
579 ├──────────┼──────┼─────────────────────┤
580 │NORM │ 1 1 │ Normalize (A) so │
581 │ │ │ max(A)-min(A) = 1 │
582 ├──────────┼──────┼─────────────────────┤
583 │NOT │ 1 1 │ NaN if A == NaN, 1 │
584 │ │ │ if A == 0, else 0 │
585 ├──────────┼──────┼─────────────────────┤
586 │NRAND │ 2 1 │ Normal, random val‐ │
587 │ │ │ ues with mean A and │
588 │ │ │ std. deviation B │
589 ├──────────┼──────┼─────────────────────┤
590 │OR │ 2 1 │ NaN if B == NaN, │
591 │ │ │ else A │
592 ├──────────┼──────┼─────────────────────┤
593 │PCDF │ 2 1 │ Poisson cumulative │
594 │ │ │ distribution func‐ │
595 │ │ │ tion for x = A and │
596 │ │ │ lambda = B │
597 └──────────┴──────┴─────────────────────┘
598
599
600
601
602
603 │PDIST │ 1 1 │ Compute minimum │
604 │ │ │ distance (in km if │
605 │ │ │ -fg) from points in │
606 │ │ │ ASCII file A │
607 ├──────────┼──────┼─────────────────────┤
608 │PDIST2 │ 2 1 │ As PDIST, from │
609 │ │ │ points in ASCII │
610 │ │ │ file B but only to │
611 │ │ │ nodes where A != 0 │
612 ├──────────┼──────┼─────────────────────┤
613 │PERM │ 2 1 │ Permutations n_P_r, │
614 │ │ │ with n = A and r = │
615 │ │ │ B │
616 ├──────────┼──────┼─────────────────────┤
617 │PLM │ 3 1 │ Associated Legendre │
618 │ │ │ polynomial P(A) │
619 │ │ │ degree B order C │
620 ├──────────┼──────┼─────────────────────┤
621 │PLMg │ 3 1 │ Normalized associ‐ │
622 │ │ │ ated Legendre poly‐ │
623 │ │ │ nomial P(A) degree │
624 │ │ │ B order C (geophys‐ │
625 │ │ │ ical convention) │
626 ├──────────┼──────┼─────────────────────┤
627 │POINT │ 1 2 │ Compute mean x and │
628 │ │ │ y from ASCII file A │
629 │ │ │ and place them on │
630 │ │ │ the stack │
631 ├──────────┼──────┼─────────────────────┤
632 │POP │ 1 0 │ Delete top element │
633 │ │ │ from the stack │
634 ├──────────┼──────┼─────────────────────┤
635 │POW │ 2 1 │ A ^ B │
636 ├──────────┼──────┼─────────────────────┤
637 │PPDF │ 2 1 │ Poisson distribu‐ │
638 │ │ │ tion P(x,lambda), │
639 │ │ │ with x = A and │
640 │ │ │ lambda = B │
641 ├──────────┼──────┼─────────────────────┤
642 │PQUANT │ 2 1 │ The B'th Quantile │
643 │ │ │ (0-100%) of A │
644 ├──────────┼──────┼─────────────────────┤
645 │PQUANTW │ 3 1 │ The C'th weighted │
646 │ │ │ quantile (0-100%) │
647 │ │ │ of A for weights in │
648 │ │ │ B │
649 ├──────────┼──────┼─────────────────────┤
650 │PSI │ 1 1 │ Psi (or Digamma) of │
651 │ │ │ A │
652 ├──────────┼──────┼─────────────────────┤
653 │PV │ 3 1 │ Legendre function │
654 │ │ │ Pv(A) of degree v = │
655 │ │ │ real(B) + imag(C) │
656 ├──────────┼──────┼─────────────────────┤
657 │QV │ 3 1 │ Legendre function │
658 │ │ │ Qv(A) of degree v = │
659 │ │ │ real(B) + imag(C) │
660 ├──────────┼──────┼─────────────────────┤
661 │R2 │ 2 1 │ R2 = A^2 + B^2 │
662 ├──────────┼──────┼─────────────────────┤
663 │R2D │ 1 1 │ Convert Radians to │
664 │ │ │ Degrees │
665 ├──────────┼──────┼─────────────────────┤
666 │RAND │ 2 1 │ Uniform random val‐ │
667 │ │ │ ues between A and B │
668 └──────────┴──────┴─────────────────────┘
669
670 │RCDF │ 1 1 │ Rayleigh cumulative │
671 │ │ │ distribution func‐ │
672 │ │ │ tion for z = A │
673 ├──────────┼──────┼─────────────────────┤
674 │RCRIT │ 1 1 │ Rayleigh distribu‐ │
675 │ │ │ tion critical value │
676 │ │ │ for alpha = A │
677 ├──────────┼──────┼─────────────────────┤
678 │RINT │ 1 1 │ rint (A) (round to │
679 │ │ │ integral value │
680 │ │ │ nearest to A) │
681 ├──────────┼──────┼─────────────────────┤
682 │RMS │ 1 1 │ Root-mean-square of │
683 │ │ │ A │
684 ├──────────┼──────┼─────────────────────┤
685 │RMSW │ 1 1 │ Root-mean-square of │
686 │ │ │ A for weights in B │
687 ├──────────┼──────┼─────────────────────┤
688 │RPDF │ 1 1 │ Rayleigh probabil‐ │
689 │ │ │ ity density func‐ │
690 │ │ │ tion for z = A │
691 ├──────────┼──────┼─────────────────────┤
692 │ROLL │ 2 0 │ Cyclicly shifts the │
693 │ │ │ top A stack items │
694 │ │ │ by an amount B │
695 ├──────────┼──────┼─────────────────────┤
696 │ROTX │ 2 1 │ Rotate A by the │
697 │ │ │ (constant) shift B │
698 │ │ │ in x-direction │
699 ├──────────┼──────┼─────────────────────┤
700 │ROTY │ 2 1 │ Rotate A by the │
701 │ │ │ (constant) shift B │
702 │ │ │ in y-direction │
703 ├──────────┼──────┼─────────────────────┤
704 │SDIST │ 2 1 │ Spherical (Great │
705 │ │ │ circle|geodesic) │
706 │ │ │ distance (in km) │
707 │ │ │ between nodes and │
708 │ │ │ stack (A, B) │
709 ├──────────┼──────┼─────────────────────┤
710 │SDIST2 │ 2 1 │ As SDIST but only │
711 │ │ │ to nodes that are │
712 │ │ │ != 0 │
713 ├──────────┼──────┼─────────────────────┤
714 │SAZ │ 2 1 │ Spherical azimuth │
715 │ │ │ from grid nodes to │
716 │ │ │ stack lon, lat │
717 │ │ │ (i.e., A, B) │
718 ├──────────┼──────┼─────────────────────┤
719 │SBAZ │ 2 1 │ Spherical │
720 │ │ │ back-azimuth from │
721 │ │ │ grid nodes to stack │
722 │ │ │ lon, lat (i.e., A, │
723 │ │ │ B) │
724 ├──────────┼──────┼─────────────────────┤
725 │SEC │ 1 1 │ sec (A) (A in radi‐ │
726 │ │ │ ans) │
727 ├──────────┼──────┼─────────────────────┤
728 │SECD │ 1 1 │ sec (A) (A in │
729 │ │ │ degrees) │
730 ├──────────┼──────┼─────────────────────┤
731 │SIGN │ 1 1 │ sign (+1 or -1) of │
732 │ │ │ A │
733 └──────────┴──────┴─────────────────────┘
734
735
736
737 │SIN │ 1 1 │ sin (A) (A in radi‐ │
738 │ │ │ ans) │
739 ├──────────┼──────┼─────────────────────┤
740 │SINC │ 1 1 │ sinc (A) (sin │
741 │ │ │ (pi*A)/(pi*A)) │
742 ├──────────┼──────┼─────────────────────┤
743 │SIND │ 1 1 │ sin (A) (A in │
744 │ │ │ degrees) │
745 ├──────────┼──────┼─────────────────────┤
746 │SINH │ 1 1 │ sinh (A) │
747 ├──────────┼──────┼─────────────────────┤
748 │SKEW │ 1 1 │ Skewness of A │
749 ├──────────┼──────┼─────────────────────┤
750 │SQR │ 1 1 │ A^2 │
751 ├──────────┼──────┼─────────────────────┤
752 │SQRT │ 1 1 │ sqrt (A) │
753 ├──────────┼──────┼─────────────────────┤
754 │STD │ 1 1 │ Standard deviation │
755 │ │ │ of A │
756 ├──────────┼──────┼─────────────────────┤
757 │STDW │ 2 1 │ Weighted standard │
758 │ │ │ deviation of A for │
759 │ │ │ weights in B │
760 ├──────────┼──────┼─────────────────────┤
761 │STEP │ 1 1 │ Heaviside step │
762 │ │ │ function: H(A) │
763 ├──────────┼──────┼─────────────────────┤
764 │STEPX │ 1 1 │ Heaviside step │
765 │ │ │ function in x: │
766 │ │ │ H(x-A) │
767 ├──────────┼──────┼─────────────────────┤
768 │STEPY │ 1 1 │ Heaviside step │
769 │ │ │ function in y: │
770 │ │ │ H(y-A) │
771 ├──────────┼──────┼─────────────────────┤
772 │SUB │ 2 1 │ A - B │
773 ├──────────┼──────┼─────────────────────┤
774 │SUM │ 1 1 │ Sum of all values │
775 │ │ │ in A │
776 ├──────────┼──────┼─────────────────────┤
777 │TAN │ 1 1 │ tan (A) (A in radi‐ │
778 │ │ │ ans) │
779 ├──────────┼──────┼─────────────────────┤
780 │TAND │ 1 1 │ tan (A) (A in │
781 │ │ │ degrees) │
782 ├──────────┼──────┼─────────────────────┤
783 │TANH │ 1 1 │ tanh (A) │
784 ├──────────┼──────┼─────────────────────┤
785 │TAPER │ 2 1 │ Unit weights │
786 │ │ │ cosine-tapered to │
787 │ │ │ zero within A and B │
788 │ │ │ of x and y grid │
789 │ │ │ margins │
790 ├──────────┼──────┼─────────────────────┤
791 │TCDF │ 2 1 │ Student's t cumula‐ │
792 │ │ │ tive distribution │
793 │ │ │ function for t = A, │
794 │ │ │ and nu = B │
795 ├──────────┼──────┼─────────────────────┤
796 │TCRIT │ 2 1 │ Student's t distri‐ │
797 │ │ │ bution critical │
798 │ │ │ value for alpha = A │
799 │ │ │ and nu = B │
800 └──────────┴──────┴─────────────────────┘
801
802
803
804 │TN │ 2 1 │ Chebyshev polyno‐ │
805 │ │ │ mial Tn(-1<t<+1,n), │
806 │ │ │ with t = A, and n = │
807 │ │ │ B │
808 ├──────────┼──────┼─────────────────────┤
809 │TPDF │ 2 1 │ Student's t proba‐ │
810 │ │ │ bility density │
811 │ │ │ function for t = A, │
812 │ │ │ and nu = B │
813 ├──────────┼──────┼─────────────────────┤
814 │TRIM │ 3 1 │ Alpha-trim C to NaN │
815 │ │ │ if values fall in │
816 │ │ │ tails A and B (in │
817 │ │ │ percentage) │
818 ├──────────┼──────┼─────────────────────┤
819 │UPPER │ 1 1 │ The highest (maxi‐ │
820 │ │ │ mum) value of A │
821 ├──────────┼──────┼─────────────────────┤
822 │VAR │ 1 1 │ Variance of A │
823 ├──────────┼──────┼─────────────────────┤
824 │VARW │ 2 1 │ Weighted variance │
825 │ │ │ of A for weights in │
826 │ │ │ B │
827 ├──────────┼──────┼─────────────────────┤
828 │WCDF │ 3 1 │ Weibull cumulative │
829 │ │ │ distribution func‐ │
830 │ │ │ tion for x = A, │
831 │ │ │ scale = B, and │
832 │ │ │ shape = C │
833 ├──────────┼──────┼─────────────────────┤
834 │WCRIT │ 3 1 │ Weibull distribu‐ │
835 │ │ │ tion critical value │
836 │ │ │ for alpha = A, │
837 │ │ │ scale = B, and │
838 │ │ │ shape = C │
839 ├──────────┼──────┼─────────────────────┤
840 │WPDF │ 3 1 │ Weibull density │
841 │ │ │ distribution │
842 │ │ │ P(x,scale,shape), │
843 │ │ │ with x = A, scale = │
844 │ │ │ B, and shape = C │
845 ├──────────┼──────┼─────────────────────┤
846 │WRAP │ 1 1 │ wrap A in radians │
847 │ │ │ onto [-pi,pi] │
848 ├──────────┼──────┼─────────────────────┤
849 │XOR │ 2 1 │ 0 if A == NaN and B │
850 │ │ │ == NaN, NaN if B == │
851 │ │ │ NaN, else A │
852 ├──────────┼──────┼─────────────────────┤
853 │Y0 │ 1 1 │ Bessel function of │
854 │ │ │ A (2nd kind, order │
855 │ │ │ 0) │
856 ├──────────┼──────┼─────────────────────┤
857 │Y1 │ 1 1 │ Bessel function of │
858 │ │ │ A (2nd kind, order │
859 │ │ │ 1) │
860 ├──────────┼──────┼─────────────────────┤
861 │YLM │ 2 2 │ Re and Im orthonor‐ │
862 │ │ │ malized spherical │
863 │ │ │ harmonics degree A │
864 │ │ │ order B │
865 └──────────┴──────┴─────────────────────┘
866
867
868
869
870
871 │YLMg │ 2 2 │ Cos and Sin normal‐ │
872 │ │ │ ized spherical har‐ │
873 │ │ │ monics degree A │
874 │ │ │ order B (geophysi‐ │
875 │ │ │ cal convention) │
876 ├──────────┼──────┼─────────────────────┤
877 │YN │ 2 1 │ Bessel function of │
878 │ │ │ A (2nd kind, order │
879 │ │ │ B) │
880 ├──────────┼──────┼─────────────────────┤
881 │ZCDF │ 1 1 │ Normal cumulative │
882 │ │ │ distribution func‐ │
883 │ │ │ tion for z = A │
884 ├──────────┼──────┼─────────────────────┤
885 │ZPDF │ 1 1 │ Normal probability │
886 │ │ │ density function │
887 │ │ │ for z = A │
888 ├──────────┼──────┼─────────────────────┤
889 │ZCRIT │ 1 1 │ Normal distribution │
890 │ │ │ critical value for │
891 │ │ │ alpha = A │
892 └──────────┴──────┴─────────────────────┘
893
895 The following symbols have special meaning:
896
897 ┌───────┬────────────────────────────┐
898 │PI │ 3.1415926... │
899 ├───────┼────────────────────────────┤
900 │E │ 2.7182818... │
901 ├───────┼────────────────────────────┤
902 │EULER │ 0.5772156... │
903 ├───────┼────────────────────────────┤
904 │EPS_F │ 1.192092896e-07 (single │
905 │ │ precision epsilon │
906 ├───────┼────────────────────────────┤
907 │XMIN │ Minimum x value │
908 ├───────┼────────────────────────────┤
909 │XMAX │ Maximum x value │
910 ├───────┼────────────────────────────┤
911 │XRANGE │ Range of x values │
912 ├───────┼────────────────────────────┤
913 │XINC │ x increment │
914 ├───────┼────────────────────────────┤
915 │NX │ The number of x nodes │
916 ├───────┼────────────────────────────┤
917 │YMIN │ Minimum y value │
918 ├───────┼────────────────────────────┤
919 │YMAX │ Maximum y value │
920 ├───────┼────────────────────────────┤
921 │YRANGE │ Range of y values │
922 ├───────┼────────────────────────────┤
923 │YINC │ y increment │
924 ├───────┼────────────────────────────┤
925 │NY │ The number of y nodes │
926 ├───────┼────────────────────────────┤
927 │X │ Grid with x-coordinates │
928 ├───────┼────────────────────────────┤
929 │Y │ Grid with y-coordinates │
930 ├───────┼────────────────────────────┤
931 │XNORM │ Grid with normalized [-1 │
932 │ │ to +1] x-coordinates │
933 ├───────┼────────────────────────────┤
934 │YNORM │ Grid with normalized [-1 │
935 │ │ to +1] y-coordinates │
936 └───────┴────────────────────────────┘
937
938 │XCOL │ Grid with column numbers │
939 │ │ 0, 1, ..., NX-1 │
940 ├───────┼────────────────────────────┤
941 │YROW │ Grid with row numbers 0, │
942 │ │ 1, ..., NY-1 │
943 ├───────┼────────────────────────────┤
944 │NODE │ Grid with node numbers 0, │
945 │ │ 1, ..., (NX*NY)-1 │
946 └───────┴────────────────────────────┘
947
949 1. For Cartesian grids the operators MEAN, MEDIAN, MODE, LMSSCL, MAD,
950 PQUANT, RMS, STD, and VAR return the expected value from the given
951 matrix. However, for geographic grids we perform a spherically
952 weighted calculation where each node value is weighted by the geo‐
953 graphic area represented by that node.
954
955 2. The operator SDIST calculates spherical distances in km between the
956 (lon, lat) point on the stack and all node positions in the grid.
957 The grid domain and the (lon, lat) point are expected to be in
958 degrees. Similarly, the SAZ and SBAZ operators calculate spherical
959 azimuth and back-azimuths in degrees, respectively. The operators
960 LDIST and PDIST compute spherical distances in km if -fg is set or
961 implied, else they return Cartesian distances. Note: If the current
962 PROJ_ELLIPSOID is ellipsoidal then geodesics are used in calcula‐
963 tions of distances, which can be slow. You can trade speed with
964 accuracy by changing the algorithm used to compute the geodesic
965 (see PROJ_GEODESIC).
966
967 The operator LDISTG is a version of LDIST that operates on the
968 GSHHG data. Instead of reading an ASCII file, it directly accesses
969 one of the GSHHG data sets as determined by the -D and -A options.
970
971 3. The operator POINT reads a ASCII table, computes the mean x and
972 mean y values and places these on the stack. If geographic data
973 then we use the mean 3-D vector to determine the mean location.
974
975 4. The operator PLM calculates the associated Legendre polynomial of
976 degree L and order M (0 <= M <= L), and its argument is the sine of
977 the latitude. PLM is not normalized and includes the Condon-Short‐
978 ley phase (-1)^M. PLMg is normalized in the way that is most com‐
979 monly used in geophysics. The C-S phase can be added by using -M as
980 argument. PLM will overflow at higher degrees, whereas PLMg is
981 stable until ultra high degrees (at least 3000).
982
983 5. The operators YLM and YLMg calculate normalized spherical harmonics
984 for degree L and order M (0 <= M <= L) for all positions in the
985 grid, which is assumed to be in degrees. YLM and YLMg return two
986 grids, the real (cosine) and imaginary (sine) component of the com‐
987 plex spherical harmonic. Use the POP operator (and EXCH) to get rid
988 of one of them, or save both by giving two consecutive = file.nc
989 calls.
990
991 The orthonormalized complex harmonics YLM are most commonly used in
992 physics and seismology. The square of YLM integrates to 1 over a
993 sphere. In geophysics, YLMg is normalized to produce unit power
994 when averaging the cosine and sine terms (separately!) over a
995 sphere (i.e., their squares each integrate to 4 pi). The Con‐
996 don-Shortley phase (-1)^M is not included in YLM or YLMg, but it
997 can be added by using -M as argument.
998
999 6. All the derivatives are based on central finite differences, with
1000 natural boundary conditions, and are Cartesian derivatives.
1001
1002 7. Files that have the same names as some operators, e.g., ADD, SIGN,
1003 =, etc. should be identified by prepending the current directory
1004 (i.e., ./LOG).
1005
1006 8. Piping of files is not allowed.
1007
1008 9. The stack depth limit is hard-wired to 100.
1009
1010 10. All functions expecting a positive radius (e.g., LOG, KEI, etc.)
1011 are passed the absolute value of their argument. (9) The bitwise
1012 operators (BITAND, BITLEFT, BITNOT, BITOR, BITRIGHT, BITTEST, and
1013 BITXOR) convert a grid's single precision values to unsigned 32-bit
1014 ints to perform the bitwise operations. Consequently, the largest
1015 whole integer value that can be stored in a float grid is 2^24 or
1016 16,777,216. Any higher result will be masked to fit in the lower 24
1017 bits. Thus, bit operations are effectively limited to 24 bit. All
1018 bitwise operators return NaN if given NaN arguments or bit-settings
1019 <= 0.
1020
1021 11. When OpenMP support is compiled in, a few operators will take
1022 advantage of the ability to spread the load onto several cores. At
1023 present, the list of such operators is: LDIST, LDIST2, PDIST,
1024 PDIST2, SAZ, SBAZ, SDIST, YLM, and grd_YLMg.
1025
1027 Regardless of the precision of the input data, GMT programs that create
1028 grid files will internally hold the grids in 4-byte floating point
1029 arrays. This is done to conserve memory and furthermore most if not all
1030 real data can be stored using 4-byte floating point values. Data with
1031 higher precision (i.e., double precision values) will lose that preci‐
1032 sion once GMT operates on the grid or writes out new grids. To limit
1033 loss of precision when processing data you should always consider nor‐
1034 malizing the data prior to processing.
1035
1037 By default GMT writes out grid as single precision floats in a
1038 COARDS-complaint netCDF file format. However, GMT is able to produce
1039 grid files in many other commonly used grid file formats and also
1040 facilitates so called "packing" of grids, writing out floating point
1041 data as 1- or 2-byte integers. (more ...)
1042
1044 When the output grid type is netCDF, the coordinates will be labeled
1045 "longitude", "latitude", or "time" based on the attributes of the input
1046 data or grid (if any) or on the -f or -R options. For example, both
1047 -f0x -f1t and -R90w/90e/0t/3t will result in a longitude/time grid.
1048 When the x, y, or z coordinate is time, it will be stored in the grid
1049 as relative time since epoch as specified by TIME_UNIT and TIME_EPOCH
1050 in the gmt.conf file or on the command line. In addition, the unit
1051 attribute of the time variable will indicate both this unit and epoch.
1052
1054 You may store intermediate calculations to a named variable that you
1055 may recall and place on the stack at a later time. This is useful if
1056 you need access to a computed quantity many times in your expression as
1057 it will shorten the overall expression and improve readability. To save
1058 a result you use the special operator STO@label, where label is the
1059 name you choose to give the quantity. To recall the stored result to
1060 the stack at a later time, use [RCL]@label, i.e., RCL is optional. To
1061 clear memory you may use CLR@label. Note that STO and CLR leave the
1062 stack unchanged.
1063
1065 The coastline database is GSHHG (formerly GSHHS) which is compiled from
1066 three sources: World Vector Shorelines (WVS), CIA World Data Bank II
1067 (WDBII), and Atlas of the Cryosphere (AC, for Antarctica only). Apart
1068 from Antarctica, all level-1 polygons (ocean-land boundary) are derived
1069 from the more accurate WVS while all higher level polygons (level 2-4,
1070 representing land/lake, lake/island-in-lake, and
1071 island-in-lake/lake-in-island-in-lake boundaries) are taken from WDBII.
1072 The Antarctica coastlines come in two flavors: ice-front or grounding
1073 line, selectable via the -A option. Much processing has taken place to
1074 convert WVS, WDBII, and AC data into usable form for GMT: assembling
1075 closed polygons from line segments, checking for duplicates, and cor‐
1076 recting for crossings between polygons. The area of each polygon has
1077 been determined so that the user may choose not to draw features
1078 smaller than a minimum area (see -A); one may also limit the highest
1079 hierarchical level of polygons to be included (4 is the maximum). The 4
1080 lower-resolution databases were derived from the full resolution data‐
1081 base using the Douglas-Peucker line-simplification algorithm. The clas‐
1082 sification of rivers and borders follow that of the WDBII. See the GMT
1083 Cookbook and Technical Reference Appendix K for further details.
1084
1086 Users may save their favorite operator combinations as macros via the
1087 file grdmath.macros in their current or user directory. The file may
1088 contain any number of macros (one per record); comment lines starting
1089 with # are skipped. The format for the macros is name = arg1 arg2 ...
1090 arg2 : comment where name is how the macro will be used. When this
1091 operator appears on the command line we simply replace it with the
1092 listed argument list. No macro may call another macro. As an example,
1093 the following macro expects three arguments (radius x0 y0) and sets the
1094 modes that are inside the given circle to 1 and those outside to 0:
1095
1096 INCIRCLE = CDIST EXCH DIV 1 LE : usage: r x y INCIRCLE to return 1
1097 inside circle
1098
1099 Note: Because geographic or time constants may be present in a macro,
1100 it is required that the optional comment flag (:) must be followed by a
1101 space.
1102
1104 To compute all distances to north pole:
1105
1106 gmt grdmath -Rg -I1 0 90 SDIST = dist_to_NP.nc
1107
1108 To take log10 of the average of 2 files, use
1109
1110 gmt grdmath file1.nc file2.nc ADD 0.5 MUL LOG10 = file3.nc
1111
1112 Given the file ages.nc, which holds seafloor ages in m.y., use the
1113 relation depth(in m) = 2500 + 350 * sqrt (age) to estimate normal
1114 seafloor depths:
1115
1116 gmt grdmath ages.nc SQRT 350 MUL 2500 ADD = depths.nc
1117
1118 To find the angle a (in degrees) of the largest principal stress from
1119 the stress tensor given by the three files s_xx.nc s_yy.nc, and s_xy.nc
1120 from the relation tan (2*a) = 2 * s_xy / (s_xx - s_yy), use
1121
1122 gmt grdmath 2 s_xy.nc MUL s_xx.nc s_yy.nc SUB DIV ATAN 2 DIV = direction.nc
1123
1124 To calculate the fully normalized spherical harmonic of degree 8 and
1125 order 4 on a 1 by 1 degree world map, using the real amplitude 0.4 and
1126 the imaginary amplitude 1.1:
1127
1128 gmt grdmath -R0/360/-90/90 -I1 8 4 YLM 1.1 MUL EXCH 0.4 MUL ADD = harm.nc
1129
1130 To extract the locations of local maxima that exceed 100 mGal in the
1131 file faa.nc:
1132
1133 gmt grdmath faa.nc DUP EXTREMA 2 EQ MUL DUP 100 GT MUL 0 NAN = z.nc
1134 gmt grd2xyz z.nc -s > max.xyz
1135
1136 To demonstrate the use of named variables, consider this radial wave
1137 where we store and recall the normalized radial arguments in radians:
1138
1139 gmt grdmath -R0/10/0/10 -I0.25 5 5 CDIST 2 MUL PI MUL 5 DIV STO@r COS @r SIN MUL = wave.nc
1140
1141 To creat a dumb file saved as a 32 bits float GeoTiff using GDAL, run
1142
1143 gmt grdmath -Rd -I10 X Y MUL = lixo.tiff=gd:GTiff
1144
1146 Abramowitz, M., and I. A. Stegun, 1964, Handbook of Mathematical Func‐
1147 tions, Applied Mathematics Series, vol. 55, Dover, New York.
1148
1149 Holmes, S. A., and W. E. Featherstone, 2002, A unified approach to the
1150 Clenshaw summation and the recursive computation of very high degree
1151 and order normalised associated Legendre functions. Journal of Geodesy,
1152 76, 279-299.
1153
1154 Press, W. H., S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery,
1155 1992, Numerical Recipes, 2nd edition, Cambridge Univ., New York.
1156
1157 Spanier, J., and K. B. Oldman, 1987, An Atlas of Functions, Hemisphere
1158 Publishing Corp.
1159
1161 gmt, gmtmath, grd2xyz, grdedit, grdinfo, xyz2grd
1162
1164 2019, P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis, and F. Wobbe
1165
1166
1167
1168
11695.4.5 Feb 24, 2019 GRDMATH(1)