GNU Astronomy Utilities



6.2.4.5 Unit conversion operators

It often happens that you have data in one unit (for example, counts on your CCD), but would like to convert it into another (for example, magnitudes, to measure the brightness of a galaxy). While the equations for the unit conversions can be easily found on the internet, the operators in this section are designed to simplify the process and let you do it easily and fast without having to remember constants and relations.

counts-to-mag

Convert counts (usually CCD outputs) to magnitudes using the given zero point. The zero point is the first popped operand and the count image or value is the second popped operand.

For example, assume you have measured the standard deviation of the noise in an image to be 0.1 counts, and the image’s zero point is 22.5 and you want to measure the per-pixel surface brightness limit of the dataset158. To apply this operator on an image, simply replace 0.1 with the image name, as described below.

$ astarithmetic 0.1 22.5 counts-to-mag --quiet

Of course, you can also convert every pixel in an image (or table column in Table’s Column arithmetic) with this operator if you replace the second popped operand with an image/column name. For an example of applying this operator on an image, see the description of surface brightness in Brightness, Flux, Magnitude and Surface brightness, where we will convert an image’s pixel values to surface brightness.

mag-to-counts

Convert magnitudes to counts (usually CCD outputs) using the given zero point. The zero point is the first popped operand and the magnitude value is the second. For example, if an object has a magnitude of 20, you can estimate the counts corresponding to it (when the image has a zero point of 24.8) with this command: Note that because the output is a single number, we are using --quiet to avoid printing extra information.

$ astarithmetic 20 24.8 mag-to-counts --quiet
counts-to-sb

Convert counts to surface brightness using the zero point and area (in units of arcsec\(^2\)). The first popped operand is the area (in arcsec\(^2\)), the second popped operand is the zero point and the third are the count values. Estimating the surface brightness involves taking the logarithm. Therefore this operator will produce NaN for counts with a negative value.

For example, with the commands below, we read the zero point from the image headers (assuming it is in the ZPOINT keyword), we calculate the pixel area from the image itself, and we call this operator to convert the image pixels (in counts) to surface brightness (mag/arcsec\(^2\)).

$ zeropoint=$(astfits image.fits --keyvalue=ZPOINT -q)
$ pixarea=$(astfits image.fits --pixelareaarcsec2)
$ astarithmetic image.fits $zeropoint $pixarea counts-to-sb \
                --output=image-sb.fits

For more on the definition of surface brightness see Brightness, Flux, Magnitude and Surface brightness, and for a fully tutorial on optimal usage of this, see FITS images in a publication.

sb-to-counts

Convert surface brightness using the zero point and area (in units of arcsec\(^2\)) to counts. The first popped operand is the area (in arcsec\(^2\)), the second popped operand is the zero point and the third are the surface brightness values. See the description of counts-to-sb for more.

mag-to-sb

Convert magnitudes to surface brightness over a certain area (in units of arcsec\(^2\)). The first popped operand is the area and the second is the magnitude. For example, let’s assume you have a table with the two columns of magnitude (called MAG) and area (called AREAARCSEC2). In the command below, we will use Column arithmetic to return the surface brightness.

$ asttable table.fits -c'arith MAG AREAARCSEC2 mag-to-sb'
sb-to-mag

Convert surface brightness to magnitudes over a certain area (in units of arcsec\(^2\)). The first popped operand is the area and the second is the magnitude. See the description of mag-to-sb for more.

counts-to-jy

Convert counts (usually CCD outputs) to Janskys through an AB-magnitude based zero point. The top-popped operand is assumed to be the AB-magnitude zero point and the second-popped operand is assumed to be a dataset in units of counts (an image in Arithmetic, and a column in Table’s Column arithmetic). For the full equation and basic definitions, see Brightness, Flux, Magnitude and Surface brightness.

For example, SDSS images are calibrated in units of nanomaggies, with a fixed zero point magnitude of 22.5. Therefore you can convert the units of SDSS image pixels to Janskys with the command below:

$ astarithmetic sdss-image.fits 22.5 counts-to-jy
jy-to-counts

Convert Janskys to counts (usually CCD outputs) through an AB-magnitude based zero point. This is the inverse operation of the counts-to-jy, see there for usage example.

zeropoint-change

Change the zero point of the input dataset to a new zero point (output will always be 64-bit floating point). For example, with the command below, we are changing the zero point of an image from 26.892 to 27.0:

$ astarithmetic image.fits 26.892 27.0 zeropoint-change

Note that the input or output zero points can also be an image (with the same size as the input image). This is very useful to correct situations where the zero point can change over the image (happens in single exposures) and you want to unify it across the whole image (to build a deep stacked image).

