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 designationext_mode
str
Extraction mode (options: BOX, OPT)
flux
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
Inverse variance array (matches units of flux)
mask
Mask array (1=Good,0=Bad)
obj_model
Object model for tellurics
sigma
One sigma noise array, equivalent to 1/sqrt(ivar) (matches units of flux)
spect_meta
dict
header dict
telluric
Telluric model
wave
Wavelength array (angstroms in vacuum), weighted by pixel contributions
wave_grid_mid
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
- spectrograph
Build from PYP_SPEC
- 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 aDataContainer
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 setotype=float
andotype=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 haveotype
that aretuple
,int
,float
,numpy.integer
,numpy.floating
, numpy.ndarray, or astropy.table.Table objects. E.g.,datamodel
values forotype
cannot bedict
.
- 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
- 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:
ofile (
str
) – Filenameprimary_hdr (astropy.io.fits.Header, optional)
**kwargs – Passed to super.to_file()
- 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.