lezargus.container.cube module#

Spectral data cube container.

This module and class primarily deals with spectral data cubes containing both spatial and spectral information.

class lezargus.container.cube.LezargusCube(wavelength: ndarray, data: ndarray, uncertainty: ndarray = None, wavelength_unit: str | Unit | None = None, data_unit: str | Unit | None = None, pixel_scale: float | None = None, slice_scale: float | None = None, mask: ndarray | None = None, flags: ndarray | None = None, header: Header | None = None)[source]#

Bases: LezargusContainerArithmetic

Container to hold spectral cube data and perform operations on it.

For all available attributes, see :py:class:`LezargusContainerArithmetic`.
__init__(wavelength: ndarray, data: ndarray, uncertainty: ndarray = None, wavelength_unit: str | Unit | None = None, data_unit: str | Unit | None = None, pixel_scale: float | None = None, slice_scale: float | None = None, mask: ndarray | None = None, flags: ndarray | None = None, header: Header | None = None) None[source]#

Instantiate the spectral cube class.

Parameters:
  • wavelength (ndarray) – The wavelength axis of the spectral component of the data, if any. The unit of wavelength is typically in meters; but, check the wavelength_unit value.

  • data (ndarray) – The data stored in this container. The unit of the flux is typically in W m^-2 m^-1; but, check the data_unit value.

  • uncertainty (ndarray) – The uncertainty in the data of the spectra. The unit of the uncertainty is the same as the data value; per uncertainty_unit.

  • wavelength_unit (Astropy Unit) – The unit of the wavelength array. If None, we assume unit-less.

  • data_unit (Astropy Unit) – The unit of the data array. If None, we assume unit-less.

  • pixel_scale (float, default = None) – The E-W, “x” dimension, pixel plate scale of the spatial component, if any. Must be in radians per pixel. Scale is None if none is provided.

  • slice_scale (float, default = None) – The N-S, “y” dimension, pixel slice scale of the spatial component, if any. Must be in radians per slice-pixel. Scale is None if none is provided.

  • mask (ndarray, default = None) – A mask of the data, used to remove problematic areas. Where True, the values of the data is considered masked. If None, we assume the mask is all clear.

  • flags (ndarray, default = None) – Flags of the data. These flags store metadata about the data. If None, we assume that there are no harmful flags.

  • header (Header, default = None) – A set of header data describing the data. Note that when saving, this header is written to disk with minimal processing. We highly suggest writing of the metadata to conform to the FITS Header specification as much as possible. If None, we just use an empty header.

convolve_image(kernel: ndarray) Self[source]#

Convolve the cube by an image kernel convolving image slices.

Convolving a spectral cube can either be done one of two ways; convolving by image slices or convolving by spectral slices. We here convolve by image slices.

Parameters:

kernel (ndarray) – The image kernel which we are using to convolve.

Returns:

convolved_cube – A near copy of the data cube after convolution.

Return type:

ndarray

convolve_spectra(kernel: ndarray) Self[source]#

Convolve the cube by a spectral kernel convolving spectra slices.

Convolving a spectral cube can either be done one of two ways; convolving by image slices or convolving by spectral slices. We here convolve by spectral slices.

Parameters:

kernel (ndarray) – The spectral kernel which we are using to convolve.

Returns:

convolved_cube – A near copy of the data cube after convolution.

Return type:

ndarray

classmethod read_fits_file(filename: str) Self[source]#

Read a Lezargus cube FITS file.

We load a Lezargus FITS file from disk. Note that this should only be used for 3-D cube files.

Parameters:

filename (str) – The filename to load.

Returns:

cube – The LezargusCube class instance.

Return type:

Self-like

write_fits_file(filename: str, overwrite: bool = False) Self[source]#

Write a Lezargus cube FITS file.

We write a Lezargus FITS file to disk.

Parameters:
  • filename (str) – The filename to write to.

  • overwrite (bool, default = False) – If True, overwrite file conflicts.

Return type:

None