other versions
- jessie 3.4.4-1
- jessie 4.5.12-1
- jessie-backports 5.3.1+dfsg-1~bpo8+1
- stretch 5.3.1+dfsg-2
- testing 5.4.5+dfsg-1
- stretch-backports 5.4.5+dfsg-1~bpo9+1
- unstable 5.4.5+dfsg-1
conflicting packages
GRDMATH(1gmt) | Generic Mapping Tools | GRDMATH(1gmt) |
NAME¶
grdmath - Reverse Polish Notation calculator for grid filesSYNOPSIS¶
grdmath [ -F ] [ -Ixinc[unit][=|+][/ yinc[unit][ =|+]] ] [ -M ] [ -N ] [ -Rwest/east/south/north[r] ] [ -V ] [ -bi[s|S|d|D[ncol]|c[ var1 /...]] ] [ -fcolinfo ] operand [ operand ] OPERATOR [ operand ] OPERATOR ... = outgrdfileDESCRIPTION¶
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. When two grids 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 grid files are used in the expression then options -R, -I must be set (and optionally -F). The expression = outgrdfile can occur as many times as the depth of the stack allows.- operand
- 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).
- outgrdfile
- The name of a 2-D grid file that will hold the final result. (See GRID FILE FORMATS below).
- OPERATORS
- Choose among the following 147 operators. "args" are the number
of input and output arguments.
- SYMBOLS
- The following symbols have special meaning:
OPTIONS¶
- -F
- Force pixel node registration [Default is gridline registration]. (Node registrations are defined in GMT Cookbook Appendix B on grid file formats.) Only used with -R -I.
- -I
- 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 c to indicate arc seconds. If one of the units e, k, i, or n is appended instead, the increment is assumed to be given in meter, km, miles, or nautical miles, respectively, and will be converted to the equivalent degrees longitude at the middle latitude of the region (the conversion depends on 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 Appendix B for details. Note: if -Rgrdfile is used then grid spacing has already been initialized; use -I to override the values.
- -M
- 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.
- -N
- 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
- xmin, xmax, ymin, and ymax specify the Region of interest. For geographic regions, these limits correspond to west, east, south, and north and you may specify them in decimal degrees or in [+-]dd:mm[:ss.xxx][W|E|S|N] format. Append r if lower left and upper right map coordinates are given instead of w/e/s/n. The two shorthands -Rg and -Rd stand for global domain (0/360 and -180/+180 in longitude respectively, with -90/+90 in latitude). Alternatively, specify the name of an existing grid file and the -R settings (and grid spacing, if applicable) are copied from the grid. For calendar time coordinates you may either give (a) relative time (relative to the selected TIME_EPOCH and in the selected TIME_UNIT; append t to -JX|x), or (b) absolute time of the form [ date]T[clock] (append T to -JX|x). At least one of date and clock must be present; the T is always required. The date string must be of the form [-]yyyy[-mm[-dd]] (Gregorian calendar) or yyyy[-Www[-d]] (ISO week calendar), while the clock string must be of the form hh:mm:ss[.xxx]. The use of delimiters and their type and positions must be exactly as indicated (however, input, output and plot formats are customizable; see gmtdefaults).
- -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 d (double)]. Uppercase S or D will force byte-swapping. Optionally, append ncol, the number of columns in your binary input file if it exceeds the columns needed by the program. Or append c if the input file is netCDF. Optionally, append var1 /var2/... to specify the variables to be read. The binary input option only applies to the data files needed by operators LDIST, PDIST, and INSIDE.
- -f
- Special formatting of input and/or output columns (time or geographical data). Specify i or o to make this apply only to input or output [Default applies to both]. Give one or more columns (or column ranges) separated by commas. Append T (absolute calendar time), t (relative time in chosen TIME_UNIT since TIME_EPOCH), x (longitude), y (latitude), or f (floating point) to each column or column range item. Shorthand -f[i|o]g means -f[i|o]0x,1y (geographic coordinates).
NOTES ON OPERATORS¶
(1) 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. A few operators ( PDIST, LDIST, and INSIDE) expects their argument to be a single file with points, lines, or polygons, respectively. These distances will be in km (for geographical data, i.e, -fg and Cartesian otherwise. Be aware that LDIST in particular can be slow for large grids and numerous line segments. Note: If the current ELLIPSOID is not spherical then geodesics are used in the calculations.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 2- or 4-byte integers. To specify the precision, scale and offset, the user should add the suffix =id[/scale/offset[ /nan]], where id is a two-letter identifier of the grid type and precision, and scale and offset are optional scale factor and offset to be applied to all grid values, and nan is the value used to indicate missing data. When reading grids, the format is generally automatically recognized. If not, the same suffix can be added to input grid file names. See grdreformat(1) and Section 4.17 of the GMT Technical Reference and Cookbook for more information. When reading a netCDF file that contains multiple grids, GMT will read, by default, the first 2-dimensional grid that can find in that file. To coax GMT into reading another multi-dimensional variable in the grid file, append ?varname to the file name, where varname is the name of the variable. Note that you may need to escape the special meaning of ? in your shell program by putting a backslash in front of it, or by placing the filename and suffix between quotes or double quotes. The ?varname suffix can also be used for output grids to specify a variable name different from the default: "z". See grdreformat(1) and Section 4.18 of the GMT Technical Reference and Cookbook for more information, particularly on how to read splices of 3-, 4-, or 5-dimensional grids.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 -R 90w/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 .gmtdefaults file or on the command line. In addition, the unit attribute of the time variable will indicate both this unit and epoch.EXAMPLES¶
To take log10 of the average of 2 files, useREFERENCES¶
Abramowitz, M., and I. A. Stegun, 1964, Handbook of Mathematical Functions, Applied Mathematics Series, vol. 55, Dover, New York.SEE ALSO¶
GMT(1), gmtmath(1), grd2xyz(1), grdedit(1), grdinfo(1), xyz2grd(1)Feb 27 2014 | GMT 4.5.13 (SVN) |