In this section, list of recognized operators in Arithmetic (and the Table program’s Column arithmetic) and discussed in detail with examples. As mentioned before, to be able to easily do complex operations on the command-line, the Reverse Polish Notation is used (where you write ‘\(4\quad5\quad+\)’ instead of ‘\(4 + 5\)’), if you are not already familiar with it, before continuing, please see Reverse polish notation.

The operands to all operators can be a data array (for example, a FITS image or data cube) or a number, the output will be an array or number according to the inputs. For example, a number multiplied by an array will produce an array. The numerical data type of the output of each operator is described within it. Here are some generic tips and tricks (relevant to all operators):

- Multiple operators in one command
When you need to use arithmetic commands in several consecutive operations, you can use one command instead of multiple commands and perform all calculations in the same command. For example, assume you want to apply a threshold of 10 on your image, and label the connected groups of pixel above this threshold. You need two operators for this:

`gt`

(for “greater than”, see Conditional operators) and`connected-components`

(see Mathematical morphology operators). The bad (non-optimized and slow) way of doing this is to call Arithmetic two times:$ astarithmetic image.fits 10 gt --output=thresh.fits $ astarithmetic thresh.fits 2 connected-components \ --output=labeled.fits $ rm thresh.fits

The good (optimal) way is to call them after each other (remember Reverse polish notation):

$ astarithmetic image.fits 10 gt 2 connected-components \ --output=labeled.fits

You can similarly add any number of operations that must be done sequentially in a single command and benefit from the speed and lack of intermediate files. When your commands become long, you can use the

`set-AAA`

operator to make it more readable, see Operand storage in memory or a file.- Blank pixels in Arithmetic
Blank pixels in the image (see Blank pixels) will be stored based on the data type. When the input is floating point type, blank values are NaN. One aspect of NaN values is that by definition they will fail on

*any*comparison. Also, any operator that includes a NaN as a an operand will produce a NaN (irrespective of its other operands). Hence both equal and not-equal operators will fail when both their operands are NaN! Therefore, the only way to guarantee selection of blank pixels is through the`isblank`

operator explained above.One way you can exploit this property of the NaN value to your advantage is when you want a fully zero-valued image (even over the blank pixels) based on an already existing image (with same size and world coordinate system settings). The following command will produce this for you:

$ astarithmetic input.fits nan eq --output=all-zeros.fits

Note that on the command-line you can write NaN in any case (for example,

`NaN`

, or`NAN`

are also acceptable). Reading NaN as a floating point number in Gnuastro is not case-sensitive.

- Basic mathematical operators
- Trigonometric and hyperbolic operators
- Constants
- Coordinate conversion operators
- Unit conversion operators
- Statistical operators
- Stacking operators
- Filtering (smoothing) operators
- Pooling operators
- Interpolation operators
- Dimensionality changing operators
- Conditional operators
- Mathematical morphology operators
- Bitwise operators
- Numerical type conversion operators
- Random number generators
- Coordinate and border operators
- Loading external columns
- Size and position operators
- New operands
- Operand storage in memory or a file

JavaScript license information

GNU Astronomy Utilities 0.23 manual, July 2024.