1GRDTREND(1)                           GMT                          GRDTREND(1)
2
3
4

NAME

6       grdtrend - Fit trend surface to grids and compute residuals
7

SYNOPSIS

9       grdtrend  grdfile   -Nn_model[+r]  [   -Ddiff.nc  ]  [   -Rregion  ]  [
10       -Ttrend.nc ] [  -Wweight.nc ]
11
12       Note: No space is allowed between the option flag  and  the  associated
13       arguments.
14

DESCRIPTION

16       grdtrend reads a 2-D grid file and fits a low-order polynomial trend to
17       these data by [optionally weighted] least-squares. The trend surface is
18       defined by:
19          m1  + m2*x + m3*y + m4*x*y + m5*x*x + m6*y*y + m7*x*x*x + m8*x*x*y +
20          m9*x*y*y + m10*y*y*y.
21
22       The user must specify -Nn_model, the number of model parameters to use;
23       thus,  -N3  fits  a bilinear trend, -N6 a quadratic surface, and so on.
24       Optionally, append +r to the -N option to perform a robust fit. In this
25       case,  the program will iteratively reweight the data based on a robust
26       scale estimate, in order to converge to a solution insensitive to  out‐
27       liers.  This  may  be  handy  when separating a "regional" field from a
28       "residual" which should have non-zero mean, such as a local mountain on
29       a regional surface.
30
31       If  data  file has values set to NaN, these will be ignored during fit‐
32       ting; if output files are written, these will also have NaN in the same
33       locations.
34

REQUIRED ARGUMENTS

36       grdfile
37              The name of a 2-D binary grid file.
38
39       -Nn_model[+r]
40              n_model  sets  the number of model parameters to fit.  Append +r
41              for robust fit.
42

OPTIONAL ARGUMENTS

44       -Ddiff.nc
45              Write the difference (input data - trend) to the file diff.nc.
46
47       -Rxmin/xmax/ymin/ymax[+r][+uunit] (more ...)
48              Specify the region of interest. Using the -R option will  select
49              a  subsection  of the input grid. If this subsection exceeds the
50              boundaries  of  the  grid,  only  the  common  region  will   be
51              extracted.
52
53       -Ttrend.nc
54              Write the fitted trend to the file trend.nc.
55
56       -V[level] (more ...)
57              Select verbosity level [c].
58
59       -Wweight.nc
60              If  weight.nc  exists,  it  will  be  read  and  used to solve a
61              weighted least-squares problem. [Default: Ordinary least-squares
62              fit.]  If  the robust option has been selected, the weights used
63              in the robust fit will be written to weight.nc.
64
65       -^ or just -
66              Print a short message about the  syntax  of  the  command,  then
67              exits (NOTE: on Windows just use -).
68
69       -+ or just +
70              Print  an extensive usage (help) message, including the explana‐
71              tion of any module-specific  option  (but  not  the  GMT  common
72              options), then exits.
73
74       -? or no arguments
75              Print a complete usage (help) message, including the explanation
76              of all options, then exits.
77

REMARKS

79       The domain of x and y will be shifted and scaled to  [-1,  1]  and  the
80       basis  functions  are  built  from  Legendre  polynomials. These have a
81       numerical advantage in the form of the matrix which  must  be  inverted
82       and  allow  more  accurate solutions. NOTE: The model parameters listed
83       with -V are Legendre polynomial coefficients; they are not  numerically
84       equivalent  to the m#s in the equation described above. The description
85       above is to allow the user to match -N with the order of the polynomial
86       surface.  See  grdmath  if  you  need  to  evaluate the trend using the
87       reported coefficients.
88

GRID FILE FORMATS

90       By default GMT  writes  out  grid  as  single  precision  floats  in  a
91       COARDS-complaint  netCDF  file  format. However, GMT is able to produce
92       grid files in many other commonly  used  grid  file  formats  and  also
93       facilitates  so  called  "packing" of grids, writing out floating point
94       data as 1- or 2-byte integers. (more ...)
95

EXAMPLES

97       To remove a planar  trend  from  hawaii_topo.nc  and  write  result  in
98       hawaii_residual.nc:
99
100              gmt grdtrend hawaii_topo.nc -N3 -Dhawaii_residual.nc
101
102       To  do a robust fit of a bicubic surface to hawaii_topo.nc, writing the
103       result in hawaii_trend.nc and the weights used in hawaii_weight.nc, and
104       reporting the progress:
105
106              gmt grdtrend hawaii_topo.nc -N10+r -Thawaii_trend.nc -Whawaii_weight.nc -V
107

SEE ALSO

109       gmt, grdfft, grdfilter, grdmath
110
112       2019, P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis, and F. Wobbe
113
114
115
116
1175.4.5                            Feb 24, 2019                      GRDTREND(1)
Impressum