table of contents
conflicting packages
GMTMATH(l) | GMTMATH(l) |
NAME¶
gmtmath - Reverse Polish Notation calculator for data tablesSYNOPSIS¶
gmtmath [ -Ccols ] [ -Hnrec ] [ -Nn_col/ t_col ] [ -Q ][ -S ][ -Tt_min/t_max/t_inc ] [ -V ] [ -bi[s][n] ] [ -bo[s][n] ] operand [ operand ] OPERATOR [ operand ] OPERATOR ... = [ outfile ]
DESCRIPTION¶
gmtmath will perform operations like add, subtract, multiply, and divide on one or more table data 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 file [or standard output]. When two data tables 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 data tables are used in the expression then options -T, -N must be set (and optionally -b). By default, all columns except the "time" column are operated on, but this can be changed (see -C).- operand
- If operand can be opened as a file it will be read as an ASCII (or binary, see -bi) table data file. If not a file, it is interpreted as a numerical constant or a special symbol (see below).
- outfile is a table data file that will hold the final result. If not given then
- the output is sent to stdout.
- OPERATORS
- Choose among the following operators:
- SYMBOLS
- The following symbols have special meaning:
OPTIONS¶
- -C
- Select the columns that will be operated on until next occurrence of -C. List columns separated by commas; ranges like 1,3-5,7 are allowed. [ -C (no arguments) resets the default action of using all columns except time column (see -N]. -Ca selects all columns, inluding time column, while -Cr reverses (toggles) the current choices.
- -H
- Input file(s) has Header record(s). Number of header records can be changed by editing your .gmtdefaults file. If used, GMT default is 1 header record.
- -N
- Select the number of columns and the column number that contains the "time" variable. Columns are numbered starting at 0 [2/0].
- -Q
- Quick mode for scalar calculation. Shorthand for -Ca -N1/0 -T0/0/1.
- -S
- Only report the first row of the results [Default is all rows]. This is useful if you have computed a statistic (say the MODE) and only want to report a single number instead of numerous records with idendical values.
- -T
- Required when no input files are given. Sets the t-coordinates of the first and last point and the equidistant sampling interval for the "time" column (see -N). If there is no time column (only data columns), give -T with no arguments; this also implies -Ca.
- -V
- Selects verbose mode, which will send progress reports to stderr [Default runs "silently"].
- -bi
- Selects binary input. Append s for single precision [Default is double]. Append n for the number of columns in the binary file(s).
- -bo
- Selects binary output. Append s for single precision [Default is double].
BEWARE¶
The operator PLM calculates the associated Legendre polynomial of degree L and order M, and its argument is the cosine of the colatitude which must satisfy -1 <= x <= +1. PLM is not normalized.EXAMPLES¶
To take log10 of the average of 2 data files, usegmtmath file1.d file2.d ADD 0.5 MUL LOG10 = file3.d
gmtmath samples.d T SQRT 350 MUL 2500 ADD SUB = | lpr
gmtmath -C1,4-6 sizes.1 sizes.2 ADD sizes.3 ADD 3 DIV = ave.d
set mode_age = `gmtmath -S -T ages.d MODE =`
set z = `gmtmath -Q 1 1.75 ADD 2.2 DIV 60 COSD ADD KEI =`
BUGS¶
Files that have 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 is not allowed on input, but the output can be sent to stdout. 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.REFERENCES¶
Abramowitz, M., and I. A. Stegun, 1964, Handbook of Mathematical Functions, Applied Mathematics Series, vol. 55, Dover, New York.SEE ALSO¶
gmt(1gmt), grd2xyz(1gmt), grdedit(1gmt), grdinfo(1gmt), grdmath(1gmt), xyz2grd(1gmt)1 Jan 2004 |