1GRDFILTER(1)                 Generic Mapping Tools                GRDFILTER(1)
2
3
4

NAME

6       grdfilter - Filter a 2-D grid file in the space (or time) domain
7

SYNOPSIS

9       grdfilter input_file -Ddistance_flag -F<filtertype><width>[mode] -Gout‐
10       put_file  [  -Ixinc[unit][=|+][/yinc[unit][=|+]]  ]  [  -Ni|p|r   ]   [
11       -Rwest/east/south/north[r] ] [ -T ] [ -V ] [ -f[i|o]colinfo ]
12

DESCRIPTION

14       grdfilter  will  filter a .grd file in the time domain using one of the
15       selected convolution or non-convolution isotropic filters  and  compute
16       distances  using  Cartesian  or  Spherical geometries.  The output .grd
17       file can optionally be generated  as  a  subOPT(R)egion  of  the  input
18       and/or  with a new -Increment.  In this way, one may have "extra space"
19       in the input data so that the edges will not be used and the output can
20       be  within  one-half-  width of the input edges.  If the filter is low-
21       pass, then the output may be less frequently sampled than the input.
22
23       input_file
24              The grid 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, where
53              width is 6 times the conventional Gaussian sigma.
54              Non-convolution filters are:
55              (m) Median: Returns median value.
56              (p) Maximum likelihood probability (a  mode  estimator):  Return
57              modal  value.   If  more  than one mode is found we return their
58              average value.  Append - or + to the filter width if you  rather
59              want to return the smallest or largest of the modal values.
60              (l) Lower: Return the minimum of all values.
61              (L) Lower: Return minimum of all positive values only.
62              (u) Upper: Return maximum of all values.
63              (U) Upper: Return maximum or all negative values only.
64              In  the  case of L|U it is possible that no data passes the ini‐
65              tial sign test; in that case the filter will return 0.0.
66
67       -G     output_file is the output grid file of the  filter.   (See  GRID
68              FILE FORMATS below).
69

OPTIONS

71       -I     x_inc  [and  optionally y_inc] is the output Increment. Append m
72              to indicate minutes, or c to  indicate  seconds.   If   the  new
73              x_inc,  y_inc  are NOT integer multiples of the old ones (in the
74              input data), filtering will be considerably  slower.   [Default:
75              Same as input.]
76
77       -N     Determine  how NaN-values in the input grid affects the filtered
78              outout:  Append i to ignore all NaNs in the calculation of  fil‐
79              tered  value  [Default], r is same as i except if the input node
80              was NaN then the output node will be set to NaN (only applies if
81              both  grids  are  coregistered), and p which will force the fil‐
82              tered value to be NaN if  any  grid-nodes  with  NaN-values  are
83              found inside the filter circle.
84
85       -R     west,  east,  south,  and north defines the Region of the output
86              points.  [Default:  Same as input.]
87
88       -T     Toggle the node registration for the output grid so as to become
89              the opposite of the input grid [Default gives the same registra‐
90              tion as the input grid].
91
92       -V     Selects verbose mode, which will send progress reports to stderr
93              [Default runs "silently"].
94
95       -f     Special  formatting of input and/or output columns (time or geo‐
96              graphical data).  Specify i or o to  make  this  apply  only  to
97              input  or  output  [Default  applies to both].  Give one or more
98              columns (or column ranges) separated by commas.  Append T (abso‐
99              lute  calendar time), t (relative time in chosen TIME_UNIT since
100              TIME_EPOCH), x (longitude), y (latitude), or f (floating  point)
101              to  each  column or column range item.  Shorthand -f[i|o]g means
102              -f[i|o]0x,1y (geographic coordinates).
103

GRID FILE FORMATS

105       By default GMT writes out grid as single precision floats in a  COARDS-
106       complaint  netCDF  file  format.   However, GMT is able to produce grid
107       files in many other commonly used grid file formats  and  also  facili‐
108       tates  so called "packing" of grids, writing out floating point data as
109       2- or 4-byte integers. To specify the precision, scale and offset,  the
110       user should add the suffix =id[/scale/offset[/nan]], where id is a two-
111       letter identifier of the grid type and precision, and scale and  offset
112       are  optional scale factor and offset to be applied to all grid values,
113       and nan is the value used  to  indicate  missing  data.   When  reading
114       grids,  the  format  is generally automatically recognized. If not, the
115       same suffix can be added to input grid file names.  See  grdreformat(1)
116       and  Section  4.17 of the GMT Technical Reference and Cookbook for more
117       information.
118
119       When reading a netCDF file that contains multiple grids, GMT will read,
120       by default, the first 2-dimensional grid that can find in that file. To
121       coax GMT into reading another multi-dimensional variable  in  the  grid
122       file,  append  ?varname  to the file name, where varname is the name of
123       the variable. Note that you may need to escape the special meaning of ?
124       in  your  shell  program  by  putting a backslash in front of it, or by
125       placing the filename and suffix between quotes or double  quotes.   The
126       ?varname suffix can also be used for output grids to specify a variable
127       name different from the default: "z".  See grdreformat(1)  and  Section
128       4.18  of the GMT Technical Reference and Cookbook for more information,
129       particularly on how to read splices of 3-, 4-, or 5-dimensional grids.
130

GEOGRAPHICAL AND TIME COORDINATES

132       When the output grid type is netCDF, the coordinates  will  be  labeled
133       "longitude", "latitude", or "time" based on the attributes of the input
134       data or grid (if any) or on the -f or -R  options.  For  example,  both
135       -f0x  -f1t  and  -R90w/90e/0t/3t  will result in a longitude/time grid.
136       When the x, y, or z coordinate is time, it will be stored in  the  grid
137       as  relative  time since epoch as specified by TIME_UNIT and TIME_EPOCH
138       in the .gmtdefaults file or on the command line.  In addition, the unit
139       attribute of the time variable will indicate both this unit and epoch.
140

EXAMPLES

142       Suppose  that  north_pacific_dbdb5.grd is a file of 5 minute bathymetry
143       from 140E to 260E and 0N to 50N, and you want to find  the  medians  of
144       values  within  a 300km radius (600km full width) of the output points,
145       which you choose to be from 150E to 250E and 10N to 40N, and  you  want
146       the  output values every 0.5 degree.  Using spherical distance calcula‐
147       tions, you need:
148
149       grdfilter  north_pacific_dbdb5.grd  -Gfiltered_pacific.grd  -Fm600  -D4
150       -R150/250/10/40 -I0.5 -V
151

LIMITATIONS

153       When  working  with  geographic (lat, lon) grids, all three convolution
154       filters (boxcar, cosine arch, and gaussian) will properly normalize the
155       filter  weights  for  the  variation in gridbox size with latitude, and
156       correctly determine which nodes are needed for the convolution when the
157       filter  "circle" crosses a periodic (0-360) boundary or contains a geo‐
158       graphic pole.  However, the spatial filters, such as  median  and  mode
159       filters,  do  not use weights and thus should only be used on Cartesian
160       grids (or at very low latitudes) only.  If you want to apply such  spa‐
161       tial  filters  you should project your data to an equal-area projection
162       and run grdfilter on the resulting Cartesian grid.
163       To use the -D5 option the  input  Mercator  grid  must  be  created  by
164       img2mercgrd  using  the  -C option so the origin of the y-values is the
165       Equator (i.e., x = y = 0 correspond to lon = lat = 0).
166

SEE ALSO

168       GMT(1), grdfft(1) img2mercgrd(1)
169
170
171
172GMT 4.5.6                         10 Mar 2011                     GRDFILTER(1)
Impressum