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

grdmath.rst 73 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
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
  1. .. index:: ! grdmath
  2. .. include:: module_core_purpose.rst_
  3. *******
  4. grdmath
  5. *******
  6. |grdmath_purpose|
  7. Synopsis
  8. --------
  9. .. include:: common_SYN_OPTs.rst_
  10. **gmt grdmath**
  11. [ |SYN_OPT-Area| ]
  12. [ |-D|\ *resolution*\ [**+f**] ]
  13. [ |SYN_OPT-I| ]
  14. [ |-M| ] [ |-N| ]
  15. [ |SYN_OPT-R| ]
  16. [ |-S| ]
  17. [ |SYN_OPT-V| ]
  18. [ |SYN_OPT-a| ]
  19. [ |SYN_OPT-bi| ]
  20. [ |SYN_OPT-di| ]
  21. [ |SYN_OPT-f| ]
  22. [ |SYN_OPT-h| ]
  23. [ |SYN_OPT-i| ]
  24. [ |SYN_OPT-n| ]
  25. [ |SYN_OPT-r| ]
  26. [ |SYN_OPT-x| ]
  27. [ |SYN_OPT--| ]
  28. *operand* [ *operand* ] **OPERATOR** [ *operand* ]
  29. **OPERATOR** ... **=** *outgrdfile*
  30. |No-spaces|
  31. Description
  32. -----------
  33. **grdmath** will perform operations like add, subtract, multiply, and
  34. hundreds of other operands on one or more grid files or constants using
  35. `Reverse Polish Notation (RPN) <https://en.wikipedia.org/wiki/Reverse_Polish_notation>`_
  36. syntax. Arbitrarily complicated expressions may therefore be evaluated; the
  37. final result is written to an output grid file. Grid operations are
  38. element-by-element, not matrix manipulations. Some operators only
  39. require one operand (see below). If no grid files are used in the
  40. expression then options **-R**, **-I** must be set (and optionally
  41. |SYN_OPT-r|). The expression **=** *outgrdfile* can occur as many times as
  42. the depth of the stack allows in order to save intermediate results.
  43. Complicated or frequently occurring expressions may be coded as a macro
  44. for future use or stored and recalled via named memory locations.
  45. Required Arguments
  46. ------------------
  47. *operand*
  48. If *operand* can be opened as a file it will be read as a grid file.
  49. If not a file, it is interpreted as a numerical constant or a
  50. special symbol (see below).
  51. *outgrdfile*
  52. The name of a 2-D grid file that will hold the final result. (See
  53. GRID FILE FORMATS below).
  54. Optional Arguments
  55. ------------------
  56. .. _-A:
  57. .. |Add_-A| replace:: (**-A** is only relevant to the **LDISTG** operator)
  58. .. include:: explain_-A.rst_
  59. .. _-D:
  60. **-D**\ *resolution*\ [**+f**]
  61. Selects the resolution of the data set to use with the operator LDISTG
  62. ((**f**)ull, (**h**)igh, (**i**)ntermediate, (**l**)ow, and (**c**)rude). The
  63. resolution drops off by 80% between data sets [Default is **l**].
  64. Append **+f** to automatically select a lower resolution should the one
  65. requested not be available [abort if not found].
  66. .. _-I:
  67. .. include:: explain_-I.rst_
  68. .. _-M:
  69. **-M**
  70. By default any derivatives calculated are in z_units/x(or
  71. y)\_units. However, the user may choose this option to convert dx,dy
  72. in degrees of longitude,latitude into meters using a flat Earth
  73. approximation, so that gradients are in z_units/meter.
  74. .. _-N:
  75. **-N**
  76. Turn off strict domain match checking when multiple grids are
  77. manipulated [Default will insist that each grid domain is within
  78. 1e-4 \* grid_spacing of the domain of the first grid listed].
  79. .. _-R:
  80. .. |Add_-R| unicode:: 0x20 .. just an invisible code
  81. .. include:: explain_-R.rst_
  82. .. _-S:
  83. **-S**
  84. Reduce (i.e., collapse) the entire stack to a single grid by applying the
  85. next operator to all co-registered nodes across the entire stack. You
  86. must specify **-S** *after* listing all of your grids. **Note**: You can only
  87. follow **-S** with a reducing operator, i.e., from the list ADD, AND, MAD,
  88. LMSSCL, MAX, MEAN, MEDIAN, MIN, MODE, MUL, RMS, STD, SUB, VAR or XOR.
  89. .. _-V:
  90. .. |Add_-V| unicode:: 0x20 .. just an invisible code
  91. .. include:: explain_-V.rst_
  92. .. include:: explain_-aspatial.rst_
  93. .. |Add_-bi| replace:: The binary input option
  94. only applies to the data files needed by operators **LDIST**,
  95. **PDIST**, and **INSIDE**.
  96. .. include:: explain_-bi.rst_
  97. .. |Add_-di| unicode:: 0x20 .. just an invisible code
  98. .. include:: explain_-di.rst_
  99. .. |Add_-f| unicode:: 0x20 .. just an invisible code
  100. .. include:: explain_-f.rst_
  101. .. |Add_-g| unicode:: 0x20 .. just an invisible code
  102. .. include:: explain_-g.rst_
  103. .. |Add_-h| unicode:: 0x20 .. just an invisible code
  104. .. include:: explain_-h.rst_
  105. .. include:: explain_-icols.rst_
  106. .. include:: explain_-n.rst_
  107. .. |Add_nodereg| replace:: Only used with **-R** **-I**.
  108. .. include:: explain_nodereg.rst_
  109. .. include:: explain_core.rst_
  110. .. include:: explain_help.rst_
  111. Operators
  112. ---------
  113. Choose among the following 224 operators. "args" are the number of input
  114. and output arguments.
  115. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  116. | Operator | args | Returns |
  117. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  118. | **ABS** | 1 1 | abs (A) |
  119. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  120. | **ACOS** | 1 1 | acos (A) |
  121. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  122. | **ACOSH** | 1 1 | acosh (A) |
  123. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  124. | **ACOT** | 1 1 | acot (A) |
  125. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  126. | **ACSC** | 1 1 | acsc (A) |
  127. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  128. | **ADD** | 2 1 | A + B |
  129. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  130. | **AND** | 2 1 | B if A == NaN, else A |
  131. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  132. | **ARC** | 2 1 | Return arc(A,B) on [0 pi] |
  133. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  134. | **AREA** | 0 1 | Area of each gridnode cell (in km^2 if geographic) |
  135. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  136. | **ASEC** | 1 1 | asec (A) |
  137. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  138. | **ASIN** | 1 1 | asin (A) |
  139. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  140. | **ASINH** | 1 1 | asinh (A) |
  141. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  142. | **ATAN** | 1 1 | atan (A) |
  143. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  144. | **ATAN2** | 2 1 | atan2 (A, B) |
  145. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  146. | **ATANH** | 1 1 | atanh (A) |
  147. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  148. | **BCDF** | 3 1 | Binomial cumulative distribution function for p = A, n = B, and x = C |
  149. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  150. | **BPDF** | 3 1 | Binomial probability density function for p = A, n = B, and x = C |
  151. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  152. | **BEI** | 1 1 | bei (A) |
  153. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  154. | **BER** | 1 1 | ber (A) |
  155. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  156. | **BITAND** | 2 1 | A & B (bitwise AND operator) |
  157. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  158. | **BITLEFT** | 2 1 | A << B (bitwise left-shift operator) |
  159. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  160. | **BITNOT** | 1 1 | ~A (bitwise NOT operator, i.e., return two's complement) |
  161. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  162. | **BITOR** | 2 1 | A \| B (bitwise OR operator) |
  163. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  164. | **BITRIGHT** | 2 1 | A >> B (bitwise right-shift operator) |
  165. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  166. | **BITTEST** | 2 1 | 1 if bit B of A is set, else 0 (bitwise TEST operator) |
  167. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  168. | **BITXOR** | 2 1 | A ^ B (bitwise XOR operator) |
  169. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  170. | **BLEND** | 3 1 | Blend A and B using weights in C (0-1 range) as A*C + B*(1-C) |
  171. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  172. | **CAZ** | 2 1 | Cartesian azimuth from grid nodes to stack x,y (i.e., A, B) |
  173. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  174. | **CBAZ** | 2 1 | Cartesian back-azimuth from grid nodes to stack x,y (i.e., A, B) |
  175. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  176. | **CDIST** | 2 1 | Cartesian distance between grid nodes and stack x,y (i.e., A, B) |
  177. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  178. | **CDIST2** | 2 1 | As CDIST but only to nodes that are != 0 |
  179. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  180. | **CEIL** | 1 1 | ceil (A) (smallest integer >= A) |
  181. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  182. | **CHICRIT** | 2 1 | Chi-squared critical value for alpha = A and nu = B |
  183. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  184. | **CHICDF** | 2 1 | Chi-squared cumulative distribution function for chi2 = A and nu = B |
  185. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  186. | **CHIPDF** | 2 1 | Chi-squared probability density function for chi2 = A and nu = B |
  187. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  188. | **COMB** | 2 1 | Combinations n_C_r, with n = A and r = B |
  189. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  190. | **CORRCOEFF** | 2 1 | Correlation coefficient r(A, B) |
  191. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  192. | **COS** | 1 1 | cos (A) (A in radians) |
  193. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  194. | **COSD** | 1 1 | cos (A) (A in degrees) |
  195. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  196. | **COSH** | 1 1 | cosh (A) |
  197. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  198. | **COT** | 1 1 | cot (A) (A in radians) |
  199. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  200. | **COTD** | 1 1 | cot (A) (A in degrees) |
  201. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  202. | **CSC** | 1 1 | csc (A) (A in radians) |
  203. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  204. | **CSCD** | 1 1 | csc (A) (A in degrees) |
  205. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  206. | **CURV** | 1 1 | Curvature of A (Laplacian) |
  207. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  208. | **D2DX2** | 1 1 | d^2(A)/dx^2 2nd derivative |
  209. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  210. | **D2DY2** | 1 1 | d^2(A)/dy^2 2nd derivative |
  211. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  212. | **D2DXY** | 1 1 | d^2(A)/dxdy 2nd derivative |
  213. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  214. | **D2R** | 1 1 | Converts Degrees to Radians |
  215. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  216. | **DDX** | 1 1 | d(A)/dx Central 1st derivative |
  217. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  218. | **DAYNIGHT** | 3 1 | 1 where sun at (A, B) shines and 0 elsewhere, with C transition width |
  219. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  220. | **DDY** | 1 1 | d(A)/dy Central 1st derivative |
  221. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  222. | **DEG2KM** | 1 1 | Converts Spherical Degrees to Kilometers |
  223. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  224. | **DENAN** | 2 1 | Replace NaNs in A with values from B |
  225. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  226. | **DILOG** | 1 1 | dilog (A) |
  227. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  228. | **DIV** | 2 1 | A / B |
  229. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  230. | **DOT** | 2 1 | 2-D (Cartesian) or 3-D (geographic) dot products between nodes and stack (A, B) unit vector(s) |
  231. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  232. | **DUP** | 1 2 | Places duplicate of A on the stack |
  233. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  234. | **ECDF** | 2 1 | Exponential cumulative distribution function for x = A and lambda = B |
  235. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  236. | **ECRIT** | 2 1 | Exponential distribution critical value for alpha = A and lambda = B |
  237. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  238. | **EPDF** | 2 1 | Exponential probability density function for x = A and lambda = B |
  239. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  240. | **ERF** | 1 1 | Error function erf (A) |
  241. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  242. | **ERFC** | 1 1 | Complementary Error function erfc (A) |
  243. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  244. | **EQ** | 2 1 | 1 if A == B, else 0 |
  245. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  246. | **ERFINV** | 1 1 | Inverse error function of A |
  247. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  248. | **EXCH** | 2 2 | Exchanges A and B on the stack |
  249. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  250. | **EXP** | 1 1 | exp (A) |
  251. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  252. | **FACT** | 1 1 | A! (A factorial) |
  253. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  254. | **EXTREMA** | 1 1 | Local Extrema: +2/-2 is max/min, +1/-1 is saddle with max/min in x, 0 elsewhere |
  255. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  256. | **FCDF** | 3 1 | F cumulative distribution function for F = A, nu1 = B, and nu2 = C |
  257. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  258. | **FCRIT** | 3 1 | F distribution critical value for alpha = A, nu1 = B, and nu2 = C |
  259. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  260. | **FLIPLR** | 1 1 | Reverse order of values in each row |
  261. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  262. | **FLIPUD** | 1 1 | Reverse order of values in each column |
  263. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  264. | **FLOOR** | 1 1 | floor (A) (greatest integer <= A) |
  265. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  266. | **FMOD** | 2 1 | A % B (remainder after truncated division) |
  267. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  268. | **FPDF** | 3 1 | F probability density function for F = A, nu1 = B, and nu2 = C |
  269. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  270. | **GE** | 2 1 | 1 if A >= B, else 0 |
  271. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  272. | **GT** | 2 1 | 1 if A > B, else 0 |
  273. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  274. | **HSV2RGB** | 3 3 | Convert h,s,v triplets to r,g,b triplets, with h = A (0-360), s = B and v = C (both in 0-1) |
  275. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  276. | **HSV2RGB** | 3 3 | Convert h,s,v triplets to r,g,b triplets, with h = A (0-360), s = B and v = C (0-1) |
  277. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  278. | **HSV2XYZ** | 3 3 | Convert h,s,v triplets to x,t,z triplets, with h = A (0-360), s = B and v = C (0-1) |
  279. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  280. | **HYPOT** | 2 1 | hypot (A, B) = sqrt (A\*A + B\*B) |
  281. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  282. | **I0** | 1 1 | Modified Bessel function of A (1st kind, order 0) |
  283. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  284. | **I1** | 1 1 | Modified Bessel function of A (1st kind, order 1) |
  285. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  286. | **IFELSE** | 3 1 | B if A != 0, else C |
  287. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  288. | **IN** | 2 1 | Modified Bessel function of A (1st kind, order B) |
  289. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  290. | **INRANGE** | 3 1 | 1 if B <= A <= C, else 0 |
  291. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  292. | **INSIDE** | 1 1 | 1 when inside or on polygon(s) in A, else 0 |
  293. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  294. | **INV** | 1 1 | 1 / A |
  295. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  296. | **ISFINITE** | 1 1 | 1 if A is finite, else 0 |
  297. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  298. | **ISNAN** | 1 1 | 1 if A == NaN, else 0 |
  299. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  300. | **J0** | 1 1 | Bessel function of A (1st kind, order 0) |
  301. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  302. | **J1** | 1 1 | Bessel function of A (1st kind, order 1) |
  303. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  304. | **JN** | 2 1 | Bessel function of A (1st kind, order B) |
  305. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  306. | **K0** | 1 1 | Modified Kelvin function of A (2nd kind, order 0) |
  307. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  308. | **K1** | 1 1 | Modified Bessel function of A (2nd kind, order 1) |
  309. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  310. | **KEI** | 1 1 | kei (A) |
  311. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  312. | **KER** | 1 1 | ker (A) |
  313. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  314. | **KM2DEG** | 1 1 | Converts Kilometers to Spherical Degrees |
  315. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  316. | **KN** | 2 1 | Modified Bessel function of A (2nd kind, order B) |
  317. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  318. | **KURT** | 1 1 | Kurtosis of A |
  319. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  320. | **LAB2HSV** | 3 3 | Convert l,a,b triplets to h,s,v triplets |
  321. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  322. | **LAB2RGB** | 3 3 | Convert l,a,b triplets to r,g,b triplets |
  323. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  324. | **LAB2XYZ** | 3 3 | Convert l,a,b triplets to x,y,z triplets |
  325. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  326. | **LCDF** | 1 1 | Laplace cumulative distribution function for z = A |
  327. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  328. | **LCRIT** | 1 1 | Laplace distribution critical value for alpha = A |
  329. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  330. | **LDIST** | 1 1 | Compute minimum distance (in km if -fg) from lines in multi-segment ASCII file A |
  331. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  332. | **LDIST2** | 2 1 | As LDIST, from lines in ASCII file B but only to nodes where A != 0 |
  333. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  334. | **LDISTG** | 0 1 | As LDIST, but operates on the GSHHG dataset (see -A, -D for options). |
  335. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  336. | **LE** | 2 1 | 1 if A <= B, else 0 |
  337. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  338. | **LOG** | 1 1 | log (A) (natural log) |
  339. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  340. | **LOG10** | 1 1 | log10 (A) (base 10) |
  341. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  342. | **LOG1P** | 1 1 | log (1+A) (accurate for small A) |
  343. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  344. | **LOG2** | 1 1 | log2 (A) (base 2) |
  345. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  346. | **LMSSCL** | 1 1 | LMS (Least Median of Squares) scale estimate (LMS STD) of A |
  347. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  348. | **LMSSCLW** | 2 1 | Weighted LMS (Least Median of Squares) scale estimate (LMS STD) of A for weights in B |
  349. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  350. | **LOWER** | 1 1 | The lowest (minimum) value of A |
  351. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  352. | **LPDF** | 1 1 | Laplace probability density function for z = A |
  353. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  354. | **LRAND** | 2 1 | Laplace random noise with mean A and std. deviation B |
  355. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  356. | **LT** | 2 1 | 1 if A < B, else 0 |
  357. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  358. | **MAD** | 1 1 | Median Absolute Deviation (L1 STD) of A |
  359. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  360. | **MAX** | 2 1 | Maximum of A and B |
  361. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  362. | **MEAN** | 1 1 | Mean value of A |
  363. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  364. | **MEANW** | 2 1 | Weighted mean value of A for weights in B |
  365. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  366. | **MEDIAN** | 1 1 | Median value of A |
  367. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  368. | **MEDIANW** | 2 1 | Weighted median value of A for weights in B |
  369. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  370. | **MIN** | 2 1 | Minimum of A and B |
  371. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  372. | **MOD** | 2 1 | A mod B (remainder after floored division) |
  373. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  374. | **MODE** | 1 1 | Mode value (Least Median of Squares) of A |
  375. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  376. | **MODEW** | 2 1 | Weighted mode value (Least Median of Squares) of A for weights in B |
  377. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  378. | **MUL** | 2 1 | A \* B |
  379. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  380. | **NAN** | 2 1 | NaN if A == B, else A |
  381. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  382. | **NEG** | 1 1 | -A |
  383. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  384. | **NEQ** | 2 1 | 1 if A != B, else 0 |
  385. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  386. | **NORM** | 1 1 | Normalize (A) so max(A)-min(A) = 1 |
  387. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  388. | **NOT** | 1 1 | NaN if A == NaN, 1 if A == 0, else 0 |
  389. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  390. | **NRAND** | 2 1 | Normal, random values with mean A and std. deviation B |
  391. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  392. | **OR** | 2 1 | NaN if B == NaN, else A |
  393. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  394. | **PCDF** | 2 1 | Poisson cumulative distribution function for x = A and lambda = B |
  395. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  396. | **PDIST** | 1 1 | Compute minimum distance (in km if -fg) from points in ASCII file A |
  397. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  398. | **PDIST2** | 2 1 | As PDIST, from points in ASCII file B but only to nodes where A != 0 |
  399. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  400. | **PERM** | 2 1 | Permutations n_P_r, with n = A and r = B |
  401. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  402. | **PLM** | 3 1 | Associated Legendre polynomial P(A) degree B order C |
  403. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  404. | **PLMg** | 3 1 | Normalized associated Legendre polynomial P(A) degree B order C (geophysical convention) |
  405. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  406. | **POINT** | 1 2 | Compute mean x and y from ASCII file A and place them on the stack |
  407. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  408. | **POP** | 1 0 | Delete top element from the stack |
  409. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  410. | **POW** | 2 1 | A ^ B |
  411. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  412. | **PPDF** | 2 1 | Poisson distribution P(x,lambda), with x = A and lambda = B |
  413. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  414. | **PQUANT** | 2 1 | The B'th Quantile (0-100%) of A |
  415. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  416. | **PQUANTW** | 3 1 | The C'th weighted quantile (0-100%) of A for weights in B |
  417. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  418. | **PSI** | 1 1 | Psi (or Digamma) of A |
  419. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  420. | **PV** | 3 1 | Legendre function Pv(A) of degree v = real(B) + imag(C) |
  421. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  422. | **QV** | 3 1 | Legendre function Qv(A) of degree v = real(B) + imag(C) |
  423. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  424. | **R2** | 2 1 | R2 = A^2 + B^2 |
  425. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  426. | **R2D** | 1 1 | Convert Radians to Degrees |
  427. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  428. | **RAND** | 2 1 | Uniform random values between A and B |
  429. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  430. | **RCDF** | 1 1 | Rayleigh cumulative distribution function for z = A |
  431. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  432. | **RCRIT** | 1 1 | Rayleigh distribution critical value for alpha = A |
  433. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  434. | **RGB2HSV** | 3 3 | Convert r,g,b triplets to h,s,v triplets, with r = A, g = B, and b = C (all in 0-255 range) |
  435. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  436. | **RGB2LAB** | 3 3 | Convert r,g,b triplets to l,a,b triplets, with r = A, g = B, and b = C (in 0-255 range) |
  437. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  438. | **RGB2XYZ** | 3 3 | Convert r,g,b triplets to x,y,x triplets, with r = A, g = B, and b = C (in 0-255 range) |
  439. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  440. | **RINT** | 1 1 | rint (A) (round to integral value nearest to A) |
  441. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  442. | **RMS** | 1 1 | Root-mean-square of A |
  443. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  444. | **RMSW** | 1 1 | Root-mean-square of A for weights in B |
  445. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  446. | **RPDF** | 1 1 | Rayleigh probability density function for z = A |
  447. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  448. | **ROLL** | 2 0 | Cyclicly shifts the top A stack items by an amount B |
  449. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  450. | **ROTX** | 2 1 | Rotate A by the (constant) shift B in x-direction |
  451. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  452. | **ROTY** | 2 1 | Rotate A by the (constant) shift B in y-direction |
  453. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  454. | **SDIST** | 2 1 | Spherical (Great circle|geodesic) distance (in km) between nodes and stack (A, B) |ex_SDIST| |
  455. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  456. | **SDIST2** | 2 1 | As SDIST but only to nodes that are != 0 |
  457. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  458. | **SAZ** | 2 1 | Spherical azimuth from grid nodes to stack lon, lat (i.e., A, B) |
  459. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  460. | **SBAZ** | 2 1 | Spherical back-azimuth from grid nodes to stack lon, lat (i.e., A, B) |
  461. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  462. | **SEC** | 1 1 | sec (A) (A in radians) |
  463. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  464. | **SECD** | 1 1 | sec (A) (A in degrees) |
  465. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  466. | **SIGN** | 1 1 | sign (+1 or -1) of A |
  467. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  468. | **SIN** | 1 1 | sin (A) (A in radians) |
  469. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  470. | **SINC** | 1 1 | sinc (A) (sin (pi\*A)/(pi\*A)) |
  471. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  472. | **SIND** | 1 1 | sin (A) (A in degrees) |
  473. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  474. | **SINH** | 1 1 | sinh (A) |
  475. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  476. | **SKEW** | 1 1 | Skewness of A |
  477. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  478. | **SQR** | 1 1 | A^2 |
  479. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  480. | **SQRT** | 1 1 | sqrt (A) |
  481. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  482. | **STD** | 1 1 | Standard deviation of A |
  483. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  484. | **STDW** | 2 1 | Weighted standard deviation of A for weights in B |
  485. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  486. | **STEP** | 1 1 | Heaviside step function: H(A) |
  487. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  488. | **STEPX** | 1 1 | Heaviside step function in x: H(x-A) |
  489. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  490. | **STEPY** | 1 1 | Heaviside step function in y: H(y-A) |
  491. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  492. | **SUB** | 2 1 | A - B |
  493. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  494. | **SUM** | 1 1 | Sum of all values in A |
  495. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  496. | **TAN** | 1 1 | tan (A) (A in radians) |
  497. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  498. | **TAND** | 1 1 | tan (A) (A in degrees) |
  499. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  500. | **TANH** | 1 1 | tanh (A) |
  501. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  502. | **TAPER** | 2 1 | Unit weights cosine-tapered to zero within A and B of x and y grid margins |
  503. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  504. | **TCDF** | 2 1 | Student's t cumulative distribution function for t = A, and nu = B |
  505. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  506. | **TCRIT** | 2 1 | Student's t distribution critical value for alpha = A and nu = B |
  507. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  508. | **TN** | 2 1 | Chebyshev polynomial Tn(-1<t<+1,n), with t = A, and n = B |
  509. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  510. | **TPDF** | 2 1 | Student's t probability density function for t = A, and nu = B |
  511. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  512. | **TRIM** | 3 1 | Alpha-trim C to NaN if values fall in tails A and B (in percentage) |
  513. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  514. | **UPPER** | 1 1 | The highest (maximum) value of A |
  515. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  516. | **VAR** | 1 1 | Variance of A |
  517. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  518. | **VARW** | 2 1 | Weighted variance of A for weights in B |
  519. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  520. | **WCDF** | 3 1 | Weibull cumulative distribution function for x = A, scale = B, and shape = C |
  521. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  522. | **WCRIT** | 3 1 | Weibull distribution critical value for alpha = A, scale = B, and shape = C |
  523. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  524. | **WPDF** | 3 1 | Weibull density distribution P(x,scale,shape), with x = A, scale = B, and shape = C |
  525. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  526. | **WRAP** | 1 1 | wrap A in radians onto [-pi,pi] |
  527. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  528. | **XOR** | 2 1 | 0 if A == NaN and B == NaN, NaN if B == NaN, else A |
  529. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  530. | **XYZ2HSV** | 3 3 | Convert x,y,x triplets to h,s,v triplets |
  531. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  532. | **XYZ2LAB** | 3 3 | Convert x,y,x triplets to l,a,b triplets |
  533. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  534. | **XYZ2RGB** | 3 3 | Convert x,y,x triplets to r,g,b triplets |
  535. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  536. | **Y0** | 1 1 | Bessel function of A (2nd kind, order 0) |
  537. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  538. | **Y1** | 1 1 | Bessel function of A (2nd kind, order 1) |
  539. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  540. | **YLM** | 2 2 | Re and Im orthonormalized spherical harmonics degree A order B |
  541. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  542. | **YLMg** | 2 2 | Cos and Sin normalized spherical harmonics degree A order B (geophysical convention) |
  543. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  544. | **YN** | 2 1 | Bessel function of A (2nd kind, order B) |
  545. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  546. | **ZCDF** | 1 1 | Normal cumulative distribution function for z = A |
  547. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  548. | **ZPDF** | 1 1 | Normal probability density function for z = A |
  549. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  550. | **ZCRIT** | 1 1 | Normal distribution critical value for alpha = A |
  551. +---------------+-------+--------------------------------------------------------------------------------------------------------+
  552. Symbols
  553. -------
  554. The following symbols have special meaning:
  555. +-------------+-------------------------------------------------+
  556. | **PI** | 3.1415926... |
  557. +-------------+-------------------------------------------------+
  558. | **E** | 2.7182818... |
  559. +-------------+-------------------------------------------------+
  560. | **EULER** | 0.5772156... |
  561. +-------------+-------------------------------------------------+
  562. | **PHI** | 1.6180339... (golden ratio) |
  563. +-------------+-------------------------------------------------+
  564. | **EPS_F** | 1.192092896e-07 (single precision epsilon |
  565. +-------------+-------------------------------------------------+
  566. | **XMIN** | Minimum x value |
  567. +-------------+-------------------------------------------------+
  568. | **XMAX** | Maximum x value |
  569. +-------------+-------------------------------------------------+
  570. | **XRANGE** | Range of x values |
  571. +-------------+-------------------------------------------------+
  572. | **XINC** | x increment |
  573. +-------------+-------------------------------------------------+
  574. | **NX** | The number of x nodes |
  575. +-------------+-------------------------------------------------+
  576. | **YMIN** | Minimum y value |
  577. +-------------+-------------------------------------------------+
  578. | **YMAX** | Maximum y value |
  579. +-------------+-------------------------------------------------+
  580. | **YRANGE** | Range of y values |
  581. +-------------+-------------------------------------------------+
  582. | **YINC** | y increment |
  583. +-------------+-------------------------------------------------+
  584. | **NY** | The number of y nodes |
  585. +-------------+-------------------------------------------------+
  586. | **X** | Grid with x-coordinates |
  587. +-------------+-------------------------------------------------+
  588. | **Y** | Grid with y-coordinates |
  589. +-------------+-------------------------------------------------+
  590. | **XNORM** | Grid with normalized [-1 to +1] x-coordinates |
  591. +-------------+-------------------------------------------------+
  592. | **YNORM** | Grid with normalized [-1 to +1] y-coordinates |
  593. +-------------+-------------------------------------------------+
  594. | **XCOL** | Grid with column numbers 0, 1, ..., NX-1 |
  595. +-------------+-------------------------------------------------+
  596. | **YROW** | Grid with row numbers 0, 1, ..., NY-1 |
  597. +-------------+-------------------------------------------------+
  598. | **NODE** | Grid with node numbers 0, 1, ..., (NX*NY)-1 |
  599. +-------------+-------------------------------------------------+
  600. | **NODEP** | Grid with node numbers in presence of pad |
  601. +-------------+-------------------------------------------------+
  602. Notes On Operators
  603. ------------------
  604. #. For Cartesian grids the operators **MEAN**, **MEDIAN**, **MODE**,
  605. **LMSSCL**, **MAD**, **PQUANT**, **RMS**, **STD**, and **VAR** return the
  606. expected value from the given matrix. However, for geographic grids
  607. we perform a spherically weighted calculation where each node value
  608. is weighted by the geographic area represented by that node.
  609. #. The operator **SDIST** calculates spherical distances in km between the
  610. (lon, lat) point on the stack and all node positions in the grid. The
  611. grid domain and the (lon, lat) point are expected to be in degrees.
  612. Similarly, the **SAZ** and **SBAZ** operators calculate spherical
  613. azimuth and back-azimuths in degrees, respectively. The operators
  614. **LDIST** and **PDIST** compute spherical distances in km if **-fg** is
  615. set or implied, else they return Cartesian distances. **Note**: If the current
  616. :term:`PROJ_ELLIPSOID` is ellipsoidal then
  617. geodesics are used in calculations of distances, which can be slow.
  618. You can trade speed with accuracy by changing the algorithm used to
  619. compute the geodesic (see :ref:`PROJ_GEODESIC <Projection Parameters>`).
  620. The operator **LDISTG** is a version of **LDIST** that operates on the
  621. GSHHG data. Instead of reading an ASCII file, it directly accesses one of
  622. the GSHHG data sets as determined by the **-D** and **-A** options.
  623. #. The operator **POINT** reads a ASCII table, computes the mean x and mean
  624. y values and places these on the stack. If geographic data then we use
  625. the mean 3-D vector to determine the mean location.
  626. #. The operator **PLM** calculates the associated Legendre polynomial
  627. of degree L and order M (0 <= M <= L), and its argument is the sine of
  628. the latitude. **PLM** is not normalized and includes the Condon-Shortley
  629. phase (-1)^M. **PLMg** is normalized in the way that is most commonly
  630. used in geophysics. The C-S phase can be added by using -M as argument.
  631. **PLM** will overflow at higher degrees, whereas **PLMg** is stable
  632. until ultra high degrees (at least 3000).
  633. #. The operators **YLM** and **YLMg** calculate normalized spherical
  634. harmonics for degree L and order M (0 <= M <= L) for all positions in
  635. the grid, which is assumed to be in degrees. **YLM** and **YLMg** return
  636. two grids, the real (cosine) and imaginary (sine) component of the
  637. complex spherical harmonic. Use the **POP** operator (and **EXCH**) to
  638. get rid of one of them, or save both by giving two consecutive = file.nc calls.
  639. The orthonormalized complex harmonics **YLM** are most commonly used in
  640. physics and seismology. The square of **YLM** integrates to 1 over a
  641. sphere. In geophysics, **YLMg** is normalized to produce unit power when
  642. averaging the cosine and sine terms (separately!) over a sphere (i.e.,
  643. their squares each integrate to 4 pi). The Condon-Shortley phase (-1)^M
  644. is not included in **YLM** or **YLMg**, but it can be added by using -M
  645. as argument.
  646. #. All the derivatives are based on central finite differences, with
  647. natural boundary conditions, and are Cartesian derivatives.
  648. #. Files that have the same names as some operators, e.g., **ADD**,
  649. **SIGN**, **=**, etc. should be identified by prepending the current
  650. directory (i.e., ./LOG).
  651. #. Piping of files is not allowed.
  652. #. The stack depth limit is hard-wired to 100.
  653. #. All functions expecting a positive radius (e.g., **LOG**, **KEI**,
  654. etc.) are passed the absolute value of their argument. (9) The bitwise
  655. operators (**BITAND**, **BITLEFT**, **BITNOT**, **BITOR**, **BITRIGHT**,
  656. **BITTEST**, and **BITXOR**) convert a grid's single precision values to
  657. unsigned 32-bit ints to perform the bitwise operations. Consequently,
  658. the largest whole integer value that can be stored in a float grid is
  659. 2^24 or 16,777,216. Any higher result will be masked to fit in the lower
  660. 24 bits. Thus, bit operations are effectively limited to 24 bit. All
  661. bitwise operators return NaN if given NaN arguments or bit-settings <= 0.
  662. #. When OpenMP support is compiled in, a few operators will take advantage
  663. of the ability to spread the load onto several cores. At present, the
  664. list of such operators is: **LDIST**, **LDIST2**, **PDIST**, **PDIST2**,
  665. **SAZ**, **SBAZ**, **SDIST**, **YLM**, and **grd_YLMg**.
  666. #. Operators **DEG2KM** and **KM2DEG** are only exact when a spherical Earth
  667. is selected with :term:`PROJ_ELLIPSOID`.
  668. #. Operator **DOT** normalizes 2-D vectors before the dot-product takes place.
  669. For 3-D vector they are all unit vectors to begin with.
  670. #. The color-triplet conversion functions (**RGB2HSV**, etc.) includes not
  671. only r,g,b and h,s,v triplet conversions, but also l,a,b (CIE L a b ) and
  672. sRGB (x, y, z) conversions between all four color spaces.
  673. #. The DAYNIGHT operator returns a grid with ones on the side facing the given
  674. sun location at (A,B). If the transition width (C) is zero then we get
  675. either 1 or 0, but if C is nonzero then we approximate the step function
  676. using an atan-approximation instead. Thus, the values are never exactly
  677. 0 or 1, but close, and the smaller C the closer we get.
  678. .. include:: explain_float.rst_
  679. .. include:: explain_grd_inout_short.rst_
  680. .. include:: explain_grd_coord.rst_
  681. .. include:: explain_sto_rcl_clr.rst_
  682. .. include:: explain_gshhg.rst_
  683. .. include:: explain_inside.rst_
  684. Macros
  685. ------
  686. Users may save their favorite operator combinations as macros via the
  687. file *grdmath.macros* in their current or user directory. The file may contain
  688. any number of macros (one per record); comment lines starting with # are
  689. skipped. The format for the macros is **name** = **arg1 arg2 ... arg2**
  690. : *comment* where **name** is how the macro will be used. When this
  691. operator appears on the command line we simply replace it with the
  692. listed argument list. No macro may call another macro. As an example,
  693. the following macro expects three arguments (radius x0 y0) and sets the
  694. modes that are inside the given circle to 1 and those outside to 0:
  695. INCIRCLE = CDIST EXCH DIV 1 LE : usage: r x y INCIRCLE to return 1
  696. inside circle
  697. **Note**: Because geographic or time constants may be present in a macro, it
  698. is required that the optional comment flag (:) must be followed by a space.
  699. Examples
  700. --------
  701. .. include:: explain_example.rst_
  702. To compute all distances to north pole, try::
  703. gmt grdmath -Rg -I1 0 90 SDIST = dist_to_NP.nc
  704. To take log10 of the average of 2 files, use::
  705. gmt grdmath file1.nc file2.nc ADD 0.5 MUL LOG10 = file3.nc
  706. Given the file ages.nc, which holds seafloor ages in m.y., use the
  707. relation depth(in m) = 2500 + 350 \* sqrt (age) to estimate normal seafloor depths, try::
  708. gmt grdmath ages.nc SQRT 350 MUL 2500 ADD = depths.nc
  709. To find the angle a (in degrees) of the largest principal stress from
  710. the stress tensor given by the three files s_xx.nc s_yy.nc, and
  711. s_xy.nc from the relation tan (2\*a) = 2 \* s_xy / (s_xx - s_yy), use::
  712. gmt grdmath 2 s_xy.nc MUL s_xx.nc s_yy.nc SUB DIV ATAN 2 DIV = direction.nc
  713. To calculate the fully normalized spherical harmonic of degree 8 and
  714. order 4 on a 1 by 1 degree world map, using the real amplitude 0.4 and
  715. the imaginary amplitude 1.1, use::
  716. gmt grdmath -R0/360/-90/90 -I1 8 4 YLM 1.1 MUL EXCH 0.4 MUL ADD = harm.nc
  717. To extract the locations of local maxima that exceed 100 mGal in the file faa.nc, use::
  718. gmt grdmath faa.nc DUP EXTREMA 2 EQ MUL DUP 100 GT MUL 0 NAN = z.nc
  719. gmt grd2xyz z.nc -s > max.xyz
  720. To demonstrate the use of named variables, consider this radial wave
  721. where we store and recall the normalized radial arguments in radians by::
  722. gmt grdmath -R0/10/0/10 -I0.25 5 5 CDIST 2 MUL PI MUL 5 DIV STO@r COS @r SIN MUL = wave.nc
  723. To create a dumb file saved as a 32 bits float GeoTiff using GDAL, run::
  724. gmt grdmath -Rd -I10 X Y MUL = lixo.tiff=gd:GTiff
  725. To compute distances in km from the line trace.txt for the area represented by the
  726. geographic grid data.grd, run::
  727. gmt grdmath -Rdata.grd trace.txt LDIST = dist_from_line.grd
  728. To demonstrate the stack-reducing effect of **-S**, we compute the standard deviation
  729. per node of all the grids matching the name model_*.grd using::
  730. gmt grdmath model_*.grd -S STD = std_of_models.grd
  731. To create a geotiff with resolution 0.5x0.5 degrees with distances in km from the coast line, use::
  732. grdmath -RNO,IS -Dc -I.5 LDISTG = distance.tif=gd:GTIFF
  733. References
  734. ----------
  735. Abramowitz, M., and I. A. Stegun, 1964, *Handbook of Mathematical
  736. Functions*, Applied Mathematics Series, vol. 55, Dover, New York.
  737. Holmes, S. A., and W. E. Featherstone, 2002, A unified approach to the
  738. Clenshaw summation and the recursive computation of very high degree and
  739. order normalized associated Legendre functions. *Journal of Geodesy*,
  740. 76, 279-299.
  741. Press, W. H., S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery,
  742. 1992, *Numerical Recipes*, 2nd edition, Cambridge Univ., New York.
  743. Spanier, J., and K. B. Oldman, 1987, *An Atlas of Functions*, Hemisphere
  744. Publishing Corp.
  745. See Also
  746. --------
  747. :doc:`gmt`, :doc:`gmtmath`,
  748. :doc:`grd2xyz`, :doc:`grdedit`,
  749. :doc:`grdinfo`, :doc:`xyz2grd`
  750. .. ------------------------------------- Examples per option -------------------
  751. .. |ex_SDIST| raw:: html
  752. <a href="#openModal">Example</a>
  753. <div id="openModal" class="modalDialog">
  754. <div>
  755. <a href="#close" title="Close" class="close">X</a>
  756. <h2>To compute all distances to north pole:</h2>
  757. <p>gmt grdmath -Rg -I1 0 90 SDIST = dist_to_NP.nc</br></p>
  758. </div>
  759. </div>
Tip!

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

Comments

Loading...