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

grdinterpolate.rst 10 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
  1. .. index:: ! grdinterpolate
  2. .. include:: module_core_purpose.rst_
  3. **************
  4. grdinterpolate
  5. **************
  6. |grdinterpolate_purpose|
  7. Synopsis
  8. --------
  9. .. include:: common_SYN_OPTs.rst_
  10. **gmt grdinterpolate** *3Dgrid* | *grd1 grd2 ...*
  11. |-G|\ *outfile*
  12. |-T|\ [*min/max*\ /]\ *inc*\ [**+n**] \|\ |-T|\ *file*\|\ *list*
  13. [ |-E|\ *table*\|\ *line* ]
  14. [ |-F|\ **l**\|\ **a**\|\ **c**\|\ **n**\ [**+1**\|\ **2**] ]
  15. [ |SYN_OPT-R| ]
  16. [ |-S|\ *x/y*\|\ *pointfile*\ [**+h**\ *header*] ]
  17. [ |SYN_OPT-V| ]
  18. [ |-Z|\ **i**\ *levels*\|\ **o** ]
  19. [ |SYN_OPT-b| ]
  20. [ |SYN_OPT-d| ]
  21. [ |SYN_OPT-e| ]
  22. [ |SYN_OPT-f| ]
  23. [ |SYN_OPT-g| ]
  24. [ |SYN_OPT-h| ]
  25. [ |SYN_OPT-i| ]
  26. [ |SYN_OPT-n| ]
  27. [ |SYN_OPT-o| ]
  28. [ |SYN_OPT-q| ]
  29. [ |SYN_OPT-s| ]
  30. [ **-:**\ [**i**\|\ **o**] ]
  31. [ |SYN_OPT--| ]
  32. |No-spaces|
  33. Description
  34. -----------
  35. **grdinterpolate** reads a single 3-D netCDF data cube (or a set of 2-D layers)
  36. and interpolates along the 3rd dimension for one or more output levels. The data cube must
  37. be organized with one or more layers representing the *x* and *y* dimensions
  38. while the 3rd dimension may represent distance or time; we refer to this
  39. dimension as the *level*. The output layers may be written as a single 3-D cube
  40. or as a set of 2-D layers. Alternatively, we interpolate the cube along the level-axis
  41. at one or more arbitrary (*x/y*) coordinates (**-S**), resulting in a data table with one or
  42. more level-series, or we slice the 3-D cube along an arbitrary vertical slice and write that
  43. 2-D slice to a grid file (**-E**).
  44. Required Arguments
  45. ------------------
  46. *3Dgrid*
  47. Name of a 3-D netCDF data cube to be interpolated. Alternatively, with **-Zi**,
  48. you can specify a set of 2-D grid layers instead.
  49. .. _-G:
  50. **-G**\ *outfile*
  51. This is the output 3D data cube file. If **-T** only selects a
  52. single layer then the data cube collapses to a regular 2-D grid file.
  53. If **-Zo** is used then *outfile* must contain a C-format statement
  54. for a floating point number. Also see **-S** for a similar use to
  55. write individual level-series tables.
  56. .. _-T:
  57. **-T**\ [*min/max*\ /]\ *inc*\ [**+n**] \|\ |-T|\ *file*\|\ *list*
  58. Make evenly spaced time-steps from *min* to *max* by *inc* [Default uses input times].
  59. For details on array creation, see `Generate 1D Array`_.
  60. Optional Arguments
  61. ------------------
  62. .. _-E:
  63. **-E**\ *table*\|\ *line*\ [,\ *line*,...][**+a**\ *az*][**+g**][**+i**\ *inc*][**+l**\ *length*][**+n**\ *np*][**+o**\ *az*][**+p**][**+r**\ *radius*][**+x**]
  64. Specify a crossectinonal profile via a *file* or from specified *line* coordinates and modifiers.
  65. If a *file*, it must be contain a single segment with either *lon lat* or *lon lat dist* records.
  66. These must be equidistant. Alternatively, the format of each *line* is
  67. *start*/*stop*, where *start* or *stop* are *lon*/*lat* (*x*/*y* for
  68. Cartesian data). You may append **+i**\ *inc* to set the sampling interval;
  69. if not given then we default to half the minimum grid interval. If your *line* starts and
  70. ends at the same latitude you can force sampling along the parallel with **+p** [great circle].
  71. For a *line* along parallels or meridians you can add **+g** to report degrees of longitude or latitude
  72. instead of great circle distances starting at zero. Append **+x** to compute distances
  73. along a loxodrome (rhumbline) instead of great circle. Instead of two coordinates
  74. you can specify an origin and one of **+a**, **+o**, or **+r**.
  75. The **+a** sets the azimuth of a profile of given
  76. length starting at the given origin, while **+o** centers the profile
  77. on the origin; both require **+l**. For circular sampling specify
  78. **+r** to define a circle of given radius centered on the origin;
  79. this option requires either **+n** or **+i**. The **+n**\ *np* modifier sets
  80. the desired number of points, while **+l**\ *length* gives the
  81. total length of the profile.
  82. Also note that only one distance unit can be chosen. Giving different units
  83. will result in an error. If no units are specified we default to
  84. great circle distances in km (if geographic). If working with geographic
  85. data you can use **-j** to control distance calculation mode [Great Circle].
  86. Use **-G** to set the output grid file name.
  87. .. _-F:
  88. **-Fl**\|\ **a**\|\ **c**\|\ **n**\ [**+1**\|\ **2**]
  89. Choose from **l** (Linear), **a** (Akima spline), **c** (natural
  90. cubic spline), and **n** (no interpolation: nearest point) [Default
  91. is **-Fa**]. You may change the default interpolant; see
  92. :term:`GMT_INTERPOLANT` in your :doc:`gmt.conf` file.
  93. You may optionally evaluate the first or second derivative of the spline
  94. by appending **+1** or **+2**, respectively.
  95. .. _-R:
  96. .. |Add_-R| replace:: Using the **-R** option
  97. will select a subsection of the grid. If this subsection exceeds the
  98. boundaries of the grid, only the common region will be output.
  99. .. include:: explain_-R.rst_
  100. .. _-S:
  101. **-S**\ *x/y*\|\ *pointfile*\ [**+h**\ *header*]
  102. Rather that compute gridded output, create tile/spatial series through the stacked
  103. grids at the given point (*x/y*) or the list of points in *pointfile*. If you need
  104. a series of points defined by an origin and an end point or similar, you can make
  105. such a file first with :doc:`project`. By default we simply sample the cube at
  106. each level. Use **-T** to interpolate the series. The grid level (e.g., depth or time)
  107. will be appended as the last numerical value in the series records. Use the optional
  108. **+h** modifier to append *header* to the trailing text of these input points.
  109. On output the trailing text will become the segment header for the series that originate
  110. from each point. By default, the table output is written to standard output. Use **-G**
  111. to specify a file name. Alternatively, if you wish each series to be written to its own
  112. data file, let the filename in **-G** have a C-format integer specifier (e.g., %d) and we
  113. will use the running point number to create unique file names.
  114. .. _-V:
  115. .. |Add_-V| unicode:: 0x20 .. just an invisible code
  116. .. include:: explain_-V.rst_
  117. .. _-Z:
  118. **-Zi**\ *levels*\|\ **o**
  119. Use **-Zi** to obtain the *levels* and then we read the corresponding number of
  120. 2-D input grids given on the command line [Default is a single 3-D data cube].
  121. The *levels* are specified the same way as in **-T**.
  122. Use **-Zo** to write the 3-D data cube as a series of 2-D grids instead. If used,
  123. then the *outgrid* name given by **-G** must contain a C-language format statement
  124. for a floating point number (for instance, one can try layer_%6.6f.grd) which will contain the level
  125. for each grid [Default is a 3-D data cube, unless only one layer is implied by **-T**].
  126. **-:**
  127. Toggles between (longitude,latitude) and (latitude,longitude)
  128. input/output in **-S**\ *table*. [Default is (longitude,latitude)].
  129. .. |Add_-bi| replace:: [Default is 2 input columns].
  130. .. include:: explain_-bi.rst_
  131. .. |Add_-bo| replace:: [Default is one more than input].
  132. .. include:: explain_-bo.rst_
  133. .. |Add_-d| unicode:: 0x20 .. just an invisible code
  134. .. include:: explain_-d.rst_
  135. .. |Add_-e| unicode:: 0x20 .. just an invisible code
  136. .. include:: explain_-e.rst_
  137. .. |Add_-f| unicode:: 0x20 .. just an invisible code
  138. .. include:: explain_-f.rst_
  139. .. |Add_-g| unicode:: 0x20 .. just an invisible code
  140. .. include:: explain_-g.rst_
  141. .. |Add_-h| unicode:: 0x20 .. just an invisible code
  142. .. include:: explain_-h.rst_
  143. .. include:: explain_-icols.rst_
  144. .. include:: explain_-n.rst_
  145. .. include:: explain_-ocols.rst_
  146. .. include:: explain_-q.rst_
  147. .. include:: explain_-s.rst_
  148. .. include:: explain_help.rst_
  149. .. include:: explain_array.rst_
  150. File Order
  151. ----------
  152. If you provide a series of 2-D files and thus separately assigning the
  153. level via **-Zi**, then you must make sure that the order the grids are given
  154. on the command line matches the levels you provide via **-Zi**. Unless your
  155. files are named in lexical order you must be careful with using wildcards
  156. to list all the grids (e.g., \*.nc).
  157. Time Coordinates
  158. ----------------
  159. Time coordinates in netCDF grids, be it the x, y, or z coordinate, will
  160. be recognized as such. The variable's **unit** attribute is parsed to
  161. determine the unit and epoch of the time coordinate in the grid. Values
  162. are then converted to the internal time system specified by
  163. :term:`TIME_UNIT` and :term:`TIME_EPOCH` in the
  164. :doc:`gmt.conf` file or on the
  165. command line. The default output is relative time in that time system,
  166. or absolute time when using the option **-f0T**, **-f1T**, or **-f2T**
  167. for x, y, or z coordinate, respectively.
  168. Series creation
  169. ---------------
  170. The (optional) table-reading and table-producing **-S** option may require some
  171. of the standard common options associated with table i/o, such as **-b**, **-i**,
  172. **o**, etc., thus these options are available to **grdinterpolate** as well.
  173. Because the coordinates given via **-S** are *not* required to equal the coordinates
  174. of the grid nodes, we are resampling each 2-D layer at the given points via
  175. :doc:`grdtrack`, hence the availability of the **-n** option.
  176. Examples
  177. --------
  178. To extract a single, new 2-D layer from the temperature.nc 3-D cube for level 3400
  179. using a cubic spline, try::
  180. gmt grdinterpolate temperature.nc -T3400 -Fc -Gtemp_3400.nc
  181. To extract a single, new 2-D layer from the 3-D cube implied by the individual grids
  182. layers_*.nc, with individual layer values given via z.txt, for level 3400
  183. using a linear spline, try::
  184. gmt grdinterpolate layers_*.nc -Ziz.txt -T3400 -Fl -Gtemp_3400.nc
  185. To resample the the temperature.nc 3-D cube for all levels from
  186. 1500 to 2500 in steps of 50, using an Akima spline, try::
  187. gmt grdinterpolate temperature.nc -T1500/2500/50 -Gtemperature_1500_2500.nc -Fa
  188. The same, but this time write individual 2-D grids per layer, try::
  189. gmt grdinterpolate temperature.nc -T1500/2500/50 -Gtemperature_%4.0f.nc -Fa -Zo
  190. To extract a time-series through the grids deformation_*.nc at the location (115W, 33N),
  191. with the times of each grid provided by the file dates.txt, and append the string
  192. "Some like it hot" to the segment header for the series, try::
  193. gmt grdinterpolate deformation_*.nc -Zidates.txt -S115W/33N+h"Some like it hot" > record.txt
  194. To extract a vertical slice of the 3-D grid S362ANI_kmps.nc with seismic velocities that goes
  195. through the Hawaii hotspot, selecting cube vs (Isotropic Shear Velocity) and letting the
  196. distances be longitude degrees along the parallel, try::
  197. gmt grdinterpolate S362ANI_kmps.nc?vs -E180/20/220/20+i1d+g+p -T25/500/25 -Gslice.nc
  198. See Also
  199. --------
  200. :doc:`gmt.conf`,
  201. :doc:`gmt`,
  202. :doc:`grdedit`,
  203. :doc:`grdcut`,
  204. :doc:`project`
Tip!

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

Comments

Loading...