GNU Astronomy Utilities



6.2.4.6 Statistical operators

The operators in this section take a single dataset as input, and will return the desired statistic as a single value.

minvalue

Minimum value in the first popped operand, so “a.fits minvalue” will push the minimum pixel value in this image onto the stack. When this operator acts on a single image, the output (operand that is put back on the stack) will no longer be an image, but a number. The output of this operand is in the same type as the input. This operator is mainly intended for multi-element datasets (for example, images or data cubes), if the popped operand is a number, it will just return it without any change.

Note that when the final remaining/output operand is a single number, it is printed onto the standard output. For example, with the command below the minimum pixel value in image.fits will be printed in the terminal:

$ astarithmetic image.fits minvalue

However, the output above also includes a lot of extra information that are not relevant in this context. If you just want the final number, run Arithmetic in quiet mode:

$ astarithmetic image.fits minvalue -q

Also see the description of sqrt for other example usages of this operator.

maxvalue

Maximum value of first operand in the same type, similar to minvalue, see the description there for more. For example

$ astarithmetic image.fits maxvalue -q
numbervalue

Number of non-blank elements in first operand in the uint64 type (since it is always a positive integer, see Numeric data types). Its usage is similar to minvalue, for example

$ astarithmetic image.fits numbervalue -q
sumvalue

Sum of non-blank elements in first operand in the float32 type. Its usage is similar to minvalue, for example

$ astarithmetic image.fits sumvalue -q
meanvalue

Mean value of non-blank elements in first operand in the float32 type. Its usage is similar to minvalue, for example

$ astarithmetic image.fits meanvalue -q
stdvalue

Standard deviation of non-blank elements in first operand in the float32 type. Its usage is similar to minvalue, for example

$ astarithmetic image.fits stdvalue -q
medianvalue

Median of non-blank elements in first operand with the same type. Its usage is similar to minvalue, for example

$ astarithmetic image.fits medianvalue -q
madclip-maskfilled
sigclip-maskfilled

Mask (set to blank/NaN) all the outlying elements (defined by \(\sigma\) or MAD clipping) in the inputs and put all the inputs back on the stack. The first popped operand is the termination criteria of the clipping, the second popped operand is the multiple of \(\sigma\) or MAD and the third is the number of input datasets that will be popped for the actual operation. If you are not yet familiar with \(\sigma\) or MAD clipping, it is recommended to read this tutorial: Clipping outliers.

When more than 95\(\%\) of the area of an operand is masked, the full operand will be masked. This is necessary in like this: one of your inputs has many outliers (for example it is much more noisy than the rest or its sky level has not been subtracted properly). Because this operator fills holes between outlying pixels, most of the area of the input will be masked, but the thin edges (where there are no “holes”) will remain, causing different statistics in those thin edges of that input in your final stack. Through this mask coverage fraction (which is currently hard-coded159), we ensure that such thin edges do not cause artifacts in the final stack.

For example, with the second command below, we are masking the MAD clipped pixels of the 9 inputs (that are generated in Clipping outliers) and writing them as separate HDUs of the output. The clipping is done with 5 times the MAD and the clipping starts when the relative difference between subsequent MADs is 0.01. Finally, with the third command, we see 10 HDUs in the output (because the first, or 0-th, is just metadata).

$ ls in-*.fits
in-1.fits  in-3.fits  in-5.fits  in-7.fits  in-9.fits
in-2.fits  in-4.fits  in-6.fits  in-8.fits

$ astarithmetic in-*.fits 9 5 0.01 madclip-maskfilled \
                -g1 --writeall --output=clipped.fits

$ astfits clipped.fits --numhdus
10

In the Arithmetic command above, --writeall is necessary because this operator puts all its inputs back on the stack of operands. This is because these are usually just intermediate operators. For example, after masking the outliers from each input, you may want to stack them into one deeper image (with the Stacking operators. After the stacking is done, only one operand will be on the stack, and --writeall will no longer be necessary. For example if you want to see how many images were used in the final stack’s pixels, you can use the number operator like below:

$ astarithmetic in-*.fits 9 5 0.01 madclip-maskfilled \
                9 number -g1 --output=num-good.fits
unique

Remove all duplicate (and blank) elements from the first popped operand. The unique elements of the dataset will be stored in a single-dimensional dataset.

Recall that by default, single-dimensional datasets are stored as a table column in the output. But you can use --onedasimage or --onedonstdout to respectively store them as a single-dimensional FITS array/image, or to print them on the standard output.

Although you can use this operator on the floating point dataset, due to floating-point errors it may give non-reasonable values: because the tenth digit of the decimal point is also considered although it may be statistically meaningless, see Numeric data types. It is therefore better/recommended to use it on the integer dataset like the labeled images of Segment output where each pixel has the integer label of the object/clump it is associated with. For example, let’s assume you have cropped a region of a larger labeled image and want to find the labels/objects that are within the crop. With this operator, this job is trivial:

$ astarithmetic seg-crop.fits unique
noblank

Remove all blank elements from the first popped operand. Since the blank pixels are being removed, the output dataset will always be single-dimensional, independent of the dimensionality of the input.

Recall that by default, single-dimensional datasets are stored as a table column in the output. But you can use --onedasimage or --onedonstdout to respectively store them as a single-dimensional FITS array/image, or to print them on the standard output.

For example, with the command below, the non-blank pixel values of cropped.fits are printed on the command-line (the --quiet option is used to remove the extra information that Arithmetic prints as it reads the inputs, its version and its running time).

$ astarithmetic cropped.fits noblank --onedonstdout --quiet

Footnotes

(159)

Please get in touch with us at bug-gnuastro@gnu.org if you notice this problem and feel the fraction needs to be lowered (or generally to be set in each run).