File: gmtmath.html

package info (click to toggle)
gmt-doc 3.4-1.1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 4,756 kB
  • ctags: 1,800
  • sloc: makefile: 30
file content (294 lines) | stat: -rw-r--r-- 12,421 bytes parent folder | download | duplicates (2)
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
<HTML>
<HEAD>
<TITLE>gmtmath</TITLE>
</HEAD>
<BODY>
<H1>gmtmath</H1>
<HR>
<PRE>
<!-- Manpage converted by man2html 3.0.1 -->
       gmtmath  -  Reverse  Polish  Notation  calculator for data
       tables


</PRE>
<H2>SYNOPSIS</H2><PRE>
       <B>gmtmath</B> [ <B>-C</B><I>cols</I> ] [ <B>-H</B><I>nrec</I> ] [ <B>-N</B><I>n</I><B>_</B><I>col</I>/<I>t</I><B>_</B><I>col</I> ] [ <B>-Q</B> ]
        [ <B>-S</B> ][ <B>-T</B><I>t</I><B>_</B><I>min/t</I><B>_</B><I>max/t</I><B>_</B><I>inc</I> ] [ <B>-V</B>  ]  [  <B>-bi</B>[<B>s</B>][<I>n</I>]  ]  [
       <B>-bo</B>[<B>s</B>] ] <I>operand</I> [ <I>operand</I> ] <B>OPERATOR</B> [ <I>operand</I> ] <B>OPERATOR</B>
       ... <B>=</B> [ <I>outfile</I> ]


</PRE>
<H2>DESCRIPTION</H2><PRE>
       <B>gmtmath</B> will perform operations like add, subtract, multi
       ply,  and  divide  on one or more table data files or con
       stants using Reverse Polish Notation (RPN)  syntax  (e.g.,
       Hewlett-Packard calculator-style). Arbitrarily complicated
       expressions may therefore be evaluated; the  final  result
       is  written  to  an output file [or standard output]. When
       two data tables are on the stack, each element in  file  A
       is  modified by the corresponding element in file B.  How
       ever, some operators only require one operand (see below).
       If  no data tables are used in the expression then options
       <B>-T,</B> <B>-N</B> must be set (and optionally <B>-b</B>).  By  default,  all
       columns except the "time" column are operated on, but this
       can be changed (see <B>-C</B>).

       <I>operand</I>
              If <I>operand</I> can be opened as a file it will be  read
              as  an  ASCII (or binary, see <B>-bi</B>) table data file.
              If not a file, it is  interpreted  as  a  numerical
              constant or a special symbol (see below).

       <I>outfile</I>  is a table data file that will hold the final
       result. If not given then
              the output is sent to stdout.

       <B>OPERATORS</B>
              Choose among the following operators:
              Operator n_args Returns

              <B>ABS</B> 1 abs (A).
              <B>ACOS</B> 1 acos (A).
              <B>ACOSH</B> 1 acosh (A).
              <B>ADD(+)</B> 2 A + B.
              <B>AND</B> 2 NaN if A and B == NaN, B if A == NaN, else A.
              <B>ASIN</B> 1 asin (A).
              <B>ASINH</B> 1 asinh (A).
              <B>ATAN</B> 1 atan (A).
              <B>ATAN2</B> 2 atan2 (A, B).
              <B>ATANH</B> 1 atanh (A).
              <B>BEI</B> 1 bei (A).
              <B>BER</B> 1 ber (A).
              <B>CEIL</B> 1 ceil (A) (smallest integer &gt;= A).
              <B>CHIDIST</B> 2 Chi-squared-distribution P(chi2,n),  with
              <B>COSD</B> 1 cos (A) (A in degrees).
              <B>COSH</B> 1 cosh (A).
              <B>D2DT2</B> 1 d^2(A)/dt^2 2nd derivative.
              <B>D2R</B> 1 Converts Degrees to Radians.
              <B>DILOG</B> 1 Dilog (A).
              <B>DIV(/)</B> 2 A / B.
              <B>DDT</B> 1 d(A)/dt 1st derivative.
              <B>DUP</B> 1 Places duplicate of A on the stack.
              <B>ERF</B> 1 Error function of A.
              <B>ERFC</B> 1 Complimentory Error function of A.
              <B>ERFINV</B> 1 Inverse error function of A.
              <B>EQ</B> 2 1 if A == B, else 0.
              <B>EXCH</B> 2 Exchanges A and B on the stack.
              <B>EXP</B> 1 exp (A).
              <B>FDIST</B> 4 F-distribution Q(s1,s2,n1,n2), with s1 = A,
              s2 = B, n1 = C, and n2 = D.
              <B>FLOOR</B> 1 floor (A) (greatest integer &lt;= A).
              <B>FMOD</B> 2 A % B (remainder).
              <B>GE</B> 2 1 if A &gt;= B, else 0.
              <B>GT</B> 2 1 if A &gt; B, else 0.
              <B>HYPOT</B> 2 hypot (A, B).
              <B>I0</B> 1 Modified Bessel function of A (1st kind, order
              0).
              <B>I1</B> 1 Modified Bessel function of A (1st kind, order
              1).
              <B>IN</B> 2 Modified Bessel function of A (1st kind, order
              B).
              <B>INT</B> 1 Numerically integrate A.
              <B>INV</B> 1 1 / A.
              <B>ISNAN</B> 1 1 if A == NaN, else 0.
              <B>J0</B> 1 Bessel function of A (1st kind, order 0).
              <B>J1</B> 1 Bessel function of A (1st kind, order 1).
              <B>JN</B> 2 Bessel function of A (1st kind, order B).
              <B>K0</B> 1 Modified Kelvin function of A (2nd kind, order
              0).
              <B>K1</B> 1 Modified Bessel function of A (2nd kind, order
              1).
              <B>KN</B> 2 Modified Bessel function of A (2nd kind, order
              B).
              <B>KEI</B> 1 kei (A).
              <B>KER</B> 1 ker (A).
              <B>LE</B> 2 1 if A &lt;= B, else 0.
              <B>LMSSCL</B> 1 LMS scale estimate (LMS STD) of A.
              <B>LOG</B> 1 log (A) (natural log).
              <B>LOG10</B> 1 log10 (A).
              <B>LOG1P</B> 1 log (1+A) (accurate for small A).
              <B>LOWER</B> 1 The lowest (minimum) value of A.
              <B>LT</B> 2 1 if A &lt; B, else 0.
              <B>MAD</B> 1 Median Absolute Deviation (L1 STD) of A.
              <B>MAX</B> 2 Maximum of A and B.
              <B>MEAN</B> 1 Mean value of A.
              <B>MED</B> 1 Median value of A.
              <B>MUL(x)</B> 2 A * B.
              <B>NAN</B> 2 NaN if A == B, else A.
              <B>NEG</B> 1 -A.
              <B>NRAND</B> 2 Normal, random values with mean A and  std.
              deviation B.
              <B>OR</B> 2 NaN if A or B == NaN, else A.
              <B>PLM</B>  3  Associated  Legendre  polynomial P(-1&lt;A<+1)
              degree B order C.
              <B>POP</B> 1 Delete top element from the stack.
              <B>POW(^)</B> 2 A ^ B.
              <B>R2</B> 2 R2 = A^2 + B^2.
              <B>R2D</B> 1 Convert Radians to Degrees.
              <B>RAND</B> 2 Uniform random values between A and B.
              <B>RINT</B> 1 rint (A) (nearest integer).
              <B>SIGN</B> 1 sign (+1 or -1) of A.
              <B>SIN</B> 1 sin (A) (A in radians).
              <B>SIND</B> 1 sin (A) (A in degrees).
              <B>SINH</B> 1 sinh (A).
              <B>SQRT</B> 1 sqrt (A).
              <B>STD</B> 1 Standard deviation of A.
              <B>STEP</B> 1 Heaviside step function H(A).
              <B>STEPT</B> 1 Heaviside step function H(t-A).
              <B>SUB(-)</B> 2 A - B.
              <B>SUM</B> 1 Cumulative sum of A
              <B>TAN</B> 1 tan (A) (A in radians).
              <B>TAND</B> 1 tan (A) (A in degrees).
              <B>TANH</B> 1 tanh (A).
              <B>TDIST</B> 2 Student's t-distribution A(t,n), with  t  =
              A, and n = B).'
              <B>UPPER</B> 1 The highest (maximum) value of A.
              <B>XOR</B> 2 B if A == NaN, else A.
              <B>Y0</B> 1 Bessel function of A (2nd kind, order 0).
              <B>Y1</B> 1 Bessel function of A (2nd kind, order 1).
              <B>YN</B> 2 Bessel function of A (2nd kind, order B).

       <B>SYMBOLS</B>
              The following symbols have special meaning:

              <B>PI</B> 3.1415926...
              <B>E</B>  2.7182818...
              <B>T</B>  Table with t-coordinates


</PRE>
<H2>OPTIONS</H2><PRE>
       <B>-C</B>     Select  the  columns that will be operated on until
              next occurrence of <B>-C</B>.  List columns  separated  by
              commas;  ranges  like  1,3-5,7 are allowed. [<B>-C</B> (no
              arguments) resets the default action of  using  all
              columns  except  time column (see <B>-N</B>].  <B>-Ca</B> selects
              all  columns,  inluding  time  column,  while   <B>-Cr</B>
              reverses (toggles) the current choices.

       <B>-H</B>     Input  file(s)  has  Header  record(s).  Number  of
              record.

       <B>-N</B>     Select the number of columns and the column  number
              that contains the "time" variable. Columns are num
              bered starting at 0 [2/0].

       <B>-Q</B>     Quick mode for scalar  calculation.  Shorthand  for
              <B>-Ca</B> <B>-N</B>1/0 <B>-T</B>0/0/1.

       <B>-S</B>     Only  report  the first row of the results [Default
              is all rows]. This is useful if you have computed a
              statistic  (say the MODE) and only want to report a
              single number  instead  of  numerous  records  with
              idendical values.

       <B>-T</B>     Required when no input files are given. Sets the t-
              coordinates of the first and  last  point  and  the
              equidistant sampling interval for the "time" column
              (see <B>-N</B>).  If there is no time  column  (only  data
              columns),  give  <B>-T</B>  with  no  arguments; this also
              implies <B>-Ca</B>.

       <B>-V</B>     Selects verbose  mode,  which  will  send  progress
              reports to stderr [Default runs "silently"].

       <B>-bi</B>    Selects binary input. Append <B>s</B> for single precision
              [Default is double].  Append <I>n</I> for  the  number  of
              columns in the binary file(s).

       <B>-bo</B>    Selects  binary  output. Append <B>s</B> for single preci
              sion [Default is double].


</PRE>
<H2>BEWARE</H2><PRE>
       The operator <B>PLM</B> calculates the associated Legendre  poly
       nomial  of  degree  L and order M, and its argument is the
       cosine of the colatitude which must satisfy -1 &lt;= x &lt;= +1.
       <B>PLM</B> is not normalized.
       All  derivatives  are based on central finite differences,
       with natural boundary conditions.


</PRE>
<H2>EXAMPLES</H2><PRE>
       To take log10 of the average of 2 data files, use
               gmtmath  file1.d  file2.d  <B>ADD</B>  0.5  <B>MUL</B>  <B>LOG10</B>  <B>=</B>
       file3.d

       Given  the  file  samples.d,  which holds seafloor ages in
       m.y. and seafloor depth in m, use the relation depth(in m)
       = 2500 + 350 * sqrt (age) to print the depth anomalies:
               gmtmath  samples.d T <B>SQRT</B> 350 <B>MUL</B> 2500 <B>ADD</B> <B>SUB</B> <B>=</B> |
       lpr

       To take the average of columns 1 and 4-6 in the three data
       <B>DIV</B> <B>=</B> ave.d

       To take the 1-column data set  ages.d  and  calculate  the
       modal value and assign it to a variable, try
               set mode_age = `gmtmath <B>-S</B> <B>-T</B> ages.d <B>MODE</B> <B>=</B>`

       To  use  gmtmath  as  a  RPN Hewlett-Packard calculator on
       scalars (i.e., no input  files)  and  calculate  arbitrary
       expressions,  use  the  <B>-Q</B> option.  As an example, we will
       calculate the value of Kei (((1 + 1.75)/2.2) +  cos  (60))
       and store the result in the shell variable z:

               set z = `gmtmath <B>-Q</B> 1 1.75 <B>ADD</B> 2.2 <B>DIV</B> 60 <B>COSD</B> <B>ADD</B>
       <B>KEI</B> <B>=</B>`


</PRE>
<H2>BUGS</H2><PRE>
       Files that have the same name  as  some  operators,  e.g.,
       ADD,  SIGN, =, etc. cannot be read and must not be present
       in the current directory. Piping of files is  not  allowed
       on input, but the output can be sent to stdout.  The stack
       limit is hard-wired to 50.  All functions expecting a pos
       itive  radius  (e.g., log, kei, etc.) are passed the abso
       lute value of their argument.


</PRE>
<H2>REFERENCES</H2><PRE>
       Abramowitz, M., and I. A. Stegun, 1964, <I>Handbook</I> <I>of</I> <I>Mathe</I>
       <I>matical</I>  <I>Functions</I>,  Applied  Mathematics Series, vol. 55,
       Dover, New York.
       Press, W. H., S. A. Teukolsky, W.  T.  Vetterling,  B.  P.
       Flannery,  1992, <I>Numerical</I> <I>Recipes</I>, 2nd edition, Cambridge
       Univ., New York.


</PRE>
<H2>SEE ALSO</H2><PRE>
       <I>gmt</I>(l), <I><A HREF="grd2xyz.html">grd2xyz</A></I>(l),  <I><A HREF="grdedit.html">grdedit</A></I>(l),  <I><A HREF="grdinfo.html">grdinfo</A></I>(l),  <I><A HREF="grdmath.html">grdmath</A></I>(l),
       <I><A HREF="xyz2grd.html">xyz2grd</A></I>(l)

















</PRE>
<HR>
<ADDRESS>
Man(1) output converted with
<a href="http://www.oac.uci.edu/indiv/ehood/man2html.html">man2html</a>
</ADDRESS>
</BODY>
</HTML>
<body bgcolor="#ffffff">