blockmode

Block average (x,y,z) data tables by mode estimation

Synopsis

gmt blockmode [ table ] -Iincrement -Rregion [ -Afields ] [ -C ] [ -D[width][+c][+a|+l|+h ] [ -Er|s[+l|h] ] [ -G[grdfile] ] [ -Q ] [ -V[level] ] [ -W[i|o][+s] ] [ -aflags ] [ -bbinary ] [ -dnodata ] [ -eregexp ] [ -fflags ] [ -hheaders ] [ -iflags ] [ -oflags ] [ -qflags ] [ -rreg ] [ -:[i|o] ] [ --PAR=value ]

Note: No space is allowed between the option flag and the associated arguments.

Description

blockmode reads arbitrarily located (x,y,z) triples [or optionally weighted quadruples (x,y,z,w)] from standard input [or table] and writes to standard output mode estimates of position and value for every non-empty block in a grid region defined by the -R and -I arguments. See -G for writing gridded output directly. Either blockmean, blockmedian, or blockmode should be used as a pre-processor before running surface to avoid aliasing short wavelengths. These routines are also generally useful for decimating or averaging (x,y,z) data. You can modify the precision of the output format by editing the FORMAT_FLOAT_OUT parameter in your gmt.conf file, or you may choose binary input and/or output to avoid loss of precision.

Required Arguments

-Ixinc[+e|n][/yinc[+e|n]]

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 s to indicate arc seconds. If one of the units e, f, k, M, n or u is appended instead, the increment is assumed to be given in meter, foot, km, Mile, nautical mile or US survey foot, respectively, and will be converted to the equivalent degrees longitude at the middle latitude of the region (the conversion depends on PROJ_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 +e 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 +n 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 GMT File Formats for details. Note: If -Rgrdfile is used then the grid spacing (and registration) have already been initialized; use -I (and -r) to override the values.

-Rxmin/xmax/ymin/ymax[+r][+uunit] (more …)

Specify the region of interest.

Optional Arguments

table

3 (or 4, see -W) column ASCII data table file(s) (or binary, see -bi) holding (x,y,z[,w]) data values, where [w] is an optional weight for the data. If no file is specified, blockmode will read from standard input.

-Afields

Select which fields to write to individual grids. Requires -G. Append the codes for available fields: z (the modal data z), s (the L1 scale of the mode), l (lowest value), h (highest value) and w (the output weight; requires -W). Note s|l|h requires -E, and Es|r cannot be used. [Default is just z].

-C

Use the center of the block as the output location [Default uses the modal xy location (but see -Q)]. -C overrides -Q.

-D[width][+c][+a|+l|+h]

Perform unweighted mode calculation via histogram binning, using the specified histogram width. Append +c to center bins so that their mid point is a multiple of width [uncentered]. If multiple modes are found for a block we return the average mode [+a]. Append +l or +h to return the low of high mode instead, respectively. If width is not given it will default to 1 provided your data set only contains integers. Also, for integer data and integer bin width we enforce bin centering (+c) and select the lowest mode (+l) if there are multiples. [Default mode is normally the Least Median of Squares (LMS) statistic].

-E

Provide Extended report which includes s (the L1 scale of the mode), l, the lowest value, and h, the high value for each block. Output order becomes x,y,z,s,l,h[,w]. Default outputs x,y,z[,w]. See -W for w output.

-Er|s[+l|h]

Provide source id s or record number r output, i.e., append the source id or record number associated with the modal value. If tied then report the record number of the higher of the two values (i.e., +h is the default); append +l to instead report the record number of the lower value. Note that -E may be repeated so that both both -E and -Er[+l|h] may be specified. For -Es we expect input records of the form x,y,z[,w],sid, where sid is an unsigned integer source id.

-Ggrdfile

Write one or more fields directly to grids; no table data are written to standard output. If more than one fields are specified via -A then grdfile must contain the format flag %s so that we can embed the field code in the file names.

-Q

(Quicker) Finds mode z and mean (x,y) [Default finds mode x, mode y, mode z].

-V[level] (more …)

Select verbosity level [w].

-W[i|o][+s]

Weighted modifier[s]. Unweighted input and output have 3 columns x,y,z; Weighted i/o has 4 columns x,y,z,w. Weights can be used in input to construct weighted modal values for each block. Weight sums can be reported in output for later combining several runs, etc. Use -W for weighted i/o, -Wi for weighted input only, and -Wo for weighted output only. [Default uses unweighted i/o]. If your weights are actually uncertainties (one sigma) then append +s and we compute weight = 1/sigma.

-a[col=]name[,] (more …)

Set aspatial column associations col=name.

-bi[ncols][t] (more …)

Select native binary format for primary input. [Default is 3 (or 4 if -Wi is set)].

-bo[ncols][type] (more …)

Select native binary output. [Default is 3 (or 4 if -Wo is set)]. -E adds 3 additional columns.

-d[i|o]nodata (more …)

Replace input columns that equal nodata with NaN and do the reverse on output.

-e[~]“pattern” | -e[~]/regexp/[i] (more …)

Only accept data records that match the given pattern.

-f[i|o]colinfo (more …)

Specify data types of input and/or output columns.

-h[i|o][n][+c][+d][+msegheader][+rremark][+ttitle] (more …)

Skip or produce header record(s).

-icols[+l][+sscale][+ooffset][,][,t[word]] (more …)

Select input columns and transformations (0 is first column, t is trailing text, append word to read one word only).

-q[i|o][~]rows[+ccol][+a|f|s] (more …)

Select input or output rows or data range(s) [all].

-r[g|p] (more …)

Set node registration [gridline]. Each block is the locus of points nearest the grid value location. Consider an example with -R10/15/10/15 and -I1: With -r or -rp, 10 <= (x,y) < 11 is one of 25 blocks; otherwise 9.5 <= (x,y) < 10.5 is one of 36 blocks.

-:[i|o] (more …)

Swap 1st and 2nd column on input and/or output.

-^ or just -

Print a short message about the syntax of the command, then exit (NOTE: on Windows just use -).

-+ or just +

Print an extensive usage (help) message, including the explanation of any module-specific option (but not the GMT common options), then exit.

-? or no arguments

Print a complete usage (help) message, including the explanation of all options, then exit.

--PAR=value

Temporarily override a GMT default setting; repeatable. See gmt.conf for parameters.

ASCII Format Precision

The ASCII output formats of numerical data are controlled by parameters in your gmt.conf file. Longitude and latitude are formatted according to FORMAT_GEO_OUT, absolute time is under the control of FORMAT_DATE_OUT and FORMAT_CLOCK_OUT, whereas general floating point values are formatted according to FORMAT_FLOAT_OUT. Be aware that the format in effect can lead to loss of precision in ASCII output, which can lead to various problems downstream. If you find the output is not written with enough precision, consider switching to binary output (-bo if available) or specify more decimals using the FORMAT_FLOAT_OUT setting.

Examples

To find 5 by 5 minute block mode from the ASCII data in ship_15.txt and output a binary table with double precision triplets, run:

gmt blockmedian @ship_15.txt -R245/255/20/30 -I5m -bo3d > ship_5x5.b

To determine the most frequently occurring values per 2x2 block using histogram binning, with data representing integer counts, try:

gmt blockmode @ship_15.txt -R245/255/20/30 -I2  -r -C -D

To determine the mode and L1 scale (MAD) on the mode per 10 minute bin and save these to two separate grids called field_z.nc and field_s.nc, run:

gmt blockmode @ship_15.txt -I10m -R-115/-105/20/30 -E -Gfield_%s.nc -Azs