Montage Tutorial: Transposing the Axes of Data Cubes

The Montage data cube processing modules assume that in a data cube stored in a FITS file, the first two axes of the cube (NAXIS=1, NAXIS=2) represent positional coordinates, such as Right Ascension and declination, and the third axis (NAXIS3) represents a physical quantity, such as wavelength, redshift or time. In many data cubes, the axes are not organized this way. For many cubes produced by radio astronomy instruments and by integral field spectra, the physical quantity is often the first axis. Thus, the first step in processing a data cube with Montage is to determine the ordering of the axes and to transpose them as needed.

Consider an example data cube, OS.20061002.46998.lev1.fits, measured with the OSIRIS integral-field spectrograph at the W.M. Keck Observatory.

Step One: Determine the order of the axes.

You may use any tool to read the header of the FITS file, such as the fv tool from HEASARC. We recommend using the mGetHdr utility to write the header to a text file, OSIRIS.hdr:

mGetHdr OS.20061002.46998.lev1.fits OSIRIS.hdr
[struct stat="OK", ncard=384]

Inspection of the appropriate keywords, printed below, shows that NAXIS1 represents wavelength, NAXIS2 represents RA and NAXIS3 represents Declination:

NAXIS = 3 / number of data axes
NAXIS1 = 433 / length of data axis 1
NAXIS2 = 66 / length of data axis 2
NAXIS3 = 51 /
CTYPE3 = 'DEC--TAN' /Declination.
CUNIT1 = 'nm ' /Vacuum wavelength unit is nanometers
CUNIT2 = 'deg ' /R.A. unit is degrees, always
CUNIT3 = 'deg ' /Declination unit is degrees, always
CRVAL1 = 2121.00 / [nm] Wavelength at reference pixel
CRVAL3 = -0.0131450173056 / [deg] Declination at reference pixel
CRPIX1 = 1 /Reference pixel location
CRPIX3 = 25.0000 /Reference pixel location
CDELT1 = 0.250000 /Wavelength scale is 0.250000 nm/channel
CDELT3 = 1.38889E-05 /Pixel scale is 0.0500000 arcsec/pixel

Step Two: Transpose the axes.

Use the mTranspose utility to transpose the order of the axes so the axes are RA, Declination, and Wavelength. We are transposing the order from (1,2,3) to (2,3,1), and writing the output to OS.trans.fits:

mTranspose OS.20061002.46998.lev1.fits OS.trans.fits 2 3 1
[struct stat="OK", mindata=-16.3227, maxdata=6.83617]

You must explicitly state the ordering of all three axes. mTranspose will return an error message if you don't:

mTranspose OS.20061002.46998.lev1.fits OS.trans.fits 2 3
[struct stat="ERROR", msg="Image has 3 dimensions. You must list the output order for all of them."]

Step Three: Verify that the axes have been transposed.

A simple way to do this is to run mGetHdr again to create a text file of the header of the transposed cube, OS.trans.hdr:

mGetHdr OS.trans.fits OS.trans.hdr
[struct stat="OK", ncard=387]

Comparison of the keywords, printed below, with those in OSIRIS.hdr, shows that the axes have indeed been transposed.

NAXIS = 3 / number of data axes
NAXIS1 = 66 / length of data axis 1
NAXIS2 = 51 / length of data axis 2
NAXIS3 = 433 / length of data axis 3
...
CTYPE2 = 'DEC--TAN' /Declination.
CUNIT3 = 'nm ' /Vacuum wavelength unit is nanometers
CUNIT1 = 'deg ' /R.A. unit is degrees, always
CUNIT2 = 'deg ' /Declination unit is degrees, always
CRVAL3 = 2121.00 / [nm] Wavelength at reference pixel
CRVAL2 = -0.0131450173056 / [deg] Declination at reference pixel
CRPIX3 = 1 /Reference pixel location
CRPIX2 = 25.0000 /Reference pixel location
CDELT3 = 0.250000 /Wavelength scale is 0.250000 nm/channel
CDELT2 = 1.38889E-05 /Pixel scale is 0.0500000 arcsec/pixel

The OSIRIS data file was downloaded form the Keck Observatory Archive (KOA) at https://koa.ipac.caltech.edu. The file is part of the observing program "The Mass and Density of 2003 UB313" (M. Brown, PI).