gmt 0.1.4 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/ext/gmt/gmt.c +123 -39
- data/lib/gmt.rb +116 -78
- metadata +24 -11
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: e7c16625a1784afc2bc4bea4595cedbe3625c278c74c1c8468a82a10b43530de
|
|
4
|
+
data.tar.gz: 1a506fcdc8edeeaddf2f7ad7da5ffbf7c6c23822e4d5164f8c70f24cef471d80
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 43dbd14bf6d41a49bd91c0afe5f210e35f4b5e914a2f71f7f958f75841fd5cda975d5ecbda503c42f25b048dda643e03cf79438f7443dff12e9d9a304103dff3
|
|
7
|
+
data.tar.gz: 5a9a237244a07dad68258d383863f44d526fb5397826f0b146bd3ed18aa4e172f1b345cb8e771c628ada316c8e4c44dd2b2d9647da82483a32cc5ceaed8419e0
|
data/ext/gmt/gmt.c
CHANGED
|
@@ -106,7 +106,17 @@ static VALUE gmt_simple(const char *name, int argc, VALUE *argv, VALUE self)
|
|
|
106
106
|
return Qtrue;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
/*
|
|
109
|
+
/*
|
|
110
|
+
The GMT functions
|
|
111
|
+
|
|
112
|
+
We take this list from the GMT documentation for the "classic mode"
|
|
113
|
+
https://docs.generic-mapping-tools.org/latest/modules-classic.html
|
|
114
|
+
|
|
115
|
+
The "modern mode" modules (which have a slicker way of routing and
|
|
116
|
+
combining postscript output) will probably need a different treatment,
|
|
117
|
+
possibly a more attractive on from the Ruby perspective; for now we
|
|
118
|
+
just limit ourselves to the classic mode.
|
|
119
|
+
*/
|
|
110
120
|
|
|
111
121
|
#define GMT_FUN(name) \
|
|
112
122
|
static VALUE gmt_ ## name (int argc, VALUE *argv, VALUE self) \
|
|
@@ -114,15 +124,7 @@ static VALUE gmt_ ## name (int argc, VALUE *argv, VALUE self) \
|
|
|
114
124
|
return gmt_simple(#name, argc, argv, self); \
|
|
115
125
|
}
|
|
116
126
|
|
|
117
|
-
/*
|
|
118
|
-
|
|
119
|
-
GMT_FUN(blockmean)
|
|
120
|
-
GMT_FUN(blockmedian)
|
|
121
|
-
GMT_FUN(blockmode)
|
|
122
|
-
GMT_FUN(filter1d)
|
|
123
|
-
GMT_FUN(grdfilter)
|
|
124
|
-
|
|
125
|
-
/* Plotting of 1-D and 2-D Data */
|
|
127
|
+
/* Plotting */
|
|
126
128
|
|
|
127
129
|
GMT_FUN(gmtlogo)
|
|
128
130
|
GMT_FUN(grdcontour)
|
|
@@ -152,7 +154,23 @@ GMT_FUN(pssolar)
|
|
|
152
154
|
GMT_FUN(psternary)
|
|
153
155
|
#endif
|
|
154
156
|
|
|
155
|
-
|
|
157
|
+
#if API_AT_LEAST(6, 0, 0)
|
|
158
|
+
GMT_FUN(psevents)
|
|
159
|
+
#endif
|
|
160
|
+
|
|
161
|
+
/* Filtering */
|
|
162
|
+
|
|
163
|
+
GMT_FUN(blockmean)
|
|
164
|
+
GMT_FUN(blockmedian)
|
|
165
|
+
GMT_FUN(blockmode)
|
|
166
|
+
GMT_FUN(filter1d)
|
|
167
|
+
GMT_FUN(grdfilter)
|
|
168
|
+
|
|
169
|
+
#if API_AT_LEAST(6, 0, 0)
|
|
170
|
+
GMT_FUN(dimfilter)
|
|
171
|
+
#endif
|
|
172
|
+
|
|
173
|
+
/* Gridding */
|
|
156
174
|
|
|
157
175
|
GMT_FUN(greenspline)
|
|
158
176
|
GMT_FUN(nearneighbor)
|
|
@@ -160,20 +178,24 @@ GMT_FUN(sphinterpolate)
|
|
|
160
178
|
GMT_FUN(surface)
|
|
161
179
|
GMT_FUN(triangulate)
|
|
162
180
|
|
|
163
|
-
|
|
181
|
+
#if API_AT_LEAST(6, 1, 0)
|
|
182
|
+
GMT_FUN(grdinterpolate)
|
|
183
|
+
#endif
|
|
184
|
+
|
|
185
|
+
/* Sampling of 1-D and 2-D data */
|
|
164
186
|
|
|
165
187
|
GMT_FUN(gmtsimplify)
|
|
166
188
|
GMT_FUN(grdsample)
|
|
167
189
|
GMT_FUN(grdtrack)
|
|
168
190
|
GMT_FUN(sample1d)
|
|
169
191
|
|
|
170
|
-
/* Projection and
|
|
192
|
+
/* Projection and map-transformation */
|
|
171
193
|
|
|
172
194
|
GMT_FUN(grdproject)
|
|
173
195
|
GMT_FUN(mapproject)
|
|
174
196
|
GMT_FUN(project)
|
|
175
197
|
|
|
176
|
-
/*
|
|
198
|
+
/* Information retrieval */
|
|
177
199
|
|
|
178
200
|
GMT_FUN(gmtdefaults)
|
|
179
201
|
GMT_FUN(gmtget)
|
|
@@ -181,7 +203,7 @@ GMT_FUN(gmtinfo)
|
|
|
181
203
|
GMT_FUN(gmtset)
|
|
182
204
|
GMT_FUN(grdinfo)
|
|
183
205
|
|
|
184
|
-
/* Mathematical
|
|
206
|
+
/* Mathematical operations on tables or grids */
|
|
185
207
|
|
|
186
208
|
GMT_FUN(gmtmath)
|
|
187
209
|
GMT_FUN(makecpt)
|
|
@@ -190,14 +212,17 @@ GMT_FUN(sph2grd)
|
|
|
190
212
|
GMT_FUN(sphdistance)
|
|
191
213
|
GMT_FUN(sphtriangulate)
|
|
192
214
|
|
|
193
|
-
/* Convert or
|
|
215
|
+
/* Convert or extract subsets of data */
|
|
216
|
+
|
|
217
|
+
#if API_AT_LEAST(6, 2, 0)
|
|
218
|
+
GMT_FUN(gmtbinstats)
|
|
219
|
+
#endif
|
|
194
220
|
|
|
195
221
|
GMT_FUN(gmtconnect)
|
|
196
222
|
GMT_FUN(gmtconvert)
|
|
197
223
|
GMT_FUN(gmtselect)
|
|
198
224
|
GMT_FUN(gmtspatial)
|
|
199
225
|
GMT_FUN(gmtvector)
|
|
200
|
-
GMT_FUN(grd2rgb)
|
|
201
226
|
GMT_FUN(grd2xyz)
|
|
202
227
|
GMT_FUN(grdblend)
|
|
203
228
|
GMT_FUN(grdconvert)
|
|
@@ -206,14 +231,24 @@ GMT_FUN(grdpaste)
|
|
|
206
231
|
GMT_FUN(splitxyz)
|
|
207
232
|
GMT_FUN(xyz2grd)
|
|
208
233
|
|
|
209
|
-
|
|
234
|
+
#if API_AT_LEAST(6, 0, 0)
|
|
235
|
+
GMT_FUN(grd2kml)
|
|
236
|
+
#else
|
|
237
|
+
GMT_FUN(grd2rgb) /* https://github.com/GenericMappingTools/gmt/pull/425 */
|
|
238
|
+
#endif
|
|
239
|
+
|
|
240
|
+
/* trends in 1-D and 2-D data */
|
|
210
241
|
|
|
211
242
|
GMT_FUN(fitcircle)
|
|
212
243
|
GMT_FUN(gmtregress)
|
|
213
244
|
GMT_FUN(trend1d)
|
|
214
245
|
GMT_FUN(trend2d)
|
|
215
246
|
|
|
216
|
-
|
|
247
|
+
#if API_AT_LEAST(6, 0, 0)
|
|
248
|
+
GMT_FUN(grdtrend)
|
|
249
|
+
#endif
|
|
250
|
+
|
|
251
|
+
/* Grid operations */
|
|
217
252
|
|
|
218
253
|
GMT_FUN(grd2cpt)
|
|
219
254
|
GMT_FUN(grdclip)
|
|
@@ -226,12 +261,24 @@ GMT_FUN(grdmask)
|
|
|
226
261
|
GMT_FUN(grdmath)
|
|
227
262
|
GMT_FUN(grdvolume)
|
|
228
263
|
|
|
229
|
-
|
|
264
|
+
#if API_AT_LEAST(6, 0, 0)
|
|
265
|
+
GMT_FUN(grdfill)
|
|
266
|
+
#endif
|
|
267
|
+
|
|
268
|
+
#if API_AT_LEAST(6, 1, 0)
|
|
269
|
+
GMT_FUN(grdmix)
|
|
270
|
+
#endif
|
|
271
|
+
|
|
272
|
+
/* Miscellaneous */
|
|
230
273
|
|
|
231
274
|
GMT_FUN(gmt2kml)
|
|
232
275
|
GMT_FUN(kml2gmt)
|
|
233
276
|
GMT_FUN(psconvert)
|
|
234
277
|
|
|
278
|
+
#if API_AT_LEAST(6, 1, 0)
|
|
279
|
+
GMT_FUN(grdgdal)
|
|
280
|
+
#endif
|
|
281
|
+
|
|
235
282
|
#undef GMT_FUN
|
|
236
283
|
|
|
237
284
|
#define RB_DPM(name) rb_define_private_method(cGMT, #name "_c", gmt_ ## name, -1)
|
|
@@ -244,15 +291,7 @@ void Init_gmt(void)
|
|
|
244
291
|
rb_define_method(cGMT, "initialize", gmt_init, 0);
|
|
245
292
|
rb_define_method(cGMT, "free", gmt_release, 0);
|
|
246
293
|
|
|
247
|
-
/*
|
|
248
|
-
|
|
249
|
-
RB_DPM(blockmean);
|
|
250
|
-
RB_DPM(blockmedian);
|
|
251
|
-
RB_DPM(blockmode);
|
|
252
|
-
RB_DPM(filter1d);
|
|
253
|
-
RB_DPM(grdfilter);
|
|
254
|
-
|
|
255
|
-
/* Plotting of 1-D and 2-D Data */
|
|
294
|
+
/* Plotting */
|
|
256
295
|
|
|
257
296
|
RB_DPM(gmtlogo);
|
|
258
297
|
RB_DPM(grdcontour);
|
|
@@ -282,7 +321,23 @@ void Init_gmt(void)
|
|
|
282
321
|
RB_DPM(psternary);
|
|
283
322
|
#endif
|
|
284
323
|
|
|
285
|
-
|
|
324
|
+
#if API_AT_LEAST(6, 0, 0)
|
|
325
|
+
RB_DPM(psevents);
|
|
326
|
+
#endif
|
|
327
|
+
|
|
328
|
+
/* Filtering */
|
|
329
|
+
|
|
330
|
+
RB_DPM(blockmean);
|
|
331
|
+
RB_DPM(blockmedian);
|
|
332
|
+
RB_DPM(blockmode);
|
|
333
|
+
RB_DPM(filter1d);
|
|
334
|
+
RB_DPM(grdfilter);
|
|
335
|
+
|
|
336
|
+
#if API_AT_LEAST(6, 0, 0)
|
|
337
|
+
RB_DPM(dimfilter);
|
|
338
|
+
#endif
|
|
339
|
+
|
|
340
|
+
/* Gridding */
|
|
286
341
|
|
|
287
342
|
RB_DPM(greenspline);
|
|
288
343
|
RB_DPM(nearneighbor);
|
|
@@ -290,20 +345,24 @@ void Init_gmt(void)
|
|
|
290
345
|
RB_DPM(surface);
|
|
291
346
|
RB_DPM(triangulate);
|
|
292
347
|
|
|
293
|
-
|
|
348
|
+
#if API_AT_LEAST(6, 1, 0)
|
|
349
|
+
RB_DPM(grdinterpolate);
|
|
350
|
+
#endif
|
|
351
|
+
|
|
352
|
+
/* Sampling of 1-D and 2-D data */
|
|
294
353
|
|
|
295
354
|
RB_DPM(gmtsimplify);
|
|
296
355
|
RB_DPM(grdsample);
|
|
297
356
|
RB_DPM(grdtrack);
|
|
298
357
|
RB_DPM(sample1d);
|
|
299
358
|
|
|
300
|
-
/* Projection and
|
|
359
|
+
/* Projection and map-transformation */
|
|
301
360
|
|
|
302
361
|
RB_DPM(grdproject);
|
|
303
362
|
RB_DPM(mapproject);
|
|
304
363
|
RB_DPM(project);
|
|
305
364
|
|
|
306
|
-
/*
|
|
365
|
+
/* Information retrieval */
|
|
307
366
|
|
|
308
367
|
RB_DPM(gmtdefaults);
|
|
309
368
|
RB_DPM(gmtget);
|
|
@@ -311,7 +370,7 @@ void Init_gmt(void)
|
|
|
311
370
|
RB_DPM(gmtset);
|
|
312
371
|
RB_DPM(grdinfo);
|
|
313
372
|
|
|
314
|
-
/* Mathematical
|
|
373
|
+
/* Mathematical operations on tables or grids */
|
|
315
374
|
|
|
316
375
|
RB_DPM(gmtmath);
|
|
317
376
|
RB_DPM(makecpt);
|
|
@@ -320,14 +379,17 @@ void Init_gmt(void)
|
|
|
320
379
|
RB_DPM(sphdistance);
|
|
321
380
|
RB_DPM(sphtriangulate);
|
|
322
381
|
|
|
323
|
-
/* Convert or
|
|
382
|
+
/* Convert or extract subsets of data */
|
|
383
|
+
|
|
384
|
+
#if API_AT_LEAST(6, 2, 0)
|
|
385
|
+
RB_DPM(gmtbinstats);
|
|
386
|
+
#endif
|
|
324
387
|
|
|
325
388
|
RB_DPM(gmtconnect);
|
|
326
389
|
RB_DPM(gmtconvert);
|
|
327
390
|
RB_DPM(gmtselect);
|
|
328
391
|
RB_DPM(gmtspatial);
|
|
329
392
|
RB_DPM(gmtvector);
|
|
330
|
-
RB_DPM(grd2rgb);
|
|
331
393
|
RB_DPM(grd2xyz);
|
|
332
394
|
RB_DPM(grdblend);
|
|
333
395
|
RB_DPM(grdconvert);
|
|
@@ -336,14 +398,24 @@ void Init_gmt(void)
|
|
|
336
398
|
RB_DPM(splitxyz);
|
|
337
399
|
RB_DPM(xyz2grd);
|
|
338
400
|
|
|
339
|
-
|
|
401
|
+
#if API_AT_LEAST(6, 0, 0)
|
|
402
|
+
RB_DPM(grd2kml);
|
|
403
|
+
#else
|
|
404
|
+
RB_DPM(grd2rgb); /* https://github.com/GenericMappingTools/gmt/pull/425 */
|
|
405
|
+
#endif
|
|
406
|
+
|
|
407
|
+
/* Trends in 1-D and 2-D data */
|
|
340
408
|
|
|
341
409
|
RB_DPM(fitcircle);
|
|
342
410
|
RB_DPM(gmtregress);
|
|
343
411
|
RB_DPM(trend1d);
|
|
344
412
|
RB_DPM(trend2d);
|
|
345
413
|
|
|
346
|
-
|
|
414
|
+
#if API_AT_LEAST(6, 0, 0)
|
|
415
|
+
RB_DPM(grdtrend);
|
|
416
|
+
#endif
|
|
417
|
+
|
|
418
|
+
/* Grid operations */
|
|
347
419
|
|
|
348
420
|
RB_DPM(grd2cpt);
|
|
349
421
|
RB_DPM(grdclip);
|
|
@@ -356,12 +428,24 @@ void Init_gmt(void)
|
|
|
356
428
|
RB_DPM(grdmath);
|
|
357
429
|
RB_DPM(grdvolume);
|
|
358
430
|
|
|
359
|
-
|
|
431
|
+
#if API_AT_LEAST(6, 0, 0)
|
|
432
|
+
RB_DPM(grdfill);
|
|
433
|
+
#endif
|
|
434
|
+
|
|
435
|
+
#if API_AT_LEAST(6, 1, 0)
|
|
436
|
+
RB_DPM(grdmix);
|
|
437
|
+
#endif
|
|
438
|
+
|
|
439
|
+
/* Miscellaneous */
|
|
360
440
|
|
|
361
441
|
RB_DPM(gmt2kml);
|
|
362
442
|
RB_DPM(kml2gmt);
|
|
363
443
|
RB_DPM(psconvert);
|
|
364
444
|
|
|
445
|
+
#if API_AT_LEAST(6, 1, 0)
|
|
446
|
+
RB_DPM(grdgdal);
|
|
447
|
+
#endif
|
|
448
|
+
|
|
365
449
|
/* version constants */
|
|
366
450
|
|
|
367
451
|
rb_define_const(cGMT, "VERSION_MAJOR", INT2NUM(GMT_MAJOR_VERSION));
|
data/lib/gmt.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# This class provides a native extension accessing the programs of
|
|
2
|
-
# the {
|
|
2
|
+
# the {https://docs.generic-mapping-tools.org Generic Mapping Tools};
|
|
3
3
|
# an open source collection of about 80 command-line tools for
|
|
4
4
|
# manipulating geographic and Cartesian data sets (including filtering,
|
|
5
5
|
# trend fitting, gridding, projecting, etc.) and producing PostScript
|
|
@@ -13,16 +13,8 @@
|
|
|
13
13
|
# common = { file: 'output.ps', R: '0/3/0/2', J: 'x1i' }
|
|
14
14
|
#
|
|
15
15
|
# GMT.session do |gmt|
|
|
16
|
-
# gmt.psxy('dots.xy',
|
|
17
|
-
#
|
|
18
|
-
# position: :first,
|
|
19
|
-
# S: 'c0.50c',
|
|
20
|
-
# G: 'blue'))
|
|
21
|
-
# gmt.psxy('dots.xy',
|
|
22
|
-
# common.merge(
|
|
23
|
-
# position: :last,
|
|
24
|
-
# S: 'c0.25c',
|
|
25
|
-
# G: 'red'))
|
|
16
|
+
# gmt.psxy('dots.xy', position: :first, S: 'c0.50c', G: 'blue', **common)
|
|
17
|
+
# gmt.psxy('dots.xy', position: :last, S: 'c0.25c', G: 'red', **common)
|
|
26
18
|
# end
|
|
27
19
|
#
|
|
28
20
|
# Those familiar with GMT will recognise the +-R+ (range) and +-J+ (projection)
|
|
@@ -50,23 +42,30 @@
|
|
|
50
42
|
# single options hash. The options hash corresponds to the command-line
|
|
51
43
|
# options of the GMT program; hence the shell command
|
|
52
44
|
#
|
|
53
|
-
# gmt makecpt -Cgebco depths.txt -i2 -Z -E24 >
|
|
45
|
+
# gmt makecpt -Cgebco depths.txt -i2 -Z -E24 > bath.cpt
|
|
54
46
|
#
|
|
55
47
|
# would be replicated by the Ruby
|
|
56
48
|
#
|
|
57
49
|
# gmt = GMT.new
|
|
58
|
-
# gmt.makecpt('depths.txt',
|
|
59
|
-
# :C => 'gebco', :i => 2, :Z => nil, :E => 24, :> => 'my_depths.cpt')
|
|
50
|
+
# gmt.makecpt('depths.txt', C: 'gebco', i: 2, Z: nil, E: 24, :> => 'bath.cpt')
|
|
60
51
|
#
|
|
61
52
|
# Note that
|
|
62
53
|
# - the argument(s) (the input file <code>'depths.txt'</code>) preceed(s)
|
|
63
54
|
# the options hash
|
|
64
55
|
# - the options hash has keys which are symbols
|
|
65
56
|
# - options which lack arguments correspond to hash keys with nil values
|
|
66
|
-
# <code
|
|
57
|
+
# <code>Z: nil</code>.
|
|
67
58
|
# - the output redirection is _also_ treated as hash option, with key
|
|
68
59
|
# <code>:></code> and value which is the output file.
|
|
69
60
|
#
|
|
61
|
+
# The options without argument can also be specifed by a symbol
|
|
62
|
+
# _argument_, but recall that arguments must proceed the options hash,
|
|
63
|
+
# so the above would be
|
|
64
|
+
#
|
|
65
|
+
# gmt.makecpt('depths.txt', :Z, C: 'gebco', i: 2, E: 24, :> => 'bath.cpt')
|
|
66
|
+
#
|
|
67
|
+
# using this format.
|
|
68
|
+
#
|
|
70
69
|
# == PostScript functions
|
|
71
70
|
#
|
|
72
71
|
# When creating complex PostScript plots one needs to make several calls to
|
|
@@ -75,17 +74,17 @@
|
|
|
75
74
|
# and error-prone on the command-line, and more so in the "options hash"
|
|
76
75
|
# representation in the Ruby module.
|
|
77
76
|
#
|
|
78
|
-
# So we add some
|
|
77
|
+
# So we add some syntactic sugar for these PostScript functions: if the
|
|
79
78
|
# options hash has the keys +:position+ (with values one of +:first+, +:middle+,
|
|
80
79
|
# or +:last+) and +:file+ (with the value of the ouptut file), then the
|
|
81
80
|
# +-O+ and +-K+ options and the output redirection are handled by the class.
|
|
82
81
|
# So one might write
|
|
83
82
|
#
|
|
84
83
|
# gmt = GMT.new
|
|
85
|
-
# gmt.psbasemap(
|
|
86
|
-
# gmt.pstext(
|
|
87
|
-
# gmt.psxy(
|
|
88
|
-
# gmt.pslogo(
|
|
84
|
+
# gmt.psbasemap( ..., file: 'map.ps', position: :first)
|
|
85
|
+
# gmt.pstext( ..., file: 'map.ps', position: :middle)
|
|
86
|
+
# gmt.psxy( ..., file: 'map.ps', position: :middle)
|
|
87
|
+
# gmt.pslogo( ..., file: 'map.ps', position: :last)
|
|
89
88
|
#
|
|
90
89
|
class GMT
|
|
91
90
|
|
|
@@ -133,13 +132,13 @@ class GMT
|
|
|
133
132
|
# @param [Array<String>] files The input files
|
|
134
133
|
# @param [Hash] options The GMT command-line options in hash form
|
|
135
134
|
# @return [Boolean] +true+ on success
|
|
136
|
-
# @see
|
|
135
|
+
# @see https://docs.generic-mapping-tools.org/latest/$1.html
|
|
137
136
|
def wrapper_ps(method)
|
|
138
|
-
define_method(method) do |*args, **
|
|
139
|
-
|
|
140
|
-
coerce_postscript_options!(
|
|
141
|
-
coerce_append_option!(
|
|
142
|
-
self.send(api_function(method), *args, options_as_pairs(
|
|
137
|
+
define_method(method) do |*args, **opts|
|
|
138
|
+
args, opts = arg_opt_normalise(args, opts)
|
|
139
|
+
coerce_postscript_options!(opts)
|
|
140
|
+
coerce_append_option!(opts)
|
|
141
|
+
self.send(api_function(method), *args, options_as_pairs(opts))
|
|
143
142
|
end
|
|
144
143
|
end
|
|
145
144
|
|
|
@@ -148,12 +147,12 @@ class GMT
|
|
|
148
147
|
# @param [Array<String>] arguments The arguments
|
|
149
148
|
# @param [Hash] options The GMT command-line options in hash form
|
|
150
149
|
# @return [Boolean] +true+ on success
|
|
151
|
-
# @see
|
|
150
|
+
# @see https://docs.generic-mapping-tools.org/latest/$1.html
|
|
152
151
|
def wrapper_other(method)
|
|
153
|
-
define_method(method) do |*args, **
|
|
154
|
-
|
|
155
|
-
coerce_append_option!(
|
|
156
|
-
self.send(api_function(method), *args, options_as_pairs(
|
|
152
|
+
define_method(method) do |*args, **opts|
|
|
153
|
+
args, opts = arg_opt_normalise(args, opts)
|
|
154
|
+
coerce_append_option!(opts)
|
|
155
|
+
self.send(api_function(method), *args, options_as_pairs(opts))
|
|
157
156
|
end
|
|
158
157
|
end
|
|
159
158
|
|
|
@@ -176,10 +175,22 @@ class GMT
|
|
|
176
175
|
[method.to_s, 'c'].join('_').to_sym
|
|
177
176
|
end
|
|
178
177
|
|
|
179
|
-
# convert arguments to
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
178
|
+
# convert symbol arguments to nil-valued options, and
|
|
179
|
+
# call :to_s on the remaining arguments, so
|
|
180
|
+
#
|
|
181
|
+
# arg_opt_normalise(['a', :b, Pathname('/c')], {d: 'e'})
|
|
182
|
+
#
|
|
183
|
+
# becomes
|
|
184
|
+
#
|
|
185
|
+
# [['a', '/c'], {b: nil, d: 'e'}]
|
|
186
|
+
#
|
|
187
|
+
# returns the normalised arguments and options, does not
|
|
188
|
+
# modify the inputs
|
|
189
|
+
|
|
190
|
+
def arg_opt_normalise(args, opts)
|
|
191
|
+
syms, strs = args.partition { |x| x.is_a? Symbol }
|
|
192
|
+
syms.each { |sym| opts[sym] = nil }
|
|
193
|
+
[strs.map(&:to_s), opts]
|
|
183
194
|
end
|
|
184
195
|
|
|
185
196
|
# for GMT modules which produce PostScript, convert the
|
|
@@ -187,43 +198,43 @@ class GMT
|
|
|
187
198
|
# equivalent of the -K, -O options, and the creation of
|
|
188
199
|
# or appending to the PostScript output file
|
|
189
200
|
|
|
190
|
-
def coerce_postscript_options!(
|
|
191
|
-
file =
|
|
192
|
-
position =
|
|
201
|
+
def coerce_postscript_options!(opts)
|
|
202
|
+
file = opts.delete(:file)
|
|
203
|
+
position = opts.delete(:position)
|
|
193
204
|
if file && position then
|
|
194
|
-
|
|
205
|
+
file_opts =
|
|
195
206
|
case position
|
|
196
207
|
when :first, 'first'
|
|
197
|
-
{ :
|
|
208
|
+
{ K: nil, :> => file }
|
|
198
209
|
when :middle, 'middle'
|
|
199
|
-
{ :
|
|
210
|
+
{ O: nil, K: nil, :>> => file }
|
|
200
211
|
when :last, 'last'
|
|
201
|
-
{ :
|
|
212
|
+
{ O: nil, :>> => file }
|
|
202
213
|
else
|
|
203
214
|
raise ArgumentError, 'position should be :first, :middle or :last'
|
|
204
215
|
end
|
|
205
|
-
|
|
216
|
+
opts.merge!(file_opts)
|
|
206
217
|
end
|
|
207
218
|
end
|
|
208
219
|
|
|
209
220
|
# handle the :>> option
|
|
210
221
|
|
|
211
|
-
def coerce_append_option!(
|
|
212
|
-
if file =
|
|
213
|
-
|
|
222
|
+
def coerce_append_option!(opts)
|
|
223
|
+
if file = opts.delete(:>>) then
|
|
224
|
+
opts[:>] = '>' + file
|
|
214
225
|
end
|
|
215
226
|
end
|
|
216
227
|
|
|
217
228
|
# convert non-nil argument to string
|
|
218
229
|
|
|
219
|
-
def string_unless_nil(
|
|
220
|
-
|
|
230
|
+
def string_unless_nil(arg)
|
|
231
|
+
arg.to_s unless arg.nil?
|
|
221
232
|
end
|
|
222
233
|
|
|
223
234
|
# convert the options hash to an array of pairs
|
|
224
235
|
|
|
225
|
-
def options_as_pairs(
|
|
226
|
-
|
|
236
|
+
def options_as_pairs(opts)
|
|
237
|
+
opts.each_with_object(Array.new) do |(key, values), result|
|
|
227
238
|
if values.respond_to? :each then
|
|
228
239
|
values.each do |value|
|
|
229
240
|
result << [key, string_unless_nil(value)]
|
|
@@ -236,25 +247,7 @@ class GMT
|
|
|
236
247
|
|
|
237
248
|
public
|
|
238
249
|
|
|
239
|
-
# @!group
|
|
240
|
-
|
|
241
|
-
# L2 (x,y,z) table data filter/decimator
|
|
242
|
-
wrapper_other :blockmean
|
|
243
|
-
|
|
244
|
-
# L1 (x,y,z) table data filter/decimator
|
|
245
|
-
wrapper_other :blockmedian
|
|
246
|
-
|
|
247
|
-
# Mode estimate (x,y,z) table data filter/decimator
|
|
248
|
-
wrapper_other :blockmode
|
|
249
|
-
|
|
250
|
-
# Time domain filtering of 1-D data tables
|
|
251
|
-
wrapper_other :filter1d
|
|
252
|
-
|
|
253
|
-
# Filter 2-D gridded data sets in the space domain
|
|
254
|
-
wrapper_other :grdfilter
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
# @!group Plotting of 1-D and 2-D Data
|
|
250
|
+
# @!group Plotting
|
|
258
251
|
|
|
259
252
|
# Plot the GMT logo on maps
|
|
260
253
|
wrapper_ps :gmtlogo
|
|
@@ -319,8 +312,32 @@ class GMT
|
|
|
319
312
|
# Plot data on ternary diagrams
|
|
320
313
|
wrapper_ps :psternary
|
|
321
314
|
|
|
315
|
+
# Plot event symbols and labels for a moment in time
|
|
316
|
+
wrapper_ps :psevents
|
|
322
317
|
|
|
323
|
-
|
|
318
|
+
|
|
319
|
+
# @!group Filtering
|
|
320
|
+
|
|
321
|
+
# L2 (x,y,z) table data filter/decimator
|
|
322
|
+
wrapper_other :blockmean
|
|
323
|
+
|
|
324
|
+
# L1 (x,y,z) table data filter/decimator
|
|
325
|
+
wrapper_other :blockmedian
|
|
326
|
+
|
|
327
|
+
# Mode estimate (x,y,z) table data filter/decimator
|
|
328
|
+
wrapper_other :blockmode
|
|
329
|
+
|
|
330
|
+
# Time domain filtering of 1-D data tables
|
|
331
|
+
wrapper_other :filter1d
|
|
332
|
+
|
|
333
|
+
# Filter 2-D gridded data sets in the space domain
|
|
334
|
+
wrapper_other :grdfilter
|
|
335
|
+
|
|
336
|
+
# Directional filtering of grids in the space domain
|
|
337
|
+
wrapper_other :dimfilter
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
# @!group Gridding
|
|
324
341
|
|
|
325
342
|
# Interpolation with Green’s functions for splines in 1–3 D
|
|
326
343
|
wrapper_other :greenspline
|
|
@@ -337,8 +354,11 @@ class GMT
|
|
|
337
354
|
# Perform optimal Delauney triangulation and gridding
|
|
338
355
|
wrapper_other :triangulate
|
|
339
356
|
|
|
357
|
+
# Interpolate 2-D grids or 1-D series from a 3-D data cube
|
|
358
|
+
wrapper_other :grdinterpolate
|
|
359
|
+
|
|
340
360
|
|
|
341
|
-
# @!group Sampling of 1-D and 2-D
|
|
361
|
+
# @!group Sampling of 1-D and 2-D data
|
|
342
362
|
|
|
343
363
|
# Line reduction using the Douglas-Peucker algorithm
|
|
344
364
|
wrapper_other :gmtsimplify
|
|
@@ -353,7 +373,7 @@ class GMT
|
|
|
353
373
|
wrapper_other :sample1d
|
|
354
374
|
|
|
355
375
|
|
|
356
|
-
# @!group Projection and
|
|
376
|
+
# @!group Projection and map-transformation
|
|
357
377
|
|
|
358
378
|
# Project gridded data sets onto a new coordinate system
|
|
359
379
|
wrapper_other :grdproject
|
|
@@ -365,7 +385,7 @@ class GMT
|
|
|
365
385
|
wrapper_other :project
|
|
366
386
|
|
|
367
387
|
|
|
368
|
-
# @!group
|
|
388
|
+
# @!group Information retrieval
|
|
369
389
|
|
|
370
390
|
# List the current default settings
|
|
371
391
|
wrapper_other :gmtdefaults
|
|
@@ -383,7 +403,7 @@ class GMT
|
|
|
383
403
|
wrapper_other :grdinfo
|
|
384
404
|
|
|
385
405
|
|
|
386
|
-
# @!group Mathematical
|
|
406
|
+
# @!group Mathematical operations on tables or grids
|
|
387
407
|
|
|
388
408
|
# Mathematical operations on table data
|
|
389
409
|
wrapper_other :gmtmath
|
|
@@ -404,7 +424,10 @@ class GMT
|
|
|
404
424
|
wrapper_other :sphtriangulate
|
|
405
425
|
|
|
406
426
|
|
|
407
|
-
# @!group Convert or
|
|
427
|
+
# @!group Convert or extract subsets of data
|
|
428
|
+
|
|
429
|
+
# Bin spatial data and determine statistics per bin
|
|
430
|
+
wrapper_other :gmtbinstats
|
|
408
431
|
|
|
409
432
|
# Connect segments into more complete lines or polygons
|
|
410
433
|
wrapper_other :gmtconnect
|
|
@@ -445,8 +468,11 @@ class GMT
|
|
|
445
468
|
# Convert an equidistant table xyz file to a 2-D grid file
|
|
446
469
|
wrapper_other :xyz2grd
|
|
447
470
|
|
|
471
|
+
# Create KML image quadtree from single grid
|
|
472
|
+
wrapper_other :grd2kml
|
|
448
473
|
|
|
449
|
-
|
|
474
|
+
|
|
475
|
+
# @!group Trends in 1-D and 2-D data
|
|
450
476
|
|
|
451
477
|
# Finds the best-fitting great or small circle for a set of points
|
|
452
478
|
wrapper_other :fitcircle
|
|
@@ -460,8 +486,11 @@ class GMT
|
|
|
460
486
|
# Fits polynomial trends to z = f(x,y) series
|
|
461
487
|
wrapper_other :trend2d
|
|
462
488
|
|
|
489
|
+
# Fit trend surface to grids and compute residuals
|
|
490
|
+
wrapper_other :grdtrend
|
|
491
|
+
|
|
463
492
|
|
|
464
|
-
# @!group
|
|
493
|
+
# @!group Grid operations
|
|
465
494
|
|
|
466
495
|
# Make color palette table from a grid files
|
|
467
496
|
wrapper_other :grd2cpt
|
|
@@ -475,6 +504,9 @@ class GMT
|
|
|
475
504
|
# Perform operations on grid files in the frequency domain
|
|
476
505
|
wrapper_other :grdfft
|
|
477
506
|
|
|
507
|
+
# Interpolate across holes in a grid
|
|
508
|
+
wrapper_other :grdfill
|
|
509
|
+
|
|
478
510
|
# Compute directional gradient from grid files
|
|
479
511
|
wrapper_other :grdgradient
|
|
480
512
|
|
|
@@ -490,11 +522,14 @@ class GMT
|
|
|
490
522
|
# Mathematical operations on grid files
|
|
491
523
|
wrapper_other :grdmath
|
|
492
524
|
|
|
525
|
+
# Blending and transforming grids and images
|
|
526
|
+
wrapper_other :grdmix
|
|
527
|
+
|
|
493
528
|
# Calculate volumes under a surface within specified contour
|
|
494
529
|
wrapper_other :grdvolume
|
|
495
530
|
|
|
496
531
|
|
|
497
|
-
# @!group Miscellaneous
|
|
532
|
+
# @!group Miscellaneous
|
|
498
533
|
|
|
499
534
|
# Like psxy but plots KML for use in Google Earth
|
|
500
535
|
wrapper_other :gmt2kml
|
|
@@ -505,6 +540,9 @@ class GMT
|
|
|
505
540
|
# Crop and convert PostScript files to raster images, EPS, and PDF
|
|
506
541
|
wrapper_other :psconvert
|
|
507
542
|
|
|
543
|
+
# Execute GDAL raster programs from GMT
|
|
544
|
+
wrapper_other :grdgdal
|
|
545
|
+
|
|
508
546
|
end
|
|
509
547
|
|
|
510
548
|
require 'gmt/gmt'
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gmt
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- J.J. Green
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2021-07-09 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -16,28 +16,28 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
19
|
+
version: '2'
|
|
20
20
|
type: :development
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '
|
|
26
|
+
version: '2'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: rake
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
31
|
- - "~>"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '
|
|
33
|
+
version: '13.0'
|
|
34
34
|
type: :development
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
38
|
- - "~>"
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '
|
|
40
|
+
version: '13.0'
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: rspec
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -80,8 +80,22 @@ dependencies:
|
|
|
80
80
|
- - "~>"
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
82
|
version: 0.2.4
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: rake-compiler
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - "~>"
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '1'
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - "~>"
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '1'
|
|
83
97
|
description: |
|
|
84
|
-
A Ruby extension for the Generic Mapping Tools (GMT5)
|
|
98
|
+
A Ruby extension for the Generic Mapping Tools (GMT5/6)
|
|
85
99
|
cartographic toolset.
|
|
86
100
|
email: j.j.green@gmx.co.uk
|
|
87
101
|
executables: []
|
|
@@ -114,11 +128,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
114
128
|
- !ruby/object:Gem::Version
|
|
115
129
|
version: '0'
|
|
116
130
|
requirements:
|
|
117
|
-
- GMT5 development libraries (compile)
|
|
118
|
-
- GMT5 installation (test)
|
|
131
|
+
- GMT5/6 development libraries (compile)
|
|
132
|
+
- GMT5/6 installation (test)
|
|
119
133
|
- ghostscript (test)
|
|
120
|
-
|
|
121
|
-
rubygems_version: 2.5.2.1
|
|
134
|
+
rubygems_version: 3.1.2
|
|
122
135
|
signing_key:
|
|
123
136
|
specification_version: 4
|
|
124
137
|
summary: Generic Mapping Tools (GMT)
|