pypeit.onespec module

Provides a simple datamodel for a single spectrum.

class pypeit.onespec.OneSpec(wave, wave_grid_mid, flux, PYP_SPEC=None, ivar=None, sigma=None, mask=None, telluric=None, obj_model=None, ext_mode=None, fluxed=None)[source]

Bases: DataContainer

DataContainer to hold single spectra, e.g., from CoAdd1D.

The datamodel attributes are:

Version: 1.0.2

Attribute

Type

Array Type

Description

PYP_SPEC

str

PypeIt spectrograph designation

ext_mode

str

Extraction mode (options: BOX, OPT)

flux

numpy.ndarray

numpy.floating

Flux array in units of counts/s or 10^-17 erg/s/cm^2/Ang; see fluxed

fluxed

bool

Boolean indicating if the spectrum is fluxed.

ivar

numpy.ndarray

numpy.floating

Inverse variance array (matches units of flux)

mask

numpy.ndarray

numpy.integer

Mask array (1=Good,0=Bad)

obj_model

numpy.ndarray

numpy.floating

Object model for tellurics

sigma

numpy.ndarray

numpy.floating

One sigma noise array, equivalent to 1/sqrt(ivar) (matches units of flux)

spect_meta

dict

header dict

telluric

numpy.ndarray

numpy.floating

Telluric model

wave

numpy.ndarray

numpy.floating

Wavelength array (angstroms in vacuum), weighted by pixel contributions

wave_grid_mid

numpy.ndarray

numpy.floating

Wavelength (angstroms in vacuum) evaluated at the bin centers of a grid that is uniformly spaced in either lambda or log10-lambda/velocity

Parameters:
  • wave

  • wave_grid_mid

  • flux

  • PYP_SPEC

  • ivar

  • mask

  • telluric

  • obj_model

  • ext_mode

  • fluxed

head0

Primary header

Type:

astropy.io.fits.Header

spect_meta

Parsed meta from the header

Type:

dict

spectrograph

Build from PYP_SPEC

Type:

pypeit.spectrographs.spectrograph.Spectrograph

_bundle()[source]

Override the base class method simply to set the HDU extension name.

datamodel = {'PYP_SPEC': {'descr': '``PypeIt`` spectrograph designation', 'otype': <class 'str'>}, 'ext_mode': {'descr': 'Extraction mode (options: BOX, OPT)', 'otype': <class 'str'>}, 'flux': {'atype': <class 'numpy.floating'>, 'descr': 'Flux array in units of counts/s or 10^-17 erg/s/cm^2/Ang; see ``fluxed``', 'otype': <class 'numpy.ndarray'>}, 'fluxed': {'descr': 'Boolean indicating if the spectrum is fluxed.', 'otype': <class 'bool'>}, 'ivar': {'atype': <class 'numpy.floating'>, 'descr': 'Inverse variance array (matches units of flux)', 'otype': <class 'numpy.ndarray'>}, 'mask': {'atype': <class 'numpy.integer'>, 'descr': 'Mask array (1=Good,0=Bad)', 'otype': <class 'numpy.ndarray'>}, 'obj_model': {'atype': <class 'numpy.floating'>, 'descr': 'Object model for tellurics', 'otype': <class 'numpy.ndarray'>}, 'sigma': {'atype': <class 'numpy.floating'>, 'descr': 'One sigma noise array, equivalent to 1/sqrt(ivar) (matches units of flux)', 'otype': <class 'numpy.ndarray'>}, 'spect_meta': {'descr': 'header dict', 'otype': <class 'dict'>}, 'telluric': {'atype': <class 'numpy.floating'>, 'descr': 'Telluric model', 'otype': <class 'numpy.ndarray'>}, 'wave': {'atype': <class 'numpy.floating'>, 'descr': 'Wavelength array (angstroms in vacuum), weighted by pixel contributions', 'otype': <class 'numpy.ndarray'>}, 'wave_grid_mid': {'atype': <class 'numpy.floating'>, 'descr': 'Wavelength (angstroms in vacuum) evaluated at the bin centers of a grid that is uniformly spaced in either lambda or log10-lambda/velocity', 'otype': <class 'numpy.ndarray'>}}

Provides the class data model. This is undefined in the abstract class and should be overwritten in the derived classes.

The format of the datamodel needed for each implementation of a DataContainer derived class is as follows.

The datamodel itself is a class attribute (i.e., it is a member of the class, not just of an instance of the class). The datamodel is a dictionary of dictionaries: Each key of the datamodel dictionary provides the name of a given datamodel element, and the associated item (dictionary) for the datamodel element provides the type and description information for that datamodel element. For each datamodel element, the dictionary item must provide:

  • otype: This is the type of the object for this datamodel item. E.g., for a float or a numpy.ndarray, you would set otype=float and otype=np.ndarray, respectively.

  • descr: This provides a text description of the datamodel element. This is used to construct the datamodel tables in the pypeit documentation.

If the object type is a numpy.ndarray, you should also provide the atype keyword that sets the type of the data contained within the array. E.g., for a floating point array containing an image, your datamodel could be simply:

datamodel = {'image' : dict(otype=np.ndarray, atype=float, descr='My image')}

More advanced examples are given in the top-level module documentation.

Currently, datamodel components are restricted to have otype that are tuple, int, float, numpy.integer, numpy.floating, numpy.ndarray, or astropy.table.Table objects. E.g., datamodel values for otype cannot be dict.

classmethod from_file(ifile, verbose=True, chk_version=True, **kwargs)[source]

Instantiate the object from an extension in the specified fits file.

Over-load from_file() to deal with the header

Parameters:
  • ifile (str, Path) – Fits file with the data to read

  • verbose (bool, optional) – Print informational messages (not currently used)

  • chk_version (bool, optional) – Passed to from_hdu().

  • kwargs (dict, optional) – Arguments passed directly to from_hdu().

internals = ['head0', 'filename', 'spectrograph', 'spect_meta', 'history']

A list of strings identifying a set of internal attributes that are not part of the datamodel.

to_file(ofile, primary_hdr=None, history=None, **kwargs)[source]

Over-load pypeit.datamodel.DataContainer.to_file() to deal with the header

Parameters:
version = '1.0.2'

Provides the string representation of the class version.

This is currently put to minimal use so far, but will used for I/O verification in the future.

Each derived class should provide a version to guard against data model changes during development.