The cascade.data_model module

This module defines the data models for the CASCADe transit spectroscopy code

class InstanceDescriptorMixin[source]

Bases: object

The InstanceDescriptorMixin Class.

Mixin to be able to add descriptor to the instance of the class and not the class itself

class UnitDesc(keyname)[source]

Bases: object

The UnitDesc Class.

A descriptor for adding auxilary measurements, setting the property for the unit atribute

__get__(instance, owner)[source]

Get.

Parameters:
  • instance (TYPE) – DESCRIPTION.

  • owner (TYPE) – DESCRIPTION.

Returns:

TYPE – DESCRIPTION.

__set__(instance, value)[source]

Set.

Parameters:
  • instance (TYPE) – DESCRIPTION.

  • value (TYPE) – DESCRIPTION.

Returns:

None.

__delete__(instance)[source]

Delete.

Parameters:

instance (TYPE) – DESCRIPTION.

Returns:

None.

class FlagDesc(keyname)[source]

Bases: object

The FlagDesc Class.

A descriptor for adding logical flags

__get__(instance, owner)[source]

Get.

Parameters:
  • instance (TYPE) – DESCRIPTION.

  • owner (TYPE) – DESCRIPTION.

Returns:

TYPE – DESCRIPTION.

__set__(instance, value)[source]

Set.

Parameters:
  • instance (TYPE) – DESCRIPTION.

  • value (TYPE) – DESCRIPTION.

Returns:

None.

__delete__(instance)[source]

Delete.

Parameters:

instance (TYPE) – DESCRIPTION.

Returns:

None.

class AuxilaryInfoDesc(keyname)[source]

Bases: object

The AuxilaryInfoDesc Class.

A descriptor for adding Auxilary information to the dataset

__get__(instance, owner)[source]

Get.

Parameters:
  • instance (TYPE) – DESCRIPTION.

  • owner (TYPE) – DESCRIPTION.

Returns:

TYPE – DESCRIPTION.

__set__(instance, value)[source]

Set.

Parameters:
  • instance (TYPE) – DESCRIPTION.

  • value (TYPE) – DESCRIPTION.

Returns:

None.

__delete__(instance)[source]

Delete.

Parameters:

instance (TYPE) – DESCRIPTION.

Returns:

None.

class MeasurementDesc(keyname)[source]

Bases: object

The MeasurementDesc Class.

A descriptor for adding auxilary measurements, setting the properties for the the measurement and unit

__get__(instance, owner)[source]

Get.

Parameters:
  • instance (TYPE) – DESCRIPTION.

  • owner (TYPE) – DESCRIPTION.

Returns:

TYPE – DESCRIPTION.

__set__(instance, value)[source]

Set.

Parameters:
  • instance (TYPE) – DESCRIPTION.

  • value (TYPE) – DESCRIPTION.

Returns:

None.

__delete__(instance)[source]

Delete.

Parameters:

instance (TYPE) – DESCRIPTION.

Returns:

None.

class SpectralData(wavelength=nan, wavelength_unit=None, data=nan, data_unit=None, uncertainty=nan, mask=False, **kwargs)[source]

Bases: InstanceDescriptorMixin

The SpectralData Class.

Class defining basic properties of spectral data In the instance if the SpectralData class all data are stored internally as numppy arrays. Outputted data are astropy Quantities unless no units (=None) are specified.

Parameters:
  • wavelength – wavelength of data (can be frequencies)

  • wavelenth_unit – The physical unit of the wavelength (uses astropy.units)

  • data – spectral data

  • data_unit – the physical unit of the data (uses astropy.units)

  • uncertainty – uncertainty on spectral data

  • mask – mask defining masked data

  • **kwargs – any auxilary data relevant to the spectral data (like position, detector temperature etc.) If unit is not explicitly given a unit atribute is added. Input argument can be instance of astropy quantity. Auxilary atributes are added to instance of the SpectralData class and not to the class itself. Only the required input stated above is always defined for all instances.

Examples

To create an instance of a SpectralData object with an initialization with data using units, run the following code:

>>> import numpy as np
>>> import astropu.units as u
>>> from cascade.data_model import SpectralData
>>> wave = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0])*u.micron
>>> flux = np.array([8.0, 8.0, 8.0, 8.0, 8.0, 8.0])*u.Jy
>>> sd = SpectralData(wavelength=wave, data=flux)
>>> print(sd.data, sd.wavelength)

To change to convert the units to a different but equivalent unit:

>>> sd.data_unit = u.erg/u.s/u.cm**2/u.Hz
>>> sd.wavelength_unit = u.cm
>>> print(sd.data, sd.wavelength)
property wavelength

Wavelength.

