Spectrum, Image and Cube format¶
Attributes¶
Spectrum, Image and Cube objects all have the following items, where O denotes the name of the object:
Component | Description |
---|---|
O.filename | A FITS filename if the data were loaded from a FITS file |
O.primary_header | A FITS primary header instance |
O.wcs | World coordinate spatial information (WCS object) |
O.wave | World coordinate spectral information (WaveCoord object) |
O.shape | An array of the dimensions of the cube |
O.data | A numpy masked array of pixel values |
O.data_header | A FITS data header instance |
O.unit | The physical units of the data values |
O.dtype | The data-type of the data array (int, float) |
O.var | An optional numpy masked array of pixel variances |
O.mask | An array of the masked state of each pixel |
O.ndim | The number of dimensions in the data, variance and mask arrays |
Masked arrays are arrays that can have missing or invalid entries. The
numpy.ma module
provides a nearly work-alike replacement for numpy that supports data arrays
with masks. See the DataArray
documentation for more
details.
When an object is constructed from a MUSE FITS file, O.data
will contain the DATA extension,
O.var
will contain the STAT extension and O.mask
will contain the DQ extension if it exists.
A DQ extension contains the pixel data quality. By default all bad pixels are masked.
But it is possible for the user to create his mask by using the Python interface for euro3D convention.
Indexing¶
The format of each numpy array follows the indexing used by Python to handle 2D and 3D arrays. For an MPDAF cube C, the pixel in the bottom-lower-left corner is C[0,0,0] and pixel C[k,p,q] refers to the horizontal position q, the vertical position p, and the spectral position k, as follows:
In total, this cube C contains nq pixels in the horizontal direction, np pixels in the vertical direction and nk channels in the spectral direction. In the cube, each numpy masked array has 3 dimensions, array[k,p,q], where k is the spectral axis, and p and q are the spatial axes:
In [1]: from mpdaf.obj import Cube
# data array is read from the file (extension number 0)
In [2]: cube = Cube(filename='sdetect/minicube.fits')
# The 3 dimensions of the cube:
In [3]: cube.shape
Out[3]: (3681, 40, 40)
In [4]: cube.data.shape