counts-to-nanomaggy

Convert counts to Nanomaggy (with fixed zero point of 22.5, used as the pixel units of many surveys like SDSS). For example if your image has a zero point of 24.93, you can convert it to Nanomaggies with the command below:

$ astarithmetic image.fits 24.93 counts-to-nanomaggy

This is just a wrapper over the zeropoint-change operator where the output zero point is 22.5.

nanomaggy-to-counts

Convert Nanomaggy to counts. Nanomaggy is defined to have a fixed zero point of 22.5 and is the pixel units of many surveys like SDSS. For example if you would like to convert an image in units of Nanomaggy (for example from SDSS) to the counts of a camera with a zero point of 25.92, you can use the command below:

$ astarithmetic image.fits 25.92 nanomaggy-to-counts

This is just a wrapper over the zeropoint-change operator where the input zero point is 22.5.

mag-to-jy

Convert AB magnitudes to Janskys, see Brightness, Flux, Magnitude and Surface brightness.

jy-to-mag

Convert Janskys to AB magnitude, see Brightness, Flux, Magnitude and Surface brightness.

jy-to-wavelength-flux-density

Convert Janskys to wavelength flux density (in units of \(erg/cm^2/s/\AA\)) at a certain wavelength (given in units of Angstroms). Recall that Jansky is also a unit of flux density, but it is in units of frequency (\(erg/cm^2/s/Hz\)).

For example at the wavelength of 5556, Vega’s frequency flux density is 3500 Janskys. To convert this to wavelength flux density, you can use this command:

$ astarithmetic 3.5e3 5556 jy-to-wavelength-flux-density

If your input values are in units of counts or magnitudes, you can use the mag-to-jy or count-to-jy operators that are described above. For example, if you want the wavelength flux density of a source with magnitude 21 in the J-PAS J0660 filter (centered at approximately \(6600\AA\)), you can use this command:

$ astarithmetic 21 mag-to-jy 6600 \
                jy-to-wavelength-flux-density
au-to-pc

Convert Astronomical Units (AUs) to Parsecs (PCs). This operator takes a single argument which is interpreted to be the input AUs. The conversion is based on the definition of Parsecs: \(1 \rm{PC} = 1/tan(1^{\prime\prime}) \rm{AU}\), where \(1^{\prime\prime}\) is one arcseconds. In other words, \(1 (\rm{PC}) = 648000/\pi (\rm{AU})\). For example, if we take Pluto’s average distance to the Sun to be 40 AUs, we can obtain its distance in Parsecs using this command:

echo 40 | asttable -c'arith $1 au-to-pc'
pc-to-au

Convert Parsecs (PCs) to Astronomical Units (AUs). This operator takes a single argument which is interpreted to be the input PCs. For more on the conversion equation, see description of au-to-pc. For example, Proxima Centauri (the nearest star to the Solar system) is 1.3020 Parsecs from the Sun, we can calculate this distance in units of AUs with the command below:

echo 1.3020 | asttable -c'arith $1 pc-to-au'
ly-to-pc

Convert Light-years (LY) to Parsecs (PCs). This operator takes a single argument which is interpreted to be the input LYs. The conversion is done from IAU’s definition of the light-year (9460730472580800 m \(\approx\) 63241.077 AU = 0.306601 PC, for the conversion of AU to PC, see the description of au-to-pc).

For example, the distance of Andromeda galaxy to our galaxy is 2.5 million light-years, so its distance in kilo-Parsecs can be calculated with the command below (note that we want the output in kilo-parsecs, so we are dividing the output of this operator by 1000):

echo 2.5e6 | asttable -c'arith $1 ly-to-pc 1000 /'
pc-to-ly

Convert Parsecs (PCs) to Light-years (LY). This operator takes a single argument which is interpreted to be the input PCs. For the conversion and an example of the inverse of this operator, see the description of ly-to-pc.

ly-to-au

Convert Light-years (LY) to Astronomical Units (AUs). This operator takes a single argument which is interpreted to be the input LYs. For the conversion and a similar example, see the description of ly-to-pc.

au-to-ly

Convert Astronomical Units (AUs) to Light-years (LY). This operator takes a single argument which is interpreted to be the input AUs. For the conversion and a similar example, see the description of ly-to-pc.


Footnotes

(158)

The per-pixel surface brightness limit is the magnitude of the noise standard deviation. For more on surface brightness see Brightness, Flux, Magnitude and Surface brightness. In the example command, because the output is a single number, we are using --quiet to avoid printing extra information.