Accepted Data Types¶
The TurbuStat routines can accept several different data types.
FITS HDU¶
The most common format is a FITS HDU. These can be loaded in python with the fits
library:
>>> from astropy.io import fits
>>> hdulist = fits.open("test.fits")
>>> hdu = hdulist[0]
The TurbuStat statistics expect a single extension for a FITS file to be given.
Numpy array and header¶
The data can be given as a numpy array, along with a FITS header. This may be useful for data generated from simple physical models (see preparing simulated data). The data can be given as a 2-element tuple or list:
>>> input_data = (array, header)
>>> input_data = [array, header]
Spectral-Cube objects¶
The spectral-cube package is a dependency of TurbuStat for calculating moment arrays and spectrally regridding cubes for the VCA statistic. When the data need to be preprocessed, it will often be easiest to work with a SpectralCube object. See the spectral-cube tutorial for more information:
>>> from spectral_cube import SpectralCube
>>> cube = SpectralCube("test.fits")
This SpectralCube
object can be sliced or used to create moment maps. These spatial 2D maps are called a “Projection” or “Slice” and both are accepted by the TurbuStat statistics:
>>> sliced_img = cube[100]
>>> moment_img = cube.moment0()
The Projection
object also offers a number of convenient functions available for a SpectralCube, making it easy to manipulate and alter the data as needed. To load a spatial FITS image as a projection:
>>> from spectral_cube import Projection
>>> img_hdu = fits.open("test_spatial.fits")[0]
>>> proj = Projection.from_hdu(img_hdu)