1GRDFILTER(1) Generic Mapping Tools GRDFILTER(1)
2
3
4
6 grdfilter - Filter a 2-D gridded file in the space (or time) domain
7
9 grdfilter input_file.grd -Ddistance_flag -F<filtertype><width>[mode]
10 -Goutput_file.grd [ -Ixinc[unit][=|+][/yinc[unit][=|+]] ] [
11 -Rwest/east/south/north[r] ] [ -T ] [ -V ] [ -f[i|o]colinfo ]
12
14 grdfilter will filter a .grd file in the time domain using one of the
15 selected convolution or non-convolution filters and compute distances
16 using Cartesian or Spherical geometries. The output .grd file can
17 optionally be generated as a sub-Region of the input and/or with a new
18 -Increment. In this way, one may have "extra space" in the input data
19 so that the edges will not be used and the output can be within one-
20 half- width of the input edges. If the filter is low-pass, then the
21 output may be less frequently sampled than the input.
22
23 input_file.grd
24 The file of points to be filtered. (See GRID FILE FORMATS
25 below).
26
27 -D Distance flag tells how grid (x,y) relates to filter width as
28 follows:
29
30 flag = 0: grid (x,y) same units as width, Cartesian distances.
31 flag = 1: grid (x,y) in degrees, width in kilometers, Cartesian
32 distances.
33 flag = 2: grid (x,y) in degrees, width in km, dx scaled by
34 cos(middle y), Cartesian distances.
35
36 The above options are fastest because they allow weight matrix
37 to be computed only once. The next three options are slower
38 because they recompute weights for each latitude.
39
40 flag = 3: grid (x,y) in degrees, width in km, dx scaled by
41 cosine(y), Cartesian distance calculation.
42 flag = 4: grid (x,y) in degrees, width in km, Spherical dis‐
43 tance calculation.
44 flag = 5: grid (x,y) in Mercator -Jm1 img units, width in km,
45 Spherical distance calculation.
46
47 -F Sets the filter type. Choose among convolution and non-convolu‐
48 tion filters. Append the filter code followed by the full diam‐
49 eter width. Available convolution filters are:
50 (b) Boxcar: All weights are equal.
51 (c) Cosine Arch: Weights follow a cosine arch curve.
52 (g) Gaussian: Weights are given by the Gaussian function.
53 Non-convolution filters are:
54 (m) Median: Returns median value.
55 (p) Maximum likelihood probability (a mode estimator): Return
56 modal value. If more than one mode is found we return their
57 average value. Append - or + to the filter width if you rather
58 want to return the smallest or largest of the modal values.
59 (l) Lower: Return the minimum of all values.
60 (L) Lower: Return minimum of all positive values only.
61 (u) Upper: Return maximum of all values.
62 (U) Upper: Return maximum or all negative values only.
63 In the case of L|U it is possible that no data passes the ini‐
64 tial sign test; in that case the filter will return 0.0.
65
66 -G output_file.grd is the output of the filter. (See GRID FILE
67 FORMATS below).
68
70 -I x_inc [and optionally y_inc] is the output Increment. Append m
71 to indicate minutes, or c to indicate seconds. If the new
72 x_inc, y_inc are NOT integer multiples of the old ones (in the
73 input data), filtering will be considerably slower. [Default:
74 Same as input.]
75
76 -R west, east, south, and north defines the Region of the output
77 points. [Default: Same as input.]
78
79 -T Toggle the node registration for the output grid so as to become
80 the opposite of the input grid [Default gives the same registra‐
81 tion as the input grid].
82
83 -V Selects verbose mode, which will send progress reports to stderr
84 [Default runs "silently"].
85
86 -f Special formatting of input and/or output columns (time or geo‐
87 graphical data). Specify i or o to make this apply only to
88 input or output [Default applies to both]. Give one or more
89 columns (or column ranges) separated by commas. Append T (abso‐
90 lute calendar time), t (relative time in chosen TIME_UNIT since
91 TIME_EPOCH), x (longitude), y (latitude), or f (floating point)
92 to each column or column range item. Shorthand -f[i|o]g means
93 -f[i|o]0x,1y (geographic coordinates).
94
96 By default GMT writes out grid as single precision floats in a COARDS-
97 complaint netCDF file format. However, GMT is able to produce grid
98 files in many other commonly used grid file formats and also facili‐
99 tates so called "packing" of grids, writing out floating point data as
100 2- or 4-byte integers. To specify the precision, scale and offset, the
101 user should add the suffix =id[/scale/offset[/nan]], where id is a two-
102 letter identifier of the grid type and precision, and scale and offset
103 are optional scale factor and offset to be applied to all grid values,
104 and nan is the value used to indicate missing data. When reading
105 grids, the format is generally automatically recognized. If not, the
106 same suffix can be added to input grid file names. See grdreformat(1)
107 and Section 4.17 of the GMT Technical Reference and Cookbook for more
108 information.
109
110 When reading a netCDF file that contains multiple grids, GMT will read,
111 by default, the first 2-dimensional grid that can find in that file. To
112 coax GMT into reading another multi-dimensional variable in the grid
113 file, append ?varname to the file name, where varname is the name of
114 the variable. Note that you may need to escape the special meaning of ?
115 in your shell program by putting a backslash in front of it, or by
116 placing the filename and suffix between quotes or double quotes. The
117 ?varname suffix can also be used for output grids to specify a variable
118 name different from the default: "z". See grdreformat(1) and Section
119 4.18 of the GMT Technical Reference and Cookbook for more information,
120 particularly on how to read splices of 3-, 4-, or 5-dimensional grids.
121
123 When the output grid type is netCDF, the coordinates will be labeled
124 "longitude", "latitude", or "time" based on the attributes of the input
125 data or grid (if any) or on the -f or -R options. For example, both
126 -f0x -f1t and -R90w/90e/0t/3t will result in a longitude/time grid.
127 When the x, y, or z coordinate is time, it will be stored in the grid
128 as relative time since epoch as specified by TIME_UNIT and TIME_EPOCH
129 in the .gmtdefaults file or on the command line. In addition, the unit
130 attribute of the time variable will indicate both this unit and epoch.
131
133 Suppose that north_pacific_dbdb5.grd is a file of 5 minute bathymetry
134 from 140E to 260E and 0N to 50N, and you want to find the medians of
135 values within a 300km radius (600km full width) of the output points,
136 which you choose to be from 150E to 250E and 10N to 40N, and you want
137 the output values every 0.5 degree. Using spherical distance calcula‐
138 tions, you need:
139
140 grdfilter north_pacific_dbdb5.grd -Gfiltered_pacific.grd -Fm600 -D4
141 -R150/250/10/40 -I0.5 -V
142
144 When working with geographic (lat, lon) grids, all three convolution
145 filters (boxcar, cosine arch, and gaussian) will properly normalize the
146 filter weights for the variation in gridbox size with latitude, and
147 correctly determine which nodes are needed for the convolution when the
148 filter "circle" crosses a periodic (0-360) boundary or contains a geo‐
149 graphic pole. However, the spatial filters, such as median and mode
150 filters, do not use weights and thus should only be used on Cartesian
151 grids (or at very low latitudes) only. If you want to apply such spa‐
152 tial filters you should project your data to an equal-area projection
153 and run grdfilter on the resulting Cartesian grid.
154 To use the -D5 option the input Mercator grid must be created by
155 img2mercgrd using the -C option so the origin of the y-values is the
156 Equator (i.e., x = y = 0 correspond to lon = lat = 0).
157
159 GMT(1), grdfft(1) img2mercgrd(1)
160
161
162
163GMT 4.3.1 15 May 2008 GRDFILTER(1)