1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294
|
<HTML>
<HEAD>
<TITLE>grdmath</TITLE>
</HEAD>
<BODY>
<H1>grdmath</H1>
<HR>
<PRE>
<!-- Manpage converted by man2html 3.0.1 -->
grdmath - Reverse Polish Notation calculator for grd files
</PRE>
<H2>SYNOPSIS</H2><PRE>
<B>grdmath</B> [ <B>-I</B><I>xinc</I>[<B>m|c</B>][/<I>yinc</I>[<B>m|c</B>]] <B>-R</B><I>west/east/south/north</I>
<B>-V</B>] <I>operand</I> [ <I>operand</I> ] <B>OPERATOR</B> [ <I>operand</I> ] <B>OPERATOR</B> ...
<B>=</B> <I>outgrdfile</I>
</PRE>
<H2>DESCRIPTION</H2><PRE>
<B>grdmath</B> will perform operations like add, subtract, multi
ply, and divide on one or more grd files or constants
using Reverse Polish Notation (RPN) syntax (e.g., Hewlett-
Packard calculator-style). Arbitrarily complicated expres
sions 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 cor
responding element in file B. However, some operators
only require one operand (see below). If no grdfiles are
used in the expression then options <B>-R,</B> <B>-I</B> must be set
(and optionally <B>-F</B>).
<I>operand</I>
If <I>operand</I> 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).
<I>outgrdfile</I> is a 2-D grd file that will hold the final
result.
<B>OPERATORS</B>
Choose among the following operators:
Operator n_args Returns
<B>ABS</B> 1 abs (A).
<B>ACOS</B> 1 acos (A).
<B>ACOSH</B> 1 acosh (A).
<B>ADD(+)</B> 2 A + B.
<B>AND</B> 2 NaN if A and B == NaN, B if A == NaN, else A.
<B>ASIN</B> 1 asin (A).
<B>ASINH</B> 1 asinh (A).
<B>ATAN</B> 1 atan (A).
<B>ATAN2</B> 2 atan2 (A, B).
<B>ATANH</B> 1 atanh (A).
<B>BEI</B> 1 bei (A).
<B>BER</B> 1 ber (A).
<B>CDIST</B> 2 Cartesian distance between grid nodes and
stack x,y.
<B>CEIL</B> 1 ceil (A) (smallest integer >= A).
<B>CHIDIST</B> 2 Chi-squared-distribution P(chi2,nn), with
chi2 = A and n = B.
<B>COS</B> 1 cos (A) (A in radians).
<B>COSD</B> 1 cos (A) (A in degrees).
<B>D2DX2</B> 1 d^2(A)/dx^2 2nd derivative.
<B>D2DY2</B> 1 d^2(A)/dy^2 2nd derivative.
<B>D2R</B> 1 Converts Degrees to Radians.
<B>DDX</B> 1 d(A)/dx 1st derivative.
<B>DDY</B> 1 d(A)/dy 1st derivative.
<B>DILOG</B> 1 Dilog (A).
<B>DIV(/)</B> 2 A / B.
<B>DUP</B> 1 Places duplicate of A on the stack.
<B>ERF</B> 1 Error function of A.
<B>ERFC</B> 1 Complimentory Error function of A.
<B>ERFINV</B> 1 Inverse error function of A.
<B>EQ</B> 2 1 if A == B, else 0.
<B>EXCH</B> 2 Exchanges A and B on the stack.
<B>EXP</B> 1 exp (A).
<B>EXTREMA</B> 1 Local Extrema: +2/-2 is max/min, +1/-1 is
saddle with max/min in x, 0 elsewhere.
<B>FDIST</B> 4 F-distribution Q(s1,s2,n1,n2), with s1 = A,
s2 = B, n1 = C, and n2 = D.
<B>FLOOR</B> 1 floor (A) (greatest integer <= A).
<B>FMOD</B> 2 A % B (remainder).
<B>GDIST</B> 2 Great distance (in degrees) between grid
nodes and stack lon,lat.
<B>GE</B> 2 1 if A >= B, else 0.
<B>GT</B> 2 1 if A > B, else 0.
<B>HYPOT</B> 2 hypot (A, B).
<B>I0</B> 1 Modified Bessel function of A (1st kind, order
0).
<B>I1</B> 1 Modified Bessel function of A (1st kind, order
1).
<B>IN</B> 2 Modified Bessel function of A (1st kind, order
B).
<B>INV</B> 1 1 / A.
<B>ISNAN</B> 1 1 if A == NaN, else 0.
<B>J0</B> 1 Bessel function of A (1st kind, order 0).
<B>J1</B> 1 Bessel function of A (1st kind, order 1).
<B>JN</B> 2 Bessel function of A (1st kind, order B).
<B>K0</B> 1 Modified Kelvin function of A (2nd kind, order
0).
<B>K1</B> 1 Modified Bessel function of A (2nd kind, order
1).
<B>KN</B> 2 Modified Bessel function of A (2nd kind, order
B).
<B>KEI</B> 1 kei (A).
<B>KER</B> 1 ker (A).
<B>LE</B> 2 1 if A <= B, else 0.
<B>LMSSCL</B> 1 LMS scale estimate (LMS STD) of A.
<B>LOG</B> 1 log (A) (natural log).
<B>LOG10</B> 1 log10 (A).
<B>LOG1P</B> 1 log (1+A) (accurate for small A).
<B>LOWER</B> 1 The lowest (minimum) value of A.
<B>LT</B> 2 1 if A < B, else 0.
<B>MAD</B> 1 Median Absolute Deviation (L1 STD) of A.
<B>MED</B> 1 Median value of A.
<B>MIN</B> 2 Minimum of A and B.
<B>MODE</B> 1 Mode value (LMS) of A.
<B>MUL(x)</B> 2 A * B.
<B>NAN</B> 2 NaN if A == B, else A.
<B>NEG</B> 1 -A.
<B>NRAND</B> 2 Normal, random values with mean A and std.
deviation B.
<B>OR</B> 2 NaN if A or B == NaN, else A.
<B>PLM</B> 3 Associated Legendre polynomial P(-1<A<+1)
degree B order C.
<B>POP</B> 1 Delete top element from the stack.
<B>POW(^)</B> 2 A ^ B.
<B>R2</B> 2 R2 = A^2 + B^2.
<B>R2D</B> 1 Convert Radians to Degrees.
<B>RAND</B> 2 Uniform random values between A and B.
<B>RINT</B> 1 rint (A) (nearest integer).
<B>SIGN</B> 1 sign (+1 or -1) of A.
<B>SIN</B> 1 sin (A) (A in radians).
<B>SIND</B> 1 sin (A) (A in degrees).
<B>SINH</B> 1 sinh (A).
<B>SQRT</B> 1 sqrt (A).
<B>STD</B> 1 Standard deviation of A.
<B>STEP</B> 1 Heaviside step function: H(A).
<B>STEPX</B> 1 Heaviside step function in x: H(x-A).
<B>STEPY</B> 1 Heaviside step function in y: H(y-A).
<B>SUB(-)</B> 2 A - B.
<B>TAN</B> 1 tan (A) (A in radians).
<B>TAND</B> 1 tan (A) (A in degrees).
<B>TANH</B> 1 tanh (A).
<B>TDIST</B> 2 Student's t-distribution A(t,n), with t =
A, and n = B).'
<B>UPPER</B> 1 The highest (maximum) value of A.
<B>XOR</B> 2 B if A == NaN, else A.
<B>Y0</B> 1 Bessel function of A (2nd kind, order 0).
<B>Y1</B> 1 Bessel function of A (2nd kind, order 1).
<B>YLM</B> 2 Re and Im normalized surface harmonics
(degree A, order B).
<B>YN</B> 2 Bessel function of A (2nd kind, order B).
<B>SYMBOLS</B>
The following symbols have special meaning:
<B>PI</B> 3.1415926...
<B>E</B> 2.7182818...
<B>X</B> Grid with x-coordinates
<B>Y</B> Grid with y-coordinates
</PRE>
<H2>OPTIONS</H2><PRE>
<B>-I</B> <I>x</I><B>_</B><I>inc</I> [and optionally <I>y</I><B>_</B><I>inc</I>] is the grid spacing.
Append <B>m</B> to indicate minutes or <B>c</B> to indicate sec
onds.
interest. To specify boundaries in degrees and min
utes [and seconds], use the dd:mm[:ss] format.
Append <B>r</B> if lower left and upper right map coordi
nates are given instead of wesn.
<B>-F</B> Select pixel registration. [Default is grid regis
tration].
<B>-V</B> Selects verbose mode, which will send progress
reports to stderr [Default runs "silently"].
</PRE>
<H2>BEWARE</H2><PRE>
The operator <B>GDIST</B> calculates spherical distances bewteen
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. The operator <B>YLM</B> calculates the
fully normalized spherical harmonics for degree L and
order M for all positions in the grid, which is assumed to
be in degrees. <B>YLM</B> returns two grids, the Real (cosine)
and Imaginary (sine) component of the complex spherical
harmonic. Use the <B>POP</B> operator (and <B>EXCH</B>) to get rid of
one of them. The operator <B>PLM</B> calculates the associated
Legendre polynomial of degree L and order M, and its argu
ment is the cosine of the colatitude which must satisfy -1
<= x <= +1. Unlike <B>YLM</B>, <B>PLM</B> is not normalized.
All the derivatives are based on central finite differ
ences, with natural boundary conditions.
</PRE>
<H2>EXAMPLES</H2><PRE>
To take log10 of the average of 2 files, use
grdmath file1.grd file2.grd <B>ADD</B> 0.5 <B>MUL</B> <B>LOG10</B> <B>=</B>
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 <B>SQRT</B> 350 <B>MUL</B> 2500 <B>ADD</B> <B>=</B>
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 <B>MUL</B> s_xx.grd s_yy.grd <B>SUB</B> <B>DIV</B>
<B>ATAN2</B> 2 <B>DIV</B> <B>=</B> direction.grd
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,
try
grdmath <B>-R</B>0/360/-90/90 <B>-I</B>1 8 4 <B>YML</B> 1.1 <B>MUL</B> <B>EXCH</B>
0.4 <B>MUL</B> <B>ADD</B> = harm.grd
mGal in the file faa.grd, try
grdmath faa.grd <B>DUP</B> <B>EXTREMA</B> 2 <B>EQ</B> <B>MUL</B> <B>DUP</B> 100 <B>GT</B>
<B>NAN</B> <B>MUL</B> = z.grd
grd2xyz z.grd <B>-S</B> > max.xyz
</PRE>
<H2>BUGS</H2><PRE>
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. All functions
expecting a positive radius (e.g., log, kei, etc.) are
passed the absolute value of their argument.
</PRE>
<H2>REFERENCES</H2><PRE>
Abramowitz, M., and I. A. Stegun, 1964, <I>Handbook</I> <I>of</I> <I>Mathe</I>
<I>matical</I> <I>Functions</I>, Applied Mathematics Series, vol. 55,
Dover, New York.
Press, W. H., S. A. Teukolsky, W. T. Vetterling, B. P.
Flannery, 1992, <I>Numerical</I> <I>Recipes</I>, 2nd edition, Cambridge
Univ., New York.
</PRE>
<H2>SEE ALSO</H2><PRE>
<I>gmt</I>(l), <I><A HREF="gmtmath.html">gmtmath</A></I>(l), <I><A HREF="grd2xyz.html">grd2xyz</A></I>(l), <I><A HREF="grdedit.html">grdedit</A></I>(l), <I><A HREF="grdinfo.html">grdinfo</A></I>(l),
<I><A HREF="xyz2grd.html">xyz2grd</A></I>(l)
</PRE>
<HR>
<ADDRESS>
Man(1) output converted with
<a href="http://www.oac.uci.edu/indiv/ehood/man2html.html">man2html</a>
</ADDRESS>
</BODY>
</HTML>
<body bgcolor="#ffffff">
|