Montage Tutorial: Creating a Mosaic from Data Cubes

This tutorial shows how to aggregate a set of data cubes into a mosaic. It creates a mosaic of five data cubes released as part of the Galactic Arecibo L-band Feed Array HI (GALFA-HI) survey (Peek et al., 2011, Ap J Suppl, 194, 20; DOI 10.1088/0067-0049/194/2/20; ADS Bibcode 2011ApJS..194...20P). GALFA is a high-resolution (~4'), large-area (13,000 deg2), high spectral resolution (0.18 km s-1), and wide band (-700 km s -1 < v LSR < +700 km s-1) survey of the Galactic interstellar medium in the 21 cm line hyperfine transition of neutral hydrogen conducted at Arecibo Observatory.

Here is an image of one part of the mosaicked cube, an average of the central 10 wavelength planes:

(Click to enlarge)

View a movie of the final mosaic: (; QuickTime; 115 MB)

The data cubes are organized in regions 512 arcminutes on a side, with RA and Dec as the first two axes (NAXIS=1 and NAXIS=2), and the velocity as the third axis. This tutorial will mosaic five "narrow band cubes," with 0.18 km/s resolution from -190 to +190 km/s.

The five cubes have been downloaded from the GALFA Data Release 1 (DR1) archive at We will shrink these cubes by averaging every 10 planes in the wavelength axis. This reduces processing time for this tutorial, which is approximately 9 minutes on an Intel Xeon 3.2 GHz Quad-Core machine. If you wish to mosaic the original cubes, the processing time will be roughly 90 minutes.

Note that we do not perform background rectification in creating mosaics of data cubes.

Steps to Create a Mosaic

Step One: Prepare the source input files.

Download the gzipped input files (1.07 GB each), then unzip and untar them. This will create a folder called narrow containing these files:


Step Two: Create directories to hold the images.

  • Create a directory to hold the reprojected images: $ mkdir proj-narrow
  • Create a directory to hold the shrunken images: $ mkdir narrow-shrunk
  • Create a directory to hold the final image mosaic: $ mkdir final

Step Three: Shrink the input images.

Shrink the input images by averaging data over every 10 planes in the wavelength axis; each of these processes will take approximately 15 seconds. Compare the output with these files.

mShrinkCube -m 10 narrow/GALFA_HI_RA+DEC_004.00+18.35_N.fits
narrow_shrunk/GALFA_HI_RA+DEC_004.00+18.35_N_m10_1.fits 1
[struct stat="OK"]

mShrinkCube -m 10 narrow/GALFA_HI_RA+DEC_004.00+26.35_N.fits
narrow_shrunk/GALFA_HI_RA+DEC_004.00+26.35_N_m10_1.fits 1
[struct stat="OK"]

mShrinkCube -m 10 narrow/GALFA_HI_RA+DEC_004.00+34.35_N.fits
narrow_shrunk/GALFA_HI_RA+DEC_004.00+34.35_N_m10_1.fits 1
[struct stat="OK"]

mShrinkCube -m 10 narrow/GALFA_HI_RA+DEC_012.00+10.35_N.fits
narrow_shrunk/GALFA_HI_RA+DEC_012.00+10.35_N_m10_1.fits 1
[struct stat="OK"]

mShrinkCube -m 10 narrow/GALFA_HI_RA+DEC_020.00+02.35_N.fits
narrow_shrunk/GALFA_HI_RA+DEC_020.00+02.35_N_m10_1.fits 1
[struct stat="OK"]

Step Four: Create the image list.

Create an image list, images-narrow.tbl, of the shrunken images:

mImgtbl narrow-shrunk/ images-narrow.tbl
[struct stat="OK", count=5, badfits=0, badwcs=0]

Step Five: Create a header template.

Create a header template, template-narrow.hdr for the mosaic:

mMakeHdr images-narrow.tbl template-narrow.hdr
[struct stat="OK", count=5, ncube=5, naxis1=1136, naxis2=2963, clon=9.216833, clat=16.816168, lonsize=18.933371, latsize=49.383432, posang=26.334880, lon1=27.158147, lat1=-0.533033, lon2=11.480844, lat2=-7.857621, lon3=347.839988, lat3=32.320290, lon4=6.223720, lat4=41.457206]

Step Six: Reproject the five input images.

mProjectCube narrow-shrunk/GALFA_HI_RA+DEC_004.00+18.35_N_m10_1.fits proj-narrow/GALFA_HI_RA+DEC_004.00+18.35_N_m10_1_proj.fits template-narrow.hdr
[struct stat="OK", time=48]

mProjectCube narrow-shrunk/GALFA_HI_RA+DEC_004.00+26.35_N_m10_1.fits proj-narrow/GALFA_HI_RA+DEC_004.00+26.35_N_m10_1_proj.fits template-narrow.hdr
[struct stat="OK", time=42]

mProjectCube narrow-shrunk/GALFA_HI_RA+DEC_004.00+34.35_N_m10_1.fits proj-narrow/GALFA_HI_RA+DEC_004.00+34.35_N_m10_1_proj.fits
[struct stat="OK", time=48]

mProjectCube narrow-shrunk/GALFA_HI_RA+DEC_012.00+10.35_N_m10_1.fits proj-narrow/GALFA_HI_RA+DEC_0012.00+10.35_N_m10_1_proj.fits template-narrow.hdr
[struct stat="OK", time=48]

mProjectCube narrow-shrunk/GALFA_HI_RA+DEC_020.00+02.35_N_m10_1.fits proj-narrow/GALFA_HI_RA+DEC_020.00+02.35_N_m10_1_proj.fits template-narrow.hdr
[struct stat="OK", time=48]

The proj-narrow directory will contain these images:

GALFA_HI_RA+DEC_020.00+02.35_N_m10_1_proj_area.fits GALFA_HI_RA+DEC_020.00+02.35_N_m10_1_proj.fits GALFA_HI_RA+DEC_012.00+10.35_N_m10_1_proj_area.fits GALFA_HI_RA+DEC_012.00+10.35_N_m10_1_proj.fits GALFA_HI_RA+DEC_004.00+34.35_N_m10_1_proj_area.fits GALFA_HI_RA+DEC_004.00+34.35_N_m10_1_proj.fits GALFA_HI_RA+DEC_004.00+26.35_N_m10_1_proj_area.fits GALFA_HI_RA+DEC_004.00+26.35_N_m10_1_proj.fits GALFA_HI_RA+DEC_004.00+18.35_N_m10_1_proj_area.fits GALFA_HI_RA+DEC_004.00+18.35_N_m10_1_proj.fits

The reprojected images will be approximately 750 MB each, and the area files will be 3.7 MB each.

Step Seven: Create an image metadata file

Create an image metadata file, proj-images-narrow.tbl, for the reprojected images:

mImgtbl proj-narrow/ proj-images-narrow.tbl
[struct stat="OK", count=5, badfits=0, badwcs=0]

Step Eight: Co-add the reprojected images.

Co-add the reprojected images to create the final mosaic, GALFAmosaic.fits.

mAddCube -p proj-narrow proj-images-narrow.tbl template-narrow.hdr final/GALFAmosaic.fits

The mosaic, GALFAmosaic.fits, (5.5 GB) is a datacube with 204 planes in the z-axis, and this header:

SIMPLE  =                    T
BITPIX  =                  -64
NAXIS   =                    3
NAXIS1  =                 1135
NAXIS2  =                 2952
NAXIS3  =                  204
EXTEND  =                    T / FITS dataset may contain extensions
COMMENT   FITS (Flexible Image Transport System) format is defined in 'Astronomy
COMMENT   and Astrophysics', volume 376, page 359; bibcode: 2001A&A...376..359H
CTYPE1  = 'RA---TAN'
EQUINOX =                 2000
CRVAL1  =          9.216833479
CRVAL2  =         16.816167686
CRVAL3  =          0.000000000
CRPIX1  =                568.5
CRPIX2  =                1482.
CRPIX3  =       1024.500000000
CDELT1  =         -0.016666700
CDELT2  =          0.016666700
CDELT3  =       1840.307099000
CROTA2  =         26.334879644

Create this header, GALFAmosaic.hdr, as follows:

mGetHdr GALFAmosaic.fits GALFAmosaic.hdr
[struct stat="OK", ncard=22]

This step is highly CPU-intensive, and we recommend you do the co-addition on a quiet machine. It took 127 sseconds with 85% of the CPU on Mac OS 10.9, with a 3.2GHz Quad-Core processor.

Step Nine: Create an image and enjoy the movie.

Create an image like the one at the beginning of this tutorial using mViewer:

mViewer -ct 4 -gray GALFAmosaic.fits[0][99:109] -2s max gaussian-log -out GALFA102.jpg
[struct stat="OK", min=-349.547, minpercent=0.00, minsigma=-2.00, max=40.6294, maxpercent=100.00, maxsigma=2.33, datamin=-169.384, datamax=40.6294, xflip=0, yflip=1, bunit="", colortable=4]

Here is a movie of the final cube: (115 MB).

This tutorial was based on a script developed by Dr. Ben Rusholme (IPAC, Caltech). It uses data from the Galactic ALFA HI (GALFA HI) survey data set obtained with the Arecibo L-band Feed Array (ALFA) on the Arecibo 305m telescope. Arecibo Observatory is part of the National Astronomy and Ionosphere Center, which is operated by Cornell University under Cooperative Agreement with the U.S. National Science Foundation. The GALFA HI surveys are funded by the NSF through grants to Columbia University, the University of Wisconsin, and the University of California.