The wavelength atttribute of the SpectralData is defined through a getter and setter method. This ensures that the returned wavelength has always a unit associated with it (if the wavelength_unit is set) and that the returned wavelength has the same dimension and mask as the data attribute.

property wavelength_unit

Wavelength Unit.

The wavelength_unit attribute of the SpectralData is defined through a getter and setter method. This ensures that units can be updated and the wavelength value will be adjusted accordingly.

property data

Definition of the data atttribute of the SpectralData.

The data atttribute of the SpectralData is defined through a getter and setter method. In case data is initialized with a masked quantity, the data_unit and mask attributes will be set automatically.

property uncertainty

Uncertainty.

The uncertainty atttribute of the SpectralData is defined through a getter and setter method. This ensures that the returned uncertainty has the same unit associated with it (if the data_unit is set) and the same mask as the data attribute.

property data_unit

Definition of the data unit attribute of the SpectralData.

The data_unit attribute of the SpectralData is defined through a getter and setter method. This ensures that units can be updated and the data value will be adjusted accordingly.

property mask

Mask.

The mask atttribute of the SpectralData is defined through a getter and setter method. This ensures that the returned mask has the same dimension as the data attribute and will be set automatically if the input data is a masked array.

return_masked_array(attr)[source]

Return the data, wavelength or uncertainty as masked array.

Parameters:

attr ('str') – String value to indicate which measurement should be returned as masked array. Can be ‘data’, ‘wavelength’ or ‘uncertainty’.

Returns:

‘np.ma.maskedArray’ – The measurement corresponding to the atts value as masked array.

add_measurement(**kwargs)[source]

Add measuement to SpectralData object.

Parameters:

**kwargs (TYPE) – DESCRIPTION.

Returns:

None.

add_flag(**kwargs)[source]

Add flag to the SpectralData object.

Parameters:

**kwargs (TYPE) – DESCRIPTION.

Returns:

None.

add_auxilary(**kwargs)[source]

Add auxilary data to the SpectralData object.

Parameters:

**kwargs (TYPE) – DESCRIPTION.

Returns:

None.

class SpectralDataTimeSeries(wavelength=nan, wavelength_unit=None, data=array([[nan]]), data_unit=None, uncertainty=array([[nan]]), mask=False, time=nan, time_unit=None, **kwargs)[source]

Bases: SpectralData

The Spectral Data TimeSeries Class.

Class defining timeseries of spectral data. This class inherits from SpectralData. The data stored within this class has one additional time dimension

Parameters:
  • wavelength ('array_like') – wavelength assigned to each data point (can be also be frequencies)

  • wavelenth_unit ('astropy.units.core.Unit') – The physical unit of the wavelength .

  • data ('array_like') – The spectral data to be analysed. This can be either spectra (1D), spectral images (2D) or spectral data cubes (3D).

  • data_unit (astropy.units.core.Unit) – The physical unit of the data.

  • uncertainty – The uncertainty associated with the spectral data.

  • mask ('array_like') – The bad pixel mask flagging all data not to be used.

  • **kwargs – any auxilary data relevant to the spectral data (like position, detector temperature etc.) If unit is not explicitly given a unit atribute is added. Input argument can be instance of astropy quantity. Auxilary atributes are added to instance of the SpectralData class and not to the class itself. Only the required input stated above is always defined for all instances.

  • time ('array_like') – The time of observation assiciated with each data point.

  • time_unit ('astropy.units.core.Unit') – physical unit of time data

Examples

To create an instance of a SpectralDataaTimeSeries object with an initialization with data using units, run the following code:

>>> import numpy as np
>>> from cascade.data_model import SpectralDataTimeSeries
>>> wave = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0])*u.micron
>>> flux = np.array([8.0, 8.0, 8.0, 8.0, 8.0, 8.0])*u.Jy
>>> time = np.array([240000.0, 2400001.0, 2400002.0])*u.day
>>> flux_time_series = np.repeat(flux[:, np.newaxis], time.shape[0], 1)
>>> sdt = SpectralDataTimeSeries(wavelength=wave, data=flux_time_series,
                                 time=time)
property time

Time.

The time atttribute of the SpectralDataTimeSeries is defined through a getter and setter method. This ensures that the returned time has always a unit associated with it if the time_unit is set and that the returned time has the same dimension and mask as the data attribute.

property time_unit

Time Unit.

The time_unit attribute of the SpectralDataTimeSeries is defined through a getter and setter method. This ensures that units can be updated and the time value will be adjusted accordingly.

return_masked_array(attr)[source]

Return a maasked array.

Parameters:

attr (TYPE) – DESCRIPTION.

Raises:

ValueError – DESCRIPTION.

Returns:

TYPE – DESCRIPTION.