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:
DataContainerDataContainer to hold single spectra, e.g., from
CoAdd1D.The datamodel attributes are:
Version: 1.0.2
Attribute
Type
Array Type
Description
PYP_SPECstr
PypeItspectrograph designationext_modestr
Extraction mode (options: BOX, OPT)
fluxFlux array in units of counts/s or 10^-17 erg/s/cm^2/Ang; see
fluxedfluxedbool
Boolean indicating if the spectrum is fluxed.
ivarInverse variance array (matches units of flux)
maskMask array (1=Good,0=Bad)
obj_modelObject model for tellurics
sigmaOne sigma noise array, equivalent to 1/sqrt(ivar) (matches units of flux)
spect_metadict
header dict
telluricTelluric model
waveWavelength array (angstroms in vacuum), weighted by pixel contributions
wave_grid_midWavelength (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
datamodelneeded for each implementation of aDataContainerderived 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=floatandotype=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
atypekeyword 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,
datamodelcomponents are restricted to haveotypethat aretuple,int,float,numpy.integer,numpy.floating, numpy.ndarray, or astropy.table.Table objects. E.g.,datamodelvalues forotypecannot 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.
- property npix
Number of pixels in the spectrum.
- Returns:
Number of pixels in the spectrum.
- Return type:
- rebin(new_wv, fill_value=0.0, grow_bad_sig=False)[source]
Rebin the spectrum to a new OneSpec object with the input array
Uses simple linear interpolation. The default (and only) option conserves counts (and flambda).
WARNING: Do not trust either edge pixel of the new array. In fact the sig is set to 0 for each of these Also be aware that neighboring pixels are likely to be correlated in a manner that is not described by the error array.
- 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.