GNU Astronomy Utilities


Next: , Previous: , Up: Arithmetic   [Contents][Index]


6.2.2 Arithmetic operators

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 aren’t 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.

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. 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 isn’t case-sensitive.


Next: Invoking Arithmetic, Previous: Reverse polish notation, Up: Arithmetic   [Contents][Index]