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

x2sys_init.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
363
364
365
366
367
368
369
370
371
372
373
374
  1. .. index:: ! x2sys_init
  2. .. include:: ../module_supplements_purpose.rst_
  3. **********
  4. x2sys_init
  5. **********
  6. |x2sys_init_purpose|
  7. Synopsis
  8. --------
  9. .. include:: ../../common_SYN_OPTs.rst_
  10. **gmt x2sys_init** *TAG* |-D|\ *fmtfile*
  11. [ |-E|\ *suffix* ]
  12. [ |-F| ]
  13. [ |-G|\ **d**\|\ **g** ]
  14. [ |-I|\ *dx*\ [/*dy*] ]
  15. [ |-N|\ **d**\|\ **s**\ *unit* ]
  16. [ |SYN_OPT-R| ]
  17. [ |SYN_OPT-V| ]
  18. [ |-W|\ **t**\|\ **d**\ *gap* ]
  19. [ |SYN_OPT-j| ]
  20. [ |SYN_OPT--| ]
  21. |No-spaces|
  22. Description
  23. -----------
  24. **x2sys_init** is the starting point for anyone wishing to use x2sys;
  25. it initializes a set of data bases that are particular to one kind of
  26. track data. These data, their associated data bases, and key parameters
  27. are given a short-hand notation called an x2sys TAG. The TAG keeps track
  28. of settings such as file format, whether the data are geographic or not,
  29. and the binning resolution for track indices. Running **x2sys_init** is
  30. a prerequisite to running any of the other x2sys programs, such as
  31. :doc:`x2sys_binlist`, which will create a crude representation of where
  32. each data track go within the domain and which observations are
  33. available; this information serves as input to :doc:`x2sys_put` which
  34. updates the track data base. Then, :doc:`x2sys_get` can be used to find
  35. which tracks and data are available inside a given region. With that
  36. list of tracks you can use :doc:`x2sys_cross` to calculate track
  37. crossovers, use :doc:`x2sys_report` to report crossover statistics or
  38. :doc:`x2sys_list` to pull out selected crossover information that
  39. :doc:`x2sys_solve` can use to determine track-specific systematic
  40. corrections. These corrections may be used with :doc:`x2sys_datalist` to
  41. extract corrected data values for use in subsequent work. Because you
  42. can run **x2sys_init** you *must* set the environmental parameter
  43. X2SYS_HOME to a directory where you have write permission, which is
  44. where x2sys can keep track of your settings.
  45. Required Arguments
  46. ------------------
  47. *TAG*
  48. The unique name of this data type x2sys TAG.
  49. .. _-D:
  50. **-D**\ *fmtfile*
  51. Format definition file prefix for this data set [See Format Definition Files below
  52. for more information]. Specify full path if the file is not in the
  53. current directory.
  54. Optional Arguments
  55. ------------------
  56. .. _-E:
  57. **-E**\ *suffix*
  58. Specifies the file extension (suffix) for these data files. If not
  59. given we use the format definition file prefix as the suffix (see **-D**).
  60. .. _-F:
  61. **-F**
  62. Force creating new files if old ones are present [Default will abort
  63. if old TAG files are found].
  64. .. _-G:
  65. **-Gd**\|\ **g**
  66. Selects geographical coordinates. Append **d** for discontinuity at
  67. the Dateline (makes longitude go from -180 to + 180) or **g** for
  68. discontinuity at Greenwich (makes longitude go from 0 to 360
  69. [Default]). If not given we assume the data are Cartesian.
  70. .. _-I:
  71. **-I**\ *dx*\ [/*dy*]
  72. *x_inc* [and optionally *y_inc*] is the grid spacing. Append **m**
  73. to indicate minutes or **s** to indicate seconds for geographic
  74. data. These spacings refer to the binning used in the track
  75. bin-index data base.
  76. .. _-N:
  77. **-Nd**\|\ **s**\ *unit*
  78. Sets the units used for distance and speed when requested by other
  79. programs. Append **d** for distance or **s** for speed, then give
  80. the desired *unit* as **c** (Cartesian userdist or
  81. userdist/usertime), **e** (meters or m/s), **f** (feet or feet/s),
  82. **k** (km or kms/hr), **m** (miles or miles/hr), **n** (nautical
  83. miles or knots) or **u** (survey feet or survey feet/s). [Default is
  84. **-Ndk** **-Nse** (km and m/s) if **-G** is set and **-Ndc** and
  85. **-Nsc** otherwise (Cartesian units)].
  86. .. _-R:
  87. .. |Add_-Rgeo| replace:: For Cartesian
  88. data just give *xmin/xmax/ymin/ymax*. This option bases the
  89. statistics on those COE that fall inside the specified domain.
  90. .. include:: ../../explain_-Rgeo.rst_
  91. .. _-V:
  92. .. |Add_-V| unicode:: 0x20 .. just an invisible code
  93. .. include:: ../../explain_-V.rst_
  94. **-Wt**\|\ **d**\ *gap*
  95. Give **t** or **d** and append the corresponding maximum time gap
  96. (in user units; this is typically seconds [Infinity]), or distance
  97. (for units, see |-N|) gap [Infinity]) allowed between the two data
  98. points immediately on either side of a crossover. If these limits
  99. are exceeded then a data gap is assumed and no COE will be determined.
  100. .. include:: ../../explain_distcalc.rst_
  101. .. include:: ../../explain_help.rst_
  102. Format Definition Files
  103. -----------------------
  104. These \*.fmt files contain information about the data file format and
  105. have two sections: (1) header information and (2) column
  106. information. All header information starts with the character # in the
  107. first column, immediately followed by an upper-case directive. If the
  108. directive takes an argument it is separated by white-space. You may
  109. append a trailing # comments. Five directives are recognized:
  110. **ASCII** states that the data files are in ASCII format.
  111. **BINARY** states that the data files are native binary files.
  112. **NETCDF** states that the data files are COARDS-compliant 1-D netCDF files.
  113. **SKIP** takes an integer argument which is either the number of lines
  114. to skip (when reading ASCII files) or the number of bytes to skip (when
  115. reading native binary files). Not used with netCDF files.
  116. **GEO** indicates that these files are geographic data sets, with
  117. periodicities in the *x*-coordinate (longitudes). Alternatively, use **-G**.
  118. **MULTISEG** means each track consists of multiple segments separated by
  119. a GMT segment header. Not used with netCDF files.
  120. The column information consists of one line per column in the order the
  121. columns appear in the data file. For each column you must provide seven
  122. attributes:
  123. *name type NaN NaN-proxy scale offset oformat*
  124. *name* is the name of the column variable. You must
  125. use the special names *lon* (or *x* if Cartesian) and *lat* (or *y*) for
  126. the two required coordinate columns, *time* when optional absolute time data
  127. are present, and *rtime* when relative time data are given (make sure the
  128. GMT defaults :term:`TIME_UNIT` and :term:`TIME_EPOCH` are set properly). Regardless
  129. of input time flavor, we will write absolute time on output.
  130. *type* is always **a** for ASCII representations of numbers, whereas for
  131. binary files you may choose among **c** for signed 1-byte character
  132. (-127,+128), **u** for unsigned byte (0-255), **h** for signed 2-byte
  133. integers (-32768,+32767), **i** for signed 4-byte integers
  134. (-2,147,483,648,+2,147,483,647), **f** for 4-byte floating points and
  135. **d** for 8-byte double precision floating points. For netCDF, simply
  136. use **d** as netCDF will automatically handle type-conversions during reading.
  137. *NaN* is Y if certain values (e.g, -9999) are to be replaced by NaN, and N otherwise.
  138. *NaN-proxy* is that special value (e.g., -9999).
  139. *scale* is used to multiply the data after reading.
  140. *offset* is used to add to the scaled data.
  141. *oformat* is a C-style format string used to print values from this column.
  142. If you give - as the *oformat* then GMT's formatting machinery
  143. will be used instead (i.e., :term:`FORMAT_FLOAT_OUT`,
  144. :term:`FORMAT_GEO_MAP`, :term:`FORMAT_DATE_MAP`,
  145. :term:`FORMAT_CLOCK_MAP`).
  146. Some file formats already have definition files premade. These include
  147. mgd77 (for plain ASCII MGD77 data files), mgd77+ (for enhanced MGD77+
  148. netCDF files), gmt (for old mgg supplement binary files), xy (for plain
  149. ASCII x, y tables), xyz (same, with one z-column), geo (for plain ASCII
  150. longitude, latitude files), and geoz (same, with one z-column).
  151. Examples
  152. --------
  153. If you have a large set of track data files you can organize them using
  154. the x2sys tools. Here we will outline the steps. Let us assume that your
  155. track data file format consist of 2 header records with text information
  156. followed by any number of identically formatted data records with 6
  157. columns (lat, lon, time, obs1, obs2, obs3) and that files are called
  158. \*.trk. We will call this the "line" format. First, we create the
  159. line.fmt file:
  160. ====== ==== === ========= ===== ====== ========
  161. # Format define file for the line format
  162. -----------------------------------------------------
  163. # SKIP 2 # Skip 2 header records
  164. ----------------- ----------------------------------
  165. # GEO # Data are geographic
  166. ----------------- ----------------------------------
  167. #name type NaN NaN-proxy scale offset oformat
  168. ====== ==== === ========= ===== ====== ========
  169. lat a N 0 1 0 %9.5f
  170. lon a N 0 1 0 %10.5f
  171. time a N 0 1 0 %7.1f
  172. obs1 a N 0 1 0 %7.2f
  173. obs2 a N 0 1 0 %7.2f
  174. obs3 a N 0 1 0 %7.2f
  175. ====== ==== === ========= ===== ====== ========
  176. Next we create the TAG and the TAG directory with the databases for
  177. these line track files. Assuming these contain geographic data and that
  178. we want to keep track of the data distribution at a 1 x 1 degree
  179. resolution, with distances in km calculated along geodesics and with
  180. speeds given in knots, we may run
  181. ::
  182. gmt x2sys_init LINE -V -G -Dline -Rg -je -Ndk -Nsn -I1/1 -Etrk
  183. where we have selected LINE to be our x2sys tag. When x2sys tools try to
  184. read your line data files they will first look in the current directory
  185. and second look in the file *TAG*\ \_paths.txt for a list of additional
  186. directories to examine. Therefore, create such a file (here
  187. LINE_paths.txt) and stick the full paths to your data directories
  188. there. All TAG-related files (format definition files, tag files, and track
  189. data bases created) will be expected to be in the directory pointed to
  190. by **$X2SYS_HOME**/*TAG* (in our case **$X2SYS_HOME**/LINE). Note that
  191. the argument to **-D** must contain the full path if the \*.fmt file is
  192. not in the current directory. **x2sys_init** will copy this file to the
  193. **$X2SYS_HOME**/*TAG* directory where all other x2sys tools will expect
  194. to find it.
  195. **Create tbf file(s):**
  196. Once the (empty) TAG databases have been initialized we go through a
  197. two-step process to populate them. First we run :doc:`x2sys_binlist`
  198. on all our track files to create one (or more) multisegment track
  199. bin-index files (tbf). These contain information on which 1 x 1
  200. degree bins (or any other blocksize; see **-I**) each track has
  201. visited and which observations (in your case obs1, obs2, obs3) were
  202. actually observed (not all tracks may have all three kinds of
  203. observations everywhere). For instance, if your tracks are listed in
  204. the file tracks.lis we may run this command:
  205. ::
  206. gmt x2sys_binlist -V -TLINE =tracks.lis > tracks.tbf
  207. **Update index data base:**
  208. Next, the track bin-index files are fed to :doc:`x2sys_put` which will
  209. insert the information into the TAG databases:
  210. ::
  211. gmt x2sys_put -V -TLINE tracks.tbf
  212. **Search for data:**
  213. You may now use :doc:`x2sys_get` to find all the tracks within a
  214. certain sub-region, and optionally limit the search to those tracks
  215. that have a particular combination of observables. E.g., to find all
  216. the tracks which has both obs1 and obs3 inside the specified region, run
  217. ::
  218. gmt x2sys_get -V -TLINE -R20/40/-40/-20 -Fobs1,obs3 > tracks.tbf
  219. **MGD77[+] or GMT:**
  220. Format definition files already exist for MGD77 files (both standard ASCII
  221. and enhanced netCDF-based MGD77+ files) and the old \*.gmt files
  222. manipulated by the mgg supplements; for these data sets the **-j**
  223. and **-N** will default to great circle distance calculation in km
  224. and speed in m/s. There are also format definition files for plain x,y[,z]
  225. and lon,lat[,z] tracks. To initiate new track databases to be used
  226. with MGD77 data from NCEI, try
  227. ::
  228. gmt x2sys_init MGD77 -V -Dmgd77 -Emgd77 -Rd -Gd -Nsn -I1/1 -Wt900 -Wd5
  229. where we have chosen a 15 minute (900 sec) or 5 km threshold to
  230. indicate a data gap and selected knots as the speed; the other steps
  231. are similar.
  232. **Binary files:**
  233. Let us pretend that your line files actually are binary files with a
  234. 128-byte header structure (to be skipped) followed by the data
  235. records and where *lon*, *lat*, *time* are double precision numbers
  236. while the three observations are 2-byte integers which must be
  237. multiplied by 0.1. Finally, the first two observations may be -32768
  238. which means there is no data available. All that is needed is a
  239. different line.fmt file:
  240. ====== ==== === ========= ===== ====== ========
  241. # Format define file for the binary line format
  242. -----------------------------------------------------
  243. # BINARY # File is now binary
  244. ----------------- ----------------------------------
  245. # SKIP 128 # Skip 128 bytes
  246. ----------------- ----------------------------------
  247. # GEO # Data are geographic
  248. ----------------- ----------------------------------
  249. #name type NaN NaN-proxy scale offset oformat
  250. ====== ==== === ========= ===== ====== ========
  251. lon d N 0 1 0 %10.5f
  252. lat d N 0 1 0 %9.5f
  253. time d N 0 1 0 %7.1f
  254. obs1 h Y -32768 0.1 0 %6.1f
  255. obs2 h Y -32768 0.1 0 %6.1f
  256. obs3 h N 0 0.1 0 %6.1f
  257. ====== ==== === ========= ===== ====== ========
  258. The rest of the steps are identical.
  259. **COARDS 1-D netCDF files:**
  260. Finally, suppose that your line files actually are netCDF files that
  261. conform to the COARDS convention, with data columns named *lon*,
  262. *lat*, *time*, *obs1*, *obs2*, and *obs3*. All that is needed is a
  263. different line.fmt file:
  264. ====== ==== === ========= ===== ====== ========
  265. # Format define file for the netCDF COARDS line format
  266. -----------------------------------------------------
  267. # NETCDF # File is now netCDF
  268. ----------------- ----------------------------------
  269. # GEO # Data are geographic
  270. ----------------- ----------------------------------
  271. #name type NaN NaN-proxy scale offset oformat
  272. ====== ==== === ========= ===== ====== ========
  273. lon d N 0 1 0 %10.5f
  274. lat d N 0 1 0 %9.5f
  275. time d N 0 1 0 %7.1f
  276. obs1 d N 0 1 0 %6.1f
  277. obs2 d N 0 1 0 %6.1f
  278. obs3 d N 0 1 0 %6.1f
  279. ====== ==== === ========= ===== ====== ========
  280. Note we use no scaling or NaN proxies since those issues are usually
  281. handled internally in the netCDF format description.
  282. Deprecated behavior
  283. -------------------
  284. The Format Definition Files used to have extension .def but since that is also used
  285. by GMT's symbol macro files we have deprecated that extension and now use .fmt.
  286. However, old .def files are still being read.
  287. See Also
  288. --------
  289. :doc:`x2sys_binlist`,
  290. :doc:`x2sys_datalist`,
  291. :doc:`x2sys_get`,
  292. :doc:`x2sys_list`,
  293. :doc:`x2sys_put`,
  294. :doc:`x2sys_report`,
  295. :doc:`x2sys_solve`,
  296. :doc:`x2sys_cross`
Tip!

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

Comments

Loading...