1DIMFILTER(1) GMT DIMFILTER(1)
2
3
4
6 dimfilter - Directional filtering of 2-D gridded files in the space (or
7 time) domain
8
10 dimfilter input_file.nc -Ddistance_flag
11 -Fxwidth[mode] -Goutput_file.nc
12 -Nxsectors [ -Qcols ] [ -Iincrement ] [ -Rregion ] [ -T ] [
13 -V[level] ] [ -fflags ]
14
15 Note: No space is allowed between the option flag and the associated
16 arguments.
17
19 dimfilter will filter a .nc file in the space (or time) domain by
20 dividing the given filter circle into n_sectors, applying one of the
21 selected primary convolution or non-convolution filters to each sector,
22 and choosing the final outcome according to the selected secondary fil‐
23 ter. It computes distances using Cartesian or Spherical geometries.
24 The output .nc file can optionally be generated as a subregion of the
25 input and/or with a new -Increment. In this way, one may have "extra
26 space" in the input data so that there will be no edge effects for the
27 output grid. If the filter is low-pass, then the output may be less
28 frequently sampled than the input. -Q is for the error analysis mode
29 and only requires the total number of columns in the input file, which
30 contains the filtered depths. Finally, one should know that dimfilter
31 will not produce a smooth output as other spatial filters do because it
32 returns a minimum median out of N medians of N sectors. The output can
33 be rough unless the input data is noise-free. Thus, an additional fil‐
34 tering (e.g., Gaussian via grdfilter) of the DiM-filtered data is gen‐
35 erally recommended.
36
38 input_file.nc
39 The data grid to be filtered.
40
41 -Ddistance_flag
42 Distance flag tells how grid (x,y) relates to filter width, as
43 follows:
44
45 flag = 0: grid (x,y) same units as width, Cartesian distances.
46 flag = 1: grid (x,y) in degrees, width in kilometers, Cartesian
47 distances. flag = 2: grid (x,y) in degrees, width in km, dx
48 scaled by cos(middle y), Cartesian distances.
49
50 The above options are fastest because they allow weight matrix
51 to be computed only once. The next three options are slower
52 because they recompute weights for each latitude.
53
54 flag = 3: grid (x,y) in degrees, width in km, dx scaled by
55 cosine(y), Cartesian distance calculation.
56
57 flag = 4: grid (x,y) in degrees, width in km, Spherical distance
58 calculation.
59
60 -Fxwidth[mode]
61 Sets the primary filter type. Choose among convolution and
62 non-convolution filters. Append the filter code x followed by
63 the full diameter width. Available convolution filters are:
64
65 (b) Boxcar: All weights are equal.
66
67 (c) Cosine Arch: Weights follow a cosine arch curve.
68
69 (g) Gaussian: Weights are given by the Gaussian function.
70
71 Non-convolution filters are:
72
73 (m) Median: Returns median value.
74
75 (p) Maximum likelihood probability (a mode estimator): Return
76 modal value. If more than one mode is found we return their
77 average value. Append - or + to the filter width if you rather
78 want to return the smallest or largest of the modal values.
79
80 -Nxsectors
81 Sets the secondary filter type x and the number of bow-tie sec‐
82 tors. sectors must be integer and larger than 0. When sectors
83 is set to 1, the secondary filter is not effective. Available
84 secondary filters are:
85
86 (l) Lower: Return the minimum of all filtered values.
87
88 (u) Upper: Return the maximum of all filtered values.
89
90 (a) Average: Return the mean of all filtered values.
91
92 (m) Median: Return the median of all filtered values.
93
94 (p) Mode: Return the mode of all filtered values.
95
96 -Goutput_file.nc
97 output_file.nc is the output of the filter.
98
100 -I x_inc [and optionally y_inc] is the output Increment. Append m
101 to indicate minutes, or c to indicate seconds. If the new x_inc,
102 y_inc are NOT integer multiples of the old ones (in the input
103 data), filtering will be considerably slower. [Default: Same as
104 input.]
105
106 -R west, east, south, and north defines the Region of the output
107 points. [Default: Same as input.]
108
109 -T Toggle the node registration for the output grid so as to become
110 the opposite of the input grid [Default gives the same registra‐
111 tion as the input grid].
112
113 -Qcols cols is the total number of columns in the input text table
114 file. For this mode, it expects to read depths consisted of
115 several columns. Each column represents a filtered grid with a
116 filter width, which can be obtained by grd2xyz -Z. The outcome
117 will be median, MAD, and mean. So, the column with the medians
118 is used to generate the regional component and the column with
119 the MADs is used to conduct the error analysis.
120
121 -V[level] (more ...)
122 Select verbosity level [c].
123
124 -f[i|o]colinfo (more ...)
125 Specify data types of input and/or output columns.
126
127 -^ or just -
128 Print a short message about the syntax of the command, then
129 exits (NOTE: on Windows just use -).
130
131 -+ or just +
132 Print an extensive usage (help) message, including the explana‐
133 tion of any module-specific option (but not the GMT common
134 options), then exits.
135
136 -? or no arguments
137 Print a complete usage (help) message, including the explanation
138 of all options, then exits.
139
141 By default GMT writes out grid as single precision floats in a
142 COARDS-complaint netCDF file format. However, GMT is able to produce
143 grid files in many other commonly used grid file formats and also
144 facilitates so called "packing" of grids, writing out floating point
145 data as 1- or 2-byte integers. (more ...)
146
148 When the output grid type is netCDF, the coordinates will be labeled
149 "longitude", "latitude", or "time" based on the attributes of the input
150 data or grid (if any) or on the -f or -R options. For example, both
151 -f0x -f1t and -R90w/90e/0t/3t will result in a longitude/time grid.
152 When the x, y, or z coordinate is time, it will be stored in the grid
153 as relative time since epoch as specified by TIME_UNIT and TIME_EPOCH
154 in the gmt.conf file or on the command line. In addition, the unit
155 attribute of the time variable will indicate both this unit and epoch.
156
158 Suppose that north_pacific_dbdb5.nc is a file of 5 minute bathymetry
159 from 140E to 260E and 0N to 50N, and you want to find the medians of
160 values within a 300km radius (600km full width) of the output points,
161 which you choose to be from 150E to 250E and 10N to 40N, and you want
162 the output values every 0.5 degree. To prevent the medians from being
163 biased by the sloping plane, you want to divide the filter circle into
164 6 sectors and to choose the lowest value among 6 medians. Using spheri‐
165 cal distance calculations, you need:
166
167 gmt dimfilter north_pacific_dbdb5.nc -Gfiltered_pacific.nc -Fm600 -D4 \
168 -Nl6 -R150/250/10/40 -I0.5 -V
169
170 Suppose that cape_verde.nc is a file of 0.5 minute bathymetry from 32W
171 to 15W and 8N to 25N, and you want to remove small-length-scale fea‐
172 tures in order to define a swell in an area extending from 27.5W to
173 20.5W and 12.5N to 19.5N, and you want the output value every 2 minute.
174 Using cartesian distance calculations, you need:
175
176 gmt dimfilter cape_verde.nc -Gt.nc -Fm220 -Nl8 -D2 -R-27.5/-20.5/12.5/19.5 -I2m -V
177 gmt grdfilter t.nc -Gcape_swell.nc -Fg50 -D2 -V
178
179 Suppose that you found a range of filter widths for a given area, and
180 you filtered the given bathymetric data using the range of filter
181 widths (e.g., f100.nc f110.nc f120.nc f130.nc), and you want to define
182 a regional trend using the range of filter widths, and you want to
183 obtain median absolute deviation (MAD) estimates at each data point.
184 Then, you will need to do:
185
186 gmt grd2xyz f100.nc -Z > f100.d
187 gmt grd2xyz f110.nc -Z > f110.d
188 gmt grd2xyz f120.nc -Z > f120.d
189 gmt grd2xyz f130.nc -Z > f130.d
190 paste f100.d f110.d f120.d f130.d > depths.d
191 gmt dimfilter depths.d -Q4 > output.z
192
194 When working with geographic (lat, lon) grids, all three convolution
195 filters (boxcar, cosine arch, and gaussian) will properly normalize the
196 filter weights for the variation in gridbox size with latitude, and
197 correctly determine which nodes are needed for the convolution when the
198 filter "circle" crosses a periodic (0-360) boundary or contains a geo‐
199 graphic pole. However, the spatial filters, such as median and mode
200 filters, do not use weights and thus should only be used on Cartesian
201 grids (or at very low latitudes) only. If you want to apply such spa‐
202 tial filters you should project your data to an equal-area projection
203 and run dimfilter on the resulting Cartesian grid.
204
206 The dim.template.sh is a skeleton shell script that can be used to set
207 up a complete DiM analysis, including the MAD analysis.
208
210 Kim, S.-S., and Wessel, P. (2008), Directional Median Filtering for
211 Regional-Residual Separation of Bathymetry, Geochem. Geophys.
212 Geosyst., 9, Q03005, doi:10.1029/2007GC001850.
213
215 gmt, grdfilter
216
218 2019, P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis, and F. Wobbe
219
220
221
222
2235.4.5 Feb 24, 2019 DIMFILTER(1)