Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

grdtrack.rst 15 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
  1. .. index:: ! grdtrack
  2. .. include:: module_core_purpose.rst_
  3. ********
  4. grdtrack
  5. ********
  6. |grdtrack_purpose|
  7. Synopsis
  8. --------
  9. .. include:: common_SYN_OPTs.rst_
  10. **gmt grdtrack** [ *trackfile* ] |-G|\ *grd1* |-G|\ *grd2* ...
  11. [ |-A|\ **f**\|\ **p**\|\ **m**\|\ **r**\|\ **R**\ [**+l**] ]
  12. [ |-C|\ *length*/\ *ds*\ [*/spacing*][**+a**\|\ **+v**][**l**\|\ **r**] ]
  13. [ |-D|\ *dfile* ]
  14. [ |-E|\ *line* ]
  15. [ |-F|\ [**+b**][**+n**][**+r**][**+z**\ *z0*] ]
  16. [ |-N| ]
  17. [ |SYN_OPT-R| ]
  18. [ |-S|\ *method*/*modifiers* ]
  19. [ |-T|\ [*radius*][**+e**\|\ **p**]]
  20. [ |-V|\ [*level*] ]
  21. [ |-Z| ]
  22. [ |SYN_OPT-b| ]
  23. [ |SYN_OPT-d| ]
  24. [ |SYN_OPT-e| ]
  25. [ |SYN_OPT-f| ]
  26. [ |SYN_OPT-g| ]
  27. [ |SYN_OPT-h| ]
  28. [ |SYN_OPT-i| ]
  29. [ |SYN_OPT-j| ]
  30. [ |SYN_OPT-n| ]
  31. [ |SYN_OPT-o| ]
  32. [ |SYN_OPT-q| ]
  33. [ |SYN_OPT-s| ]
  34. [ **-:**\ [**i**\|\ **o**] ]
  35. [ |SYN_OPT--| ]
  36. |No-spaces|
  37. Description
  38. -----------
  39. **grdtrack** reads one or more grid files (or a Sandwell/Smith IMG
  40. files) and a table (from file or standard input; but see **-E** for
  41. exception) with (x,y) [or (lon,lat)] positions in the first two columns
  42. (more columns may be present). It interpolates the grid(s) at the
  43. positions in the table and writes out the table with the interpolated
  44. values added as (one or more) new columns. Alternatively (**-C**), the
  45. input is considered to be line-segments and we create orthogonal
  46. cross-profiles at each data point or with an equidistant separation and
  47. sample the grid(s) along these profiles. A bicubic [Default], bilinear,
  48. B-spline or nearest-neighbor (see **-n**) interpolation is used,
  49. requiring boundary conditions at the limits of the region (see **-n**;
  50. Default uses "natural" conditions (second partial derivative normal to
  51. edge is zero) unless the grid is automatically recognized as periodic.)
  52. Required Arguments
  53. ------------------
  54. .. _-G:
  55. **-G**\ *gridfile*
  56. *grdfile* is a 2-D binary grid file with the function f(x,y). If the
  57. specified grid is in Sandwell/Smith Mercator format you must append
  58. a comma-separated list of arguments that includes a scale to
  59. multiply the data (usually 1 or 0.1), the mode which stand for the
  60. following: (0) Img files with no constraint code, returns data at
  61. all points, (1) Img file with constraints coded, return data at all
  62. points, (2) Img file with constraints coded, return data only at
  63. constrained points and NaN elsewhere, and (3) Img file
  64. with constraints coded, return 1 at constraints and 0 elsewhere, and
  65. optionally the max latitude in the IMG file [80.738]. You may repeat
  66. **-G** as many times as you have grids you wish to sample.
  67. Alternatively, use **-G+l**\ *list* to pass a list of file names.
  68. The grids are sampled and results are output in the order given.
  69. (See GRID FILE FORMAT below.)
  70. Optional Arguments
  71. ------------------
  72. *trackfile*
  73. This is an ASCII (or binary, see **-bi**)
  74. file where the first 2 columns hold the (x,y) positions where the
  75. user wants to sample the 2-D data set.
  76. .. _-A:
  77. **-Af**\|\ **p**\|\ **m**\|\ **r**\|\ **R**\ [**+l**]
  78. For track resampling (if **-C** or **-E** are set) we can select how this is to
  79. be performed. Append **f** to keep original points, but add
  80. intermediate points if needed [Default], **m** as **f**, but first
  81. follow meridian (along y) then parallel (along x), **p** as **f**,
  82. but first follow parallel (along y) then meridian (along x), **r**
  83. to resample at equidistant locations; input points are not
  84. necessarily included in the output, and **R** as **r**, but adjust
  85. given spacing to fit the track length exactly. Finally, append
  86. **+l** if geographic distances should be measured along rhumb lines
  87. (loxodromes) instead of great circles. Ignored unless **-C** is used.
  88. .. _-C:
  89. **-C**\ *length*/\ *ds*\ [*/spacing*][**+a**\|\ **+v**][**l**\|\ **r**]
  90. Use input line segments to create an equidistant and (optionally)
  91. equally-spaced set of crossing profiles along which we sample the
  92. grid(s) [Default simply samples the grid(s) at the input locations].
  93. Specify two length scales that control how the sampling is done:
  94. *length* sets the full length of each cross-profile, while *ds* is
  95. the sampling spacing along each cross-profile. Optionally, append
  96. **/**\ *spacing* for an equidistant spacing between cross-profiles
  97. [Default erects cross-profiles at the input coordinates]; see **-A**
  98. for how resampling the input track is controlled. By
  99. default, all cross-profiles have the same direction (left to right
  100. as we look in the direction of the input line segment). Append **+a**
  101. to alternate the direction of cross-profiles, or **v** to enforce
  102. either a "west-to-east" or "south-to-north" view. By default the entire
  103. profiles are output. Choose to only output the left or right halves
  104. of the profiles by appending **+l** or **+r**, respectively. Append suitable units
  105. to *length*; it sets the unit used for *ds* [and *spacing*] (See
  106. `Units`_ below). The default unit for geographic grids is meter while
  107. Cartesian grids implies the user unit. The output columns will be
  108. *lon*, *lat*, *dist*, *azimuth*, *z1*, *z2*, ..., *zn* (The *zi* are
  109. the sampled values for each of the *n* grids)
  110. .. _-D:
  111. **-D**\ *dfile*
  112. In concert with **-C** we can save the (possibly resampled) original
  113. lines to the file *dfile* [Default only saves the cross-profiles].
  114. The columns will be *lon*, *lat*, *dist*, *azimuth*, *z1*, *z2*, ...
  115. (sampled value for each grid)
  116. .. _-E:
  117. **-E**\ *line*\ [,\ *line*,...][**+a**\ *az*][**+c**][**+d**][**+g**][**+i**\ *inc*][**+l**\ *length*][**+n**\ *np*][**+o**\ *az*][**+r**\ *radius*]
  118. Instead of reading input track coordinates, specify profiles via
  119. coordinates and modifiers. The format of each *line* is
  120. *start*/*stop*, where *start* or *stop* are either *lon*/*lat* (*x*/*y* for
  121. Cartesian data) or a 2-character XY key that uses the :doc:`text`-style
  122. justification format to specify a point on the map as
  123. [LCR][BMT]. Each line will be a separate segment unless **+c** is used
  124. which will connect segments with shared joints into a single segment.
  125. In addition to line coordinates, you can use Z-, Z+ to mean the global
  126. minimum and maximum locations in the grid (only available if a
  127. single grid is given via **-G**). You may append
  128. **+i**\ *inc* to set the sampling interval; if not given then
  129. we default to half the minimum grid interval. For a *line* along parallels
  130. or meridians you can add **+g** to report degrees of longitude or latitude
  131. instead of great circle distances starting at zero. Instead of two coordinates
  132. you can specify an origin and one of **+a**, **+o**, or **+r**.
  133. The **+a** sets the azimuth of a profile of given
  134. length starting at the given origin, while **+o** centers the profile
  135. on the origin; both require **+l**. For circular sampling specify
  136. **+r** to define a circle of given radius centered on the origin;
  137. this option requires either **+n** or **+i**. The **+n**\ *np* modifier sets
  138. the desired number of points, while **+l**\ *length* gives the
  139. total length of the profile. Append **+d** to output the along-track
  140. distances after the coordinates. **Note**: No track file will be read.
  141. Also note that only one distance unit can be chosen. Giving different units
  142. will result in an error. If no units are specified we default to
  143. great circle distances in km (if geographic). If working with geographic
  144. data you can use **-j** to control distance calculation mode [Great Circle].
  145. **Note**: If **-C** is set and *spacing* is given the that sampling scheme
  146. overrules any modifier set in **-E**.
  147. .. _-F:
  148. **-F**\ [**+b**][**+n**][**+r**][**+z**\ *z0*]
  149. Find critical points along each cross-profile as a function of along-track distance.
  150. Requires **-C** and a single input grid (*z*). We examine each cross-profile generated
  151. and report (*dist*, *lonc*, *latc*, *distc*, *azimuthc*, *zc*) at the center peak of
  152. maximum *z* value, (*lonl*, *latl*, *distl*) and (*lonr*, *latr*, *distr*)
  153. at the first and last non-NaN point whose *z*-value exceeds *z0*, respectively,
  154. and the *width* based on the two extreme points found. Here, *dist* is the distance
  155. along the original input *trackfile* and the other 12 output columns are a function
  156. of that distance. When searching for the center peak and the extreme first and last
  157. values that exceed the threshold we assume the profile is positive up. If we instead
  158. are looking for a trough then you must use **+n** to temporarily flip the profile to
  159. positive. The threshold *z0* value is always given as >= 0; use **+z** to change it [0].
  160. Alternatively, use **+b** to determine the balance point and standard deviation of the
  161. profile; this is the weighted mean and weighted standard deviation of the distances,
  162. with *z* acting as the weight. Finally, use **+r** to obtain the weighted rms about the
  163. cross-track center (*distc* == 0). **Note**: We round the exact results to the nearest
  164. distance nodes along the cross-profiles. We write 13 output columns per track:
  165. *dist, lonc, latc, distc, azimuthc, zc, lonl, latl, distl, lonr, latr, distr, width*.
  166. .. _-N:
  167. **-N**
  168. Do *not* skip points that fall outside the domain of the grid(s)
  169. [Default only output points within grid domain].
  170. .. _-R:
  171. .. |Add_-R| unicode:: 0x20 .. just an invisible code
  172. .. include:: explain_-R.rst_
  173. .. _-S:
  174. **-S**\ *method*/*modifiers*
  175. In conjunction with **-C**, compute a single stacked profile from
  176. all profiles across each segment. Append how stacking should be
  177. computed: **a** = mean (average), **m** = median, **p** = mode
  178. (maximum likelihood), **l** = lower, **L** = lower but only consider
  179. positive values, **u** = upper, **U** = upper but only consider
  180. negative values [**a**]. The *modifiers* control the output;
  181. choose one or more among these choices: **+a** : Append stacked
  182. values to all cross-profiles. **+d** : Append stack deviations to
  183. all cross-profiles. **+r** : Append data residuals (data - stack) to
  184. all cross-profiles. **+s**\ [*file*] : Save stacked profile to
  185. *file* [grdtrack_stacked_profile.txt]. **+c**\ *fact* : Compute
  186. envelope on stacked profile as ±\ *fact* \*\ *deviation* [2].
  187. Notes: (1) Deviations depend on *method* and are st.dev (**a**), L1
  188. scale, i.e., 1.4826 \* median absolute deviation (MAD) (for **m** and **p**), or half-range (upper-lower)/2. (2) The
  189. stacked profile file contains a leading column plus groups of 4-6 columns, with one
  190. group for each sampled grid. The leading column holds cross distance,
  191. while the first four columns in a group hold stacked value, deviation, min
  192. value, and max value, respectively. If *method* is one of
  193. **a**\|\ **m**\|\ **p** then we also write the lower and upper
  194. confidence bounds (see **+c**). When one or more of **+a**, **+d**,
  195. and **+r** are used then we also append the stacking results to the end of each
  196. row, for all cross-profiles. The order is always stacked value
  197. (**+a**), followed by deviations (**+d**) and finally residuals (**+r**).
  198. When more than one grid is sampled this sequence of 1-3 columns is
  199. repeated for each grid.
  200. .. _-T:
  201. **-T**\ [*radius*][**+e**\|\ **p**]
  202. To be used with normal grid sampling, and limited to a single, non-IMG grid.
  203. If the nearest node to the input point is NaN, search outwards until we find
  204. the nearest non-NaN node and report that value instead. Optionally specify
  205. a search radius which limits the consideration to points within this distance
  206. from the input point. To report the location of the nearest node and its
  207. distance from the input point, append **+e**. The default unit for geographic
  208. grid distances is spherical degrees. Use *radius* to change the unit
  209. and give *radius* = 0 if you do not want to limit the radius search.
  210. To instead replace the input point with the coordinates of the nearest node, append **+p**.
  211. .. _-V:
  212. .. |Add_-V| unicode:: 0x20 .. just an invisible code
  213. .. include:: explain_-V.rst_
  214. .. _-Z:
  215. **-Z**
  216. Only write out the sampled z-values [Default writes all columns].
  217. **-:**
  218. Toggles between (longitude,latitude) and (latitude,longitude)
  219. input/output. [Default is (longitude,latitude)].
  220. .. |Add_-bi| replace:: [Default is 2 input columns].
  221. .. include:: explain_-bi.rst_
  222. .. |Add_-bo| replace:: [Default is one more than input].
  223. .. include:: explain_-bo.rst_
  224. .. |Add_-d| unicode:: 0x20 .. just an invisible code
  225. .. include:: explain_-d.rst_
  226. .. |Add_-e| unicode:: 0x20 .. just an invisible code
  227. .. include:: explain_-e.rst_
  228. .. |Add_-f| unicode:: 0x20 .. just an invisible code
  229. .. include:: explain_-f.rst_
  230. .. |Add_-g| unicode:: 0x20 .. just an invisible code
  231. .. include:: explain_-g.rst_
  232. .. |Add_-h| unicode:: 0x20 .. just an invisible code
  233. .. include:: explain_-h.rst_
  234. .. include:: explain_-icols.rst_
  235. .. include:: explain_distcalc.rst_
  236. .. include:: explain_-n.rst_
  237. .. include:: explain_-ocols.rst_
  238. .. include:: explain_-q.rst_
  239. .. include:: explain_-s.rst_
  240. .. include:: explain_help.rst_
  241. .. include:: explain_distunits.rst_
  242. .. include:: explain_precision.rst_
  243. .. include:: explain_grd_inout_short.rst_
  244. .. include:: explain_grdresample2.rst_
  245. Hints
  246. -----
  247. If an interpolation point is not on a node of the input grid, then a NaN
  248. at any node in the neighborhood surrounding the point will yield an
  249. interpolated NaN. Bicubic interpolation [default] yields continuous
  250. first derivatives but requires a neighborhood of 4 nodes by 4 nodes.
  251. Bilinear interpolation [**-n**] uses only a 2 by 2 neighborhood, but
  252. yields only zeroth-order continuity. Use bicubic when smoothness is
  253. important. Use bilinear to minimize the propagation of NaNs, or lower
  254. *threshold*.
  255. Examples
  256. --------
  257. .. include:: explain_example.rst_
  258. To extract a profile along a great circle between (0,0) to (20,20) from the remote grid earth_relief_05m,
  259. and only write out (dist, topo) records, try::
  260. gmt grdtrack -G@earth_relief_05m -R0/20/0/20 -EBL/TR+d -o3,2 > profile.txt
  261. To sample the file hawaii_topo.nc along the SEASAT track track_4.xyg
  262. (An ASCII table containing longitude, latitude, and SEASAT-derived
  263. gravity, preceded by one header record)::
  264. grdtrack track_4.xyg -Ghawaii_topo.nc -h > track_4.xygt
  265. To sample the Sandwell/Smith IMG format file topo.8.2.img (2 minute
  266. predicted bathymetry on a Mercator grid) and the Muller et al age grid
  267. age.3.2.nc along the lon,lat coordinates given in the file
  268. cruise_track.xy, try::
  269. grdtrack cruise_track.xy -Gtopo.8.2.img,1,1 -Gage.3.2.nc > depths-age.d
  270. To sample the Sandwell/Smith IMG format file grav.18.1.img (1 minute
  271. free-air anomalies on a Mercator grid) along 100-km-long cross-profiles
  272. that are orthogonal to the line segment given in the file track.xy,
  273. erecting cross-profiles every 25 km and sampling the grid every 3 km, try
  274. ::
  275. grdtrack track.xy -Ggrav.18.1.img,0.1,1 -C100k/3/25 -Ar > xprofiles.txt
  276. The same thing, but now determining the central anomaly location along track,
  277. with a threshold of 25 mGal, try::
  278. grdtrack track.xy -Ggrav.18.1.img,0.1,1 -C100k/3/25 -F+z25 > locations.txt
  279. To sample the grid data.nc along a line from the lower left to the upper
  280. right corner, using a grid spacing of 1 km on the geodesic, and output distances as well,
  281. try::
  282. gmt grdtrack -ELB/RT+i1k+d -Gdata.nc -je > profiles.txt
  283. See Also
  284. --------
  285. :doc:`gmt`,
  286. :doc:`gmtconvert`,
  287. :doc:`text`,
  288. :doc:`sample1d`,
  289. :doc:`surface`
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...