.TH GRDMATH l "1 Jan 2004" .SH NAME grdmath \- Reverse Polish Notation calculator for grd files .SH SYNOPSIS \fBgrdmath\fP [ \fB\-F\fP ] [ \fB\-I\fP\fIxinc\fP[\fBm|c\fP][/\fIyinc\fP[\fBm|c\fP]] \fB\-R\fP\fIwest/east/south/north\fP \fB\-V\fP] \fIoperand\fP [ \fIoperand\fP ] \fBOPERATOR\fP [ \fIoperand\fP ] \fBOPERATOR\fP ... \fB=\fP \fIoutgrdfile\fP .SH DESCRIPTION \fBgrdmath\fP will perform operations like add, subtract, multiply, and divide on one or more grd 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 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 \fB\-R, \-I\fP must be set (and optionally \fB\-F\fP). .TP \fIoperand\fP If \fIoperand\fP 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). .TP \fIoutgrdfile\fP is a 2-D grd file that will hold the final result. .TP .B OPERATORS Choose among the following operators: .br Operator n_args Returns .br .sp \fBABS\fP 1 abs (A). .br \fBACOS\fP 1 acos (A). .br \fBACOSH\fP 1 acosh (A). .br \fBADD(+)\fP 2 A + B. .br \fBAND\fP 2 NaN if A and B == NaN, B if A == NaN, else A. .br \fBASIN\fP 1 asin (A). .br \fBASINH\fP 1 asinh (A). .br \fBATAN\fP 1 atan (A). .br \fBATAN2\fP 2 atan2 (A, B). .br \fBATANH\fP 1 atanh (A). .br \fBBEI\fP 1 bei (A). .br \fBBER\fP 1 ber (A). .br \fBCDIST\fP 2 Cartesian distance between grid nodes and stack x,y. .br \fBCEIL\fP 1 ceil (A) (smallest integer >= A). .br \fBCHIDIST\fP 2 Chi-squared-distribution P(chi2,nu), with chi2 = A and nu = B. .br \fBCOS\fP 1 cos (A) (A in radians). .br \fBCOSD\fP 1 cos (A) (A in degrees). .br \fBCOSH\fP 1 cosh (A). .br \fBCURV\fP 1 Curvature of A (Laplacian). .br \fBD2DX2\fP 1 d^2(A)/dx^2 2nd derivative. .br \fBD2DY2\fP 1 d^2(A)/dy^2 2nd derivative. .br \fBD2R\fP 1 Converts Degrees to Radians. .br \fBDDX\fP 1 d(A)/dx 1st derivative. .br \fBDDY\fP 1 d(A)/dy 1st derivative. .br \fBDILOG\fP 1 Dilog (A). .br \fBDIV(/)\fP 2 A / B. .br \fBDUP\fP 1 Places duplicate of A on the stack. .br \fBERF\fP 1 Error function of A. .br \fBERFC\fP 1 Complementory Error function of A. .br \fBERFINV\fP 1 Inverse error function of A. .br \fBEQ\fP 2 1 if A == B, else 0. .br \fBEXCH\fP 2 Exchanges A and B on the stack. .br \fBEXP\fP 1 exp (A). .br \fBEXTREMA\fP 1 Local Extrema: +2/-2 is max/min, +1/-1 is saddle with max/min in x, 0 elsewhere. .br \fBFDIST\fP 4 F-dist Q(var1,var2,nu1,nu2), with var1 = A, var2 = B, nu1 = C, and nu2 = D. .br \fBFLOOR\fP 1 floor (A) (greatest integer <= A). .br \fBFMOD\fP 2 A % B (remainder). .br \fBGDIST\fP 2 Great distance (in degrees) between grid nodes and stack lon,lat. .br \fBGE\fP 2 1 if A >= B, else 0. .br \fBGT\fP 2 1 if A > B, else 0. .br \fBHYPOT\fP 2 hypot (A, B). .br \fBI0\fP 1 Modified Bessel function of A (1st kind, order 0). .br \fBI1\fP 1 Modified Bessel function of A (1st kind, order 1). .br \fBIN\fP 2 Modified Bessel function of A (1st kind, order B). .br \fBINV\fP 1 1 / A. .br \fBISNAN\fP 1 1 if A == NaN, else 0. .br \fBJ0\fP 1 Bessel function of A (1st kind, order 0). .br \fBJ1\fP 1 Bessel function of A (1st kind, order 1). .br \fBJN\fP 2 Bessel function of A (1st kind, order B). .br \fBK0\fP 1 Modified Kelvin function of A (2nd kind, order 0). .br \fBK1\fP 1 Modified Bessel function of A (2nd kind, order 1). .br \fBKN\fP 2 Modified Bessel function of A (2nd kind, order B). .br \fBKEI\fP 1 kei (A). .br \fBKER\fP 1 ker (A). .br \fBLE\fP 2 1 if A <= B, else 0. .br \fBLMSSCL\fP 1 LMS scale estimate (LMS STD) of A. .br \fBLOG\fP 1 log (A) (natural log). .br \fBLOG10\fP 1 log10 (A). .br \fBLOG1P\fP 1 log (1+A) (accurate for small A). .br \fBLOWER\fP 1 The lowest (minimum) value of A. .br \fBLT\fP 2 1 if A < B, else 0. .br \fBMAD\fP 1 Median Absolute Deviation (L1 STD) of A. .br \fBMAX\fP 2 Maximum of A and B. .br \fBMEAN\fP 1 Mean value of A. .br \fBMED\fP 1 Median value of A. .br \fBMIN\fP 2 Minimum of A and B. .br \fBMODE\fP 1 Mode value (LMS) of A. .br \fBMUL(x)\fP 2 A * B. .br \fBNAN\fP 2 NaN if A == B, else A. .br \fBNEG\fP 1 -A. .br \fBNRAND\fP 2 Normal, random values with mean A and std. deviation B. .br \fBOR\fP 2 NaN if A or B == NaN, else A. .br \fBPLM\fP 3 Associated Legendre polynomial P(-1 max.xyz .SH 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. All functions expecting a positive radius (e.g., log, kei, etc.) are passed the absolute value of their argument. .SH REFERENCES Abramowitz, M., and I. A. Stegun, 1964, \fIHandbook of Mathematical Functions\fP, Applied Mathematics Series, vol. 55, Dover, New York. .br Press, W. H., S. A. Teukolsky, W. T. Vetterling, B. P. Flannery, 1992, \fINumerical Recipes\fP, 2nd edition, Cambridge Univ., New York. .SH "SEE ALSO" .IR gmt (1gmt), .IR gmtmath (1gmt), .IR grd2xyz (1gmt), .IR grdedit (1gmt), .IR grdinfo (1gmt), .IR xyz2grd (1gmt)