.\" Man page generated from reStructuredText. . .TH "GRDFILTER" "1gmt" "Jan 10, 2019" "5.4.5" "GMT" .SH NAME grdfilter \- Filter a grid in the space (or time) domain . .nr rst2man-indent-level 0 . .de1 rstReportMargin \\$1 \\n[an-margin] level \\n[rst2man-indent-level] level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] - \\n[rst2man-indent0] \\n[rst2man-indent1] \\n[rst2man-indent2] .. .de1 INDENT .\" .rstReportMargin pre: . RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .\" .rstReportMargin post: .. .de UNINDENT . RE .\" indent \\n[an-margin] .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] .nr rst2man-indent-level -1 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. .SH SYNOPSIS .sp \fBgrdfilter\fP \fIingrid\fP \fB\-D\fP\fIdistance_flag\fP \fB\-F\fP\fBx\fP\fIwidth\fP[/\fIwidth2\fP][\fImodifiers\fP] \fB\-G\fP\fIoutgrid\fP [ \fB\-I\fP\fIincrement\fP ] [ \fB\-N\fP\fBi\fP|\fBp\fP|\fBr\fP ] [ \fB\-R\fP\fIregion\fP ] [ \fB\-T\fP ] [ \fB\-V\fP[\fIlevel\fP] ] [ \fB\-f\fPflags ] .sp \fBNote:\fP No space is allowed between the option flag and the associated arguments. .SH DESCRIPTION .sp \fBgrdfilter\fP will filter a grid file in the time domain using one of the selected convolution or non\-convolution isotropic or rectangular filters and compute distances using Cartesian or Spherical geometries. The output grid file can optionally be generated as a sub\-region of the input (via \fB\-R\fP) and/or with new increment (via \fB\-I\fP) or registration (via \fB\-T\fP). In this way, one may have "extra space" in the input data so that the edges will not be used and the output can be within one half\-width of the input edges. If the filter is low\-pass, then the output may be less frequently sampled than the input. .SH REQUIRED ARGUMENTS .INDENT 0.0 .TP .B \fIingrid\fP The grid file of points to be filtered. (See GRID FILE FORMATS below). .UNINDENT .INDENT 0.0 .TP \fB\-D\fP\fIdistance_flag\fP Distance \fIflag\fP tells how grid (x,y) relates to filter \fIwidth\fP as follows: .sp \fIflag\fP = p: grid (px,py) with \fIwidth\fP an odd number of pixels; Cartesian distances. .sp \fIflag\fP = 0: grid (x,y) same units as \fIwidth\fP, Cartesian distances. .sp \fIflag\fP = 1: grid (x,y) in degrees, \fIwidth\fP in kilometers, Cartesian distances. .sp \fIflag\fP = 2: grid (x,y) in degrees, \fIwidth\fP in km, dx scaled by cos(middle y), Cartesian distances. .sp The above options are fastest because they allow weight matrix to be computed only once. The next three options are slower because they recompute weights for each latitude. .sp \fIflag\fP = 3: grid (x,y) in degrees, \fIwidth\fP in km, dx scaled by cosine(y), Cartesian distance calculation. .sp \fIflag\fP = 4: grid (x,y) in degrees, \fIwidth\fP in km, Spherical distance calculation. .sp \fIflag\fP = 5: grid (x,y) in Mercator \fB\-Jm\fP1 img units, \fIwidth\fP in km, Spherical distance calculation. .UNINDENT .INDENT 0.0 .TP \fB\-Fx\fP\fIwidth\fP[/\fIwidth2\fP][\fImodifiers\fP] Sets the filter type. Choose among convolution and non\-convolution filters. Use any filter code \fBx\fP (listed below) followed by the full diameter \fIwidth\fP\&. This gives an isotropic filter; append /\fIwidth2\fP for a rectangular filter (requires \fB\-Dp\fP or \fB\-D0\fP). By default we perform low\-pass filtering; append \fB+h\fP to select high\-pass filtering. Some filters allow for optional arguments and modifiers. .sp Convolution filters (and their codes) are: .sp (\fBb\fP) Boxcar: All weights are equal. .sp (\fBc\fP) Cosine Arch: Weights follow a cosine arch curve. .sp (\fBg\fP) Gaussian: Weights are given by the Gaussian function, where \fIwidth\fP is 6 times the conventional Gaussian sigma. .sp (\fBf\fP) Custom: Weights are given by the precomputed values in the filter weight grid file \fIweight\fP, which must have odd dimensions; also requires \fB\-D0\fP and output spacing must match input spacing or be integer multiples. .sp (\fBo\fP) Operator: Weights are given by the precomputed values in the filter weight grid file \fIweight\fP, which must have odd dimensions; also requires \fB\-D0\fP and output spacing must match input spacing or be integer multiples. Weights are assumed to sum to zero so no accumulation of weight sums and normalization will be done. .sp Non\-convolution filters (and their codes) are: .sp (\fBm\fP) Median: Returns median value. To select another quantile append \fB+q\fP\fIquantile\fP in the 0\-1 range [Default is 0.5, i.e., median]. .sp (\fBp\fP) Maximum likelihood probability (a mode estimator): Return modal value. If more than one mode is found we return their average value. Append \fB+l\fP or \fB+u\fP if you rather want to return the lowermost or uppermost of the modal values. .sp (\fBh\fP) Histogram mode (another mode estimator): Return the modal value as the center of the dominant peak in a histogram. Append /\fIbinwidth\fP to specify the binning interval. Use modifier \fB+c\fP to center the bins on multiples of \fIbinwidth\fP [Default has bin edges that are multiples of \fIbinwidth\fP]. If more than one mode is found we return their average value. Append \fB+l\fP or \fB+u\fP if you rather want to return the lowermost or uppermost of the modal values. .sp (\fBl\fP) Lower: Return the minimum of all values. .sp (\fBL\fP) Lower: Return minimum of all positive values only. .sp (\fBu\fP) Upper: Return maximum of all values. .sp (\fBU\fP) Upper: Return maximum or all negative values only. .sp In the case of \fBL\fP|\fBU\fP it is possible that no data passes the initial sign test; in that case the filter will return NaN. .UNINDENT .INDENT 0.0 .TP \fB\-G\fP\fIoutgrid\fP \fIoutgrid\fP is the output grid file of the filter. (See GRID FILE FORMATS below). .UNINDENT .SH OPTIONAL ARGUMENTS .INDENT 0.0 .TP \fB\-I\fP\fIxinc\fP[\fIunit\fP][\fB+e\fP|\fBn\fP][/\fIyinc\fP[\fIunit\fP][\fB+e\fP|\fBn\fP]] \fIx_inc\fP [and optionally \fIy_inc\fP] is the grid spacing. Optionally, append a suffix modifier. \fBGeographical (degrees) coordinates\fP: Append \fBm\fP to indicate arc minutes or \fBs\fP to indicate arc seconds. If one of the units \fBe\fP, \fBf\fP, \fBk\fP, \fBM\fP, \fBn\fP or \fBu\fP 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 \fIy_inc\fP is given but set to 0 it will be reset equal to \fIx_inc\fP; otherwise it will be converted to degrees latitude. \fBAll coordinates\fP: If \fB+e\fP is appended then the corresponding max \fIx\fP (\fIeast\fP) or \fIy\fP (\fInorth\fP) 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 \fInumber of nodes\fP desired by appending \fB+n\fP 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 App\-file\-formats for details. Note: if \fB\-R\fP\fIgrdfile\fP is used then the grid spacing has already been initialized; use \fB\-I\fP to override the values. .UNINDENT .INDENT 0.0 .TP \fB\-N\fP\fBi\fP|\fBp\fP|\fBr\fP Determine how NaN\-values in the input grid affects the filtered output: Append \fBi\fP to ignore all NaNs in the calculation of filtered value [Default], \fBr\fP is same as \fBi\fP except if the input node was NaN then the output node will be set to NaN (only applies if both grids are co\-registered), and \fBp\fP which will force the filtered value to be NaN if any grid\-nodes with NaN\-values are found inside the filter circle. .UNINDENT .INDENT 0.0 .TP \fB\-R\fP \fIwest\fP, \fIeast\fP, \fIsouth\fP, and \fInorth\fP defines the Region of the output points. [Default: Same as input.] .UNINDENT .INDENT 0.0 .TP \fB\-T\fP Toggle the node registration for the output grid so as to become the opposite of the input grid [Default gives the same registration as the input grid]. .UNINDENT .INDENT 0.0 .TP \fB\-V\fP[\fIlevel\fP] (more ...) Select verbosity level [c]. .UNINDENT .INDENT 0.0 .TP \fB\-f\fP[\fBi\fP|\fBo\fP]\fIcolinfo\fP (more ...) Specify data types of input and/or output columns. .UNINDENT .INDENT 0.0 .TP \fB\-^\fP or just \fB\-\fP Print a short message about the syntax of the command, then exits (NOTE: on Windows just use \fB\-\fP). .TP \fB\-+\fP or just \fB+\fP Print an extensive usage (help) message, including the explanation of any module\-specific option (but not the GMT common options), then exits. .TP \fB\-?\fP or no arguments Print a complete usage (help) message, including the explanation of all options, then exits. .UNINDENT .SH GRID FILE FORMATS .sp 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 1\- or 2\-byte integers. (more ...) .SH GEOGRAPHICAL AND TIME COORDINATES .sp 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 \fB\-f\fP or \fB\-R\fP options. For example, both \fB\-f0x\fP \fB\-f1t\fP and \fB\-R\fP90w/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 gmt.conf file or on the command line. In addition, the \fBunit\fP attribute of the time variable will indicate both this unit and epoch. .SH EXAMPLES .sp Suppose that north_pacific_etopo5.nc is a file of 5 minute bathymetry from 140E to 260E and 0N to 50N, and you want to find the medians of values within a 300km radius (600km full width) of the output points, which you choose to be from 150E to 250E and 10N to 40N, and you want the output values every 0.5 degree. Using spherical distance calculations, you need: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C gmt grdfilter north_pacific_etopo5.nc \-Gfiltered_pacific.nc \-Fm600 \e \-D4 \-R150/250/10/40 \-I0.5 \-V .ft P .fi .UNINDENT .UNINDENT .UNINDENT .UNINDENT .sp If we instead wanted a high\-pass result then one can perform the corresponding low\-pass filter using a coarse grid interval as \fBgrdfilter\fP will resample the result to the same resolution as the input grid so we can compute the residuals, e.g., .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C gmt grdfilter north_pacific_etopo5.nc \-Gresidual_pacific.nc \-Fm600+h \e \-D4 \-R150/250/10/40 \-I0.5 \-V .ft P .fi .UNINDENT .UNINDENT .UNINDENT .UNINDENT .sp Here, the residual_pacific.nc grid will have the same 5 minute resolution as the original. .sp To filter the dataset in ripples.nc using a custom anisotropic Gaussian filter exp (\-0.5*r^2) whose distances r from the center is given by (2x^2 + y^2 \-2xy)/6, with major axis at an angle of 63 degrees with the horizontal, try .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C gmt grdmath \-R\-10/10/\-10/10 \-I1 X 2 POW 2 MUL Y 2 POW ADD X Y MUL 2 MUL \e SUB 6 DIV NEG 2 DIV EXP DUP SUM DIV = gfilter.nc gmt grdfilter ripples.nc \-Ffgfilter.nc \-D0 \-Gsmooth.nc \-V .ft P .fi .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SH LIMITATIONS .INDENT 0.0 .IP 1. 3 To use the \fB\-D\fP5 option the input Mercator grid must be created by img2mercgrd using the \fB\-C\fP option so the origin of the y\-values is the Equator (i.e., x = y = 0 correspond to lon = lat = 0). .IP 2. 3 If the new \fIx_inc\fP, \fIy_inc\fP set with \fB\-I\fP are NOT integer multiples of the increments in the input data, filtering will be considerably slower. [Default increments: Same as input.] .UNINDENT .SH SEE ALSO .sp gmt, grdfft img2grd .SH COPYRIGHT 2019, P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis, and F. Wobbe .\" Generated by docutils manpage writer. .