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

sample1d.rst 6.6 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
  1. .. index:: ! sample1d
  2. .. include:: module_core_purpose.rst_
  3. ********
  4. sample1d
  5. ********
  6. |sample1d_purpose|
  7. Synopsis
  8. --------
  9. .. include:: common_SYN_OPTs.rst_
  10. **gmt sample1d** [ *table* ]
  11. [ |-A|\ **f**\|\ **p**\|\ **m**\|\ **r**\|\ **R**\ [**+l**] ]
  12. [ |-F|\ **l**\|\ **a**\|\ **c**\|\ **n**\|\ **s**\ *p*\ [**+d1**\|\ **2**] ]
  13. [ |-N|\ *col* ]
  14. [ |-T|\ [*min/max*\ /]\ *inc*\ [**+a**\|\ **n**] \|\ |-T|\ *file*\|\ *list* ]
  15. [ |SYN_OPT-V| ]
  16. [ |-W|\ *col* ]
  17. [ |SYN_OPT-b| ]
  18. [ |SYN_OPT-d| ]
  19. [ |SYN_OPT-e| ]
  20. [ |SYN_OPT-f| ]
  21. [ |SYN_OPT-g| ]
  22. [ |SYN_OPT-h| ]
  23. [ |SYN_OPT-i| ]
  24. [ |SYN_OPT-j| ]
  25. [ |SYN_OPT-o| ]
  26. [ |SYN_OPT-q| ]
  27. [ |SYN_OPT-:| ]
  28. [ |SYN_OPT--| ]
  29. |No-spaces|
  30. Description
  31. -----------
  32. **sample1d** reads a multi-column ASCII [or binary] data set from file
  33. [or standard input] and interpolates the time-series or spatial profile at locations
  34. where the user needs the values. The user must provide the column number
  35. of the independent (monotonically increasing **or** decreasing)
  36. variable, here called *time* (it may of course be any type of quantity) when that is not the first column in data set.
  37. Equidistant or arbitrary sampling can be selected. All columns
  38. are resampled based on the new sampling interval. Several interpolation
  39. schemes are available, in addition to a *smoothing* spline which trades off misfit
  40. for curvature. Extrapolation outside the range of the input data
  41. is not supported.
  42. Required Arguments
  43. ------------------
  44. None.
  45. Optional Arguments
  46. ------------------
  47. *table*
  48. This is one or more ASCII [of binary, see
  49. **-bi**] files with one column containing the
  50. independent *time* variable (which must be monotonically in/de-creasing)
  51. and the remaining columns holding other data values. If no file is
  52. provided, **sample1d** reads from standard input.
  53. .. _-A:
  54. **-A**\ **f**\|\ **p**\|\ **m**\|\ **r**\|\ **R**
  55. For track resampling (if **-T**...\ *unit* is set) we can select how
  56. this is to be performed. Append **f** to keep original points, but
  57. add intermediate points if needed; note this selection does not
  58. necessarily yield equidistant points [Default], **m** as **f**, but
  59. first follow meridian (along y) then parallel (along x), **p** as
  60. **f**, but first follow parallel (along y) then meridian (along x),
  61. **r** to resample at equidistant locations; input points are not
  62. necessarily included in the output, and **R** as **r**, but adjust
  63. given spacing to fit the track length exactly. Finally, append
  64. **+l** if distances should be measured along rhumb lines (loxodromes).
  65. .. _-F:
  66. **-Fl**\|\ **a**\|\ **c**\|\ **n**\ **s**\ *p*\ [**+d1**\|\ **2**]
  67. Choose from **l** (Linear), **a** (Akima spline), **c** (natural
  68. cubic spline), **n** (no interpolation: nearest point), or **s**
  69. (smoothing cubic spline; append fit parameter *p*) [Default
  70. is **-Fa**]. You may change the default interpolant; see
  71. :term:`GMT_INTERPOLANT` in your :doc:`gmt.conf` file.
  72. You may optionally evaluate the first or second derivative of the spline
  73. by appending **+d1** or **+d2**, respectively.
  74. .. _-N:
  75. **-N**\ *col*
  76. Sets the column number of the independent *time* variable [Default is 0
  77. (first)].
  78. .. _-T:
  79. **-T**\ [*min/max*\ /]\ *inc*\ [**+a**\|\ **n**] \|\ |-T|\ *file*\|\ *list*
  80. Make evenly spaced time-steps from *min* to *max* by *inc* [Default uses input times].
  81. For details on array creation, see `Generate 1D Array`_.
  82. .. _-V:
  83. .. |Add_-V| unicode:: 0x20 .. just an invisible code
  84. .. include:: explain_-V.rst_
  85. .. _-W:
  86. **-W**\ *col*
  87. Sets the column number of the weights to be used with a smoothing cubic
  88. spline. Requires **-Fs**.
  89. .. |Add_-bi| replace:: [Default is 2 (or at least the number of columns implied by **-T**)].
  90. .. include:: explain_-bi.rst_
  91. .. |Add_-bo| replace:: [Default is same as input].
  92. .. include:: explain_-bo.rst_
  93. .. |Add_-d| unicode:: 0x20 .. just an invisible code
  94. .. include:: explain_-d.rst_
  95. .. |Add_-e| unicode:: 0x20 .. just an invisible code
  96. .. include:: explain_-e.rst_
  97. .. |Add_-f| unicode:: 0x20 .. just an invisible code
  98. .. include:: explain_-f.rst_
  99. .. |Add_-g| unicode:: 0x20 .. just an invisible code
  100. .. include:: explain_-g.rst_
  101. .. |Add_-h| unicode:: 0x20 .. just an invisible code
  102. .. include:: explain_-h.rst_
  103. .. include:: explain_-icols.rst_
  104. .. include:: explain_-q.rst_
  105. .. include:: explain_distcalc.rst_
  106. .. include:: explain_-ocols.rst_
  107. .. include:: explain_help.rst_
  108. .. include:: explain_distunits.rst_
  109. .. include:: explain_precision.rst_
  110. .. include:: explain_array.rst_
  111. Notes
  112. -----
  113. The smoothing spline *s(t)* requires a fit parameter *p* that allows for the trade-off between an
  114. exact interpolation (fitting the data exactly; large *p*) to minimizing curvature (*p* approaching 0).
  115. Specifically, we seek to minimize
  116. .. math::
  117. F_p (s)= K (s) + p E (s), \quad p > 0,
  118. where the misfit is evaluated as
  119. .. math::
  120. E (s)= \sum^n_{i=1} \left [ \frac{s(t_i) - y_i}{\sigma_i} \right ]^2
  121. and the curvature is given by the integral over the domain of the second derivative of the spline
  122. .. math::
  123. K (s) = \int ^b _a [s''(t) ]^2 dt.
  124. Trial and error may be needed to select a suitable *p*.
  125. Examples
  126. --------
  127. .. include:: explain_example.rst_
  128. To resample the file profiles.tdgmb, which contains
  129. (time,distance,gravity,magnetics,bathymetry) records, at 1km equidistant
  130. intervals using Akima's spline, use
  131. ::
  132. gmt sample1d profiles.tdgmb -N1 -Fa -T1 > profiles_equi_d.tdgmb
  133. To resample the file depths.dt at positions listed in the file
  134. grav_pos.dg, using a cubic spline for the interpolation, use
  135. ::
  136. gmt sample1d depths.txt -Tgrav_pos.dg -Fc > new_depths.txt
  137. To resample the file points.txt every 0.01 from 0-6, using a cubic spline for the
  138. interpolation, but output the first derivative instead (the slope), try
  139. ::
  140. gmt sample1d points.txt -T0/6/0.01 -Fc+d1 > slopes.txt
  141. To resample the file track.txt which contains lon, lat, depth every 2
  142. nautical miles, use
  143. ::
  144. gmt sample1d track.txt -T2n -AR > new_track.txt
  145. To do approximately the same, but make sure the original points are
  146. included, use
  147. ::
  148. gmt sample1d track.txt -T2n -Af > new_track.txt
  149. To obtain a rhumb line (loxodrome) sampled every 5 km instead, use
  150. ::
  151. gmt sample1d track.txt -T5k -AR+l > new_track.txt
  152. To sample temperatures.txt every month from 2000 to 2018, use
  153. ::
  154. gmt sample1d temperatures.txt -T2000T/2018T/1o > monthly_temp.txt
  155. To use a smoothing spline on a topographic profile for a given fit parameter, try
  156. ::
  157. gmt sample1d @topo_crossection.txt -T300/500/0.1 -Fs0.001 > smooth.txt
  158. See Also
  159. --------
  160. :doc:`gmt`,
  161. :doc:`gmt.conf`,
  162. :doc:`greenspline`,
  163. :doc:`filter1d`
Tip!

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

Comments

Loading...