GNU Astronomy Utilities Building new dataset and stack management

With the operator here, you can create a new dataset from scratch to start certain operations without any input data.


Create a new dataset that only has zero values. The number of dimensions is read as the first popped operand and the number of elements along each dimension are the next popped operand (in reverse of the popping order). The type of the new dataset is an unsigned 8-bit integer and all pixel values have a value of zero. For example, if you want to create a new 100 by 200 pixel image, you can run this command:

$ astarithmetic 100 200 2 makenew

To further extend the example, you can use any of the noise-making operators to add noise to this new dataset (see Random number generators), like the command below:

$ astarithmetic 100 200 2 makenew 5 mknoise-sigma

Return an operand that will have a constant value (first popped operand) in all its elements. The number of elements is read from the second popped operand. The second popped operand is only used for its number of elements, its numeric data type, or its values are fully ignored and it is later freed.

Here is one useful scenario for this operator in tables: you want to merge the objects/rows of some catalogs together, but you first want to give each source catalog a label/counter that distinguishes between the source of each rows in the merged/final catalog (using Invoking Table). The steps below show the the usage of this.

## Add label 1 to the RA, Dec, magnitude and magnitude error
## rows of the first catalog.
$ asttable cat-1.fits -cRA,DEC,MAG,MAG_ERR \
       -c'arith $1 1 constant' --output=tab-1.fits

## Similar to above, but for the second catalog.
$ asttable cat-2.fits -cRA,DEC,MAG,MAG_ERR \
           -c'arith $1 2 constant' --output=tab-2.fits

## Concatenate (merge/blend) the rows of the two tables into
## one for the 5 columns, but also add a counter for each
## object or row in the final catalog.
$ asttable tab-1.fits --catrowfile=tab-2.fits \
           -c'arith $1 counteronly' \
           -cRA,DEC,MAG,MAG_ERR,5 --output=merged.fits \
           --colmetadata=1,ID_MERGED,counter,"Merged ID." \
           --colmetadata=6,SOURCE-CAT,counter,"Source ID."

## Add keyword information on each input. It is very important
## to preserve this within the merged catalog. If the tables
## came from public databases (for example on VizieR), give
## their public identifier as the value.
$ astfits merged.fits --write=/,"Source catalogs" \
          --write=CATSRC1,"I/355/gaiadr3","VizieR ID." \
          --write=CATSRC2,"Jane Doe","Name of source."

## Check the metadata in 'merged.fits' and clean the
## temporary files.
$ rm tab-1.fits tab-2.fits
$ astfits merged.fits -h1

Like most operators, constant is not limited to tables, you can also apply it on images. In the example below, we’ll use constant to set all the pixels of the input image to NaN (which is necessary in scenarios that you need to include in an image in an analysis, but you don’t want its pixels to affect the processing):

$ astarithmetic image.fits nan constant

Swap the top two operands on the stack. For example the index operator doesn’t pop with the top operand (the input to index), it just adds the index image to the stack. In case you want your next operation to be on the input to index, you can simply call swap and continue the operations on that image, while keeping the indexed pixels for later steps. In the example below we are using the --writeall option to write the full stack and if you open the outputs you will see that the stack order has changed.

## Index image is written in HDU 1.
$ astarithmetic image.fits index      --writeall \

## image.fits in HDU 1.
$ astarithmetic image.fits index swap --writeall \