FITS Table Calculator

The calculator tool can be used to perform spread-sheet type calculations on columns in a FITS table. The expression is evaluated on each row of the table and the result is written either to an existing column in the table (overwriting the previous values), or to a new column. If "Apply only to selected rows" was checked, it will applied only to the selected rows in table.

Results Column

The entry field on the left hand side of the "=" sign is used to specify the name of the column to which the results will be written. Click on the the 'down arrow' icon to bring up a selection menu with a list of all the existing columns in the table. Otherwise, a new column name may be entered, in which case a new column with that name will be created when the calculation is performed.

Normally, when creating a new column, the column's data type will be the same as that of the expression. That is, an integer expression will create a 4-byte integer column (TFORM = 1J) and a real expression will create an 8-byte double column (TFORM = 1D). This can be overridden by placing the desired TFORM value within parentheses after the column's name. For example, specifying a column name NewCol(1E) will create a new column named 'NewCol' with a TFORM of '1E'. (The numerical value is optional and will be filled in with the vector size of the expression.) The expression's results will thus be converted to a 4-byte real when written to the column, even though the result could be of type integer or double.

Formula

The entry field on the right hand side of the "=" sign is for entering the expression for calculation. You can either type in the expression or use the buttons. To use a column in the calculation, one just inserts the column's name. Below are some sample expressions.

To access a table entry in a row other than the current one, follow the column's name with a row offset within curly braces. For example, 'PHA{-3}' will evaluate to the value of column PHA, 3 rows above the row currently being processed. One cannot specify an absolute row number, only a relative offset. Rows that fall outside the table will be treated as undefined, or NULLs.

If a calculation involves a column with Nulls or NaNs for certain rows, then these rows in the result column will be Nulls. An exception is if the Null is encountered within an && or || construction whose value is determined by the nonNull value. For example, "TRUE || NULL" evaluates to TRUE. The calculator has several special functions which can be used to test for Null values in columns.

Calculator pad

The expression to be calculated may be constructed by clicking on the calculator function buttons in the left 1/3 of the the window. Alternatively, the expression may be typed in directly in the formula window.

Column name listing

All the column names are listed as buttons. Clicking on any of them will insert (replacing any selected text) the column name in the formula window. If the number of columns is greater than 24, the "Up" and "Down" buttons can be used to scroll through the column name list.

Functions

Below are lists of all the functions supported by the calculator. For detailed descriptions of its operations, see the Expressions help file.

Arithmetic functions supported:

Vector functions supported:

Boolean functions supported:

NULL functions supported:

Type conversions supported:


Go to About fv.