rdbrowop - perform arithmetic operations between rows within a column
rdbrowop options < input stream > output stream [columns]
rdbrowop --input=input stream --output=output stream [columns]
rdbrowop performes arithmetic and cumulative arithmetic operations within a column between the values in adjacent rows.
The input and output RDB tables are by default read and written to the standard input and output streams, but may be specified via the --input and --output command line options.
By default all columns are operated on; to operate on only a subset, specify them as individual arguments at the end of the command line. Regular expressions may be used to select columns; see the --re and --RE options.
The results are written as new columns to the table. See the --prefix option for how they are named. In the case of simple arithmetic operations, two columns are produced for each input column:
value(next row) OP value(current row) value(current row) OP value(previous row)
The values stored in the first row are
value(second row) OP value(first row) value(second row) OP value(first row)
Values stored in the last row are
value(last row) OP value(next to last row) value(last row) OP value(next to last row)
For cumulative operations, a single new column is produced:
value(current row) OP value(previous row)
For the first row multiplicative operations use 1 as the previous
value; additive operations use 0 as the previous value.
Options are specified using a UNIX getopt style interface. Long names are available when preceded with double hyphens ``--'', in which case only the minimal number of characters are required. Options which take values may be separated from those values with either white space or the ``='' character.
This option allows the specification of the prefix; it defaults to d_.
The suffices are hardwired as _p and _n, for the values of operations with the previous and next rows, respectively.
+ - / *
Cumulative operations are:
+= -= /= *=
rdbrowop --op=- < input.rdb > output.rdbCalculate differences for specfic columns:
rdbrowop --op=- < input.rdb > output.rdb energyGenerate bin edges, assuming the bin center is given:
< input.rdb \
rdbrowop \
--op=- \
energy \
| column -v -a emin N -a emax N \
| compute \
d_energy_p /= 2 \;\
d_energy_n /= 2 \;\
emin = energy - d_energy_p \;\
emax = energy + d_energy_n \
> output.rdb
Generate a cumulative sum:
rdbrowop --op += < input.rdb > output.rdb number_of_rose_petals
rdbrowop uses the RDB Perl class, and so isn't as fast as it might be.
Diab Jerius <djerius@cfa.harvard.edu>
Copyright (C) 2004 by the Smithsonian Astrophysical Observatory
This software is released under the GNU General Public License. You may find a copy at http://www.fsf.org/copyleft/gpl.html.