data

This module handles spectrum data objects.

class specviz.core.data.Data(data, dispersion=None, dispersion_unit=None, name=u'', *args, **kwargs)[source]

Class of the base data container for all data (of type numpy.ndarray) that is passed around in SpecViz. It inherits from astropy.nddata.NDData and provides functionality for arithmetic operations, I/O, and slicing.

Parameters:
  • data (ndarray) – Flux values.
  • dispersion (ndarray or None) – Dispersion values. If not given, this is calculated from WCS.
  • dispersion_unit (Unit or None) – Dispersion unit. If not given, this is obtained from WCS.
  • name (str) – Short description of the spectrum.
  • args (tuple) – Additional positional arguments.
  • kwargs (dict) – Additional keyword arguments.

Examples

>>> d = Data.read(
...     'generic_spectra.fits', filter='Generic Fits (*.fits *.mits)')
>>> d = Data.read(
...     'generic_spectra.txt', filter='ASCII (*.txt *.dat)')
dispersion

Dispersion values.

dispersion_unit

Unit of dispersion.

class specviz.core.data.Layer(source, mask, parent=None, name=u'')[source]

Class to handle layers in SpecViz.

A layer is a “view” into a Data object. It does not hold any data itself, but instead contains a special mask object and reference to the original data.

Since Data inherits from astropy.nddata.NDDataBase and provides the astropy.nddata.NDArithmeticMixin mixin, it is also possible to do arithmetic operations on layers.

Parameters:
  • source (Data) – Spectrum data object.
  • mask (ndarray) – Mask for the spectrum data.
  • parent (obj or None) – GUI parent.
  • name (str) – Short description.
data

Flux quantity with mask applied.

dispersion

Dispersion quantity with mask applied.

mask

Mask for spectrum data.

meta

Spectrum metadata.

uncertainty

Flux uncertainty with mask applied.

unit

Flux unit.

wcs

WCS for spectrum data.

class specviz.core.data.ModelLayer(model, source, mask, parent=None, name=u'')[source]

A layer for spectrum with a model applied.

Parameters:
  • model (obj) – Astropy model.
  • source (Data) – Spectrum data object.
  • mask (ndarray) – Mask for the spectrum data.
  • parent (obj or None) – GUI parent.
  • window (obj or None) – GUI window.
  • name (str) – Short description.
data

Flux quantity from model.

model

Spectrum model.

uncertainty

Models do not need to contain uncertainties; override parent class method.