Moment maps and statistics

Moment maps

Producing moment maps from a SpectralCube instance is straightforward:

>>> moment_0 = cube.moment(order=0)  
>>> moment_1 = cube.moment(order=1)  
>>> moment_2 = cube.moment(order=2)  

By default, moments are computed along the spectral dimension, but it is also possible to pass the axis argument to compute them along a different axis:

>>> moment_0_along_x = cube.moment(order=0, axis=2)  

Note

these follow the mathematical definition of moments, so the second moment is computed as the variance. For linewidth maps, see the Linewidth maps section.

The moment maps returned are Projection instances, which act like Quantity objects, and also have convenience methods for writing to a file:

>>> moment_0.write('moment0.fits')  

and converting the data and WCS to a FITS HDU:

>>> moment_0.hdu  
<astropy.io.fits.hdu.image.PrimaryHDU at 0x10d6ec510>

The conversion to HDU objects makes it very easy to use the moment map with plotting packages such as APLpy:

>>> import aplpy  
>>> f = aplpy.FITSFigure(moment_0.hdu)  
>>> f.show_colorscale()  
>>> f.save('moment_0.png')  

Linewidth maps

Making linewidth maps (sometimes refered to as second moment maps in radio astronomy), you can use:

>>> sigma_map = cube.linewidth_sigma()  
>>> fwhm_map = cube.linewidth_fwhm()  

These also return Projection instances as for the Moment maps.