pypeit.specobj module
Module for the SpecObj classes
- class pypeit.specobj.SpecObj(PYPELINE, DET, OBJTYPE='unknown', SLITID=None, ECH_ORDER=None, ECH_ORDERINDX=None)[source]
Bases:
DataContainerClass to handle single spectra from a single exposure.
One generates one of these objects for each spectrum in the exposure. They are instantiated by the object finding routine, and then all spectral extraction information for the object are assigned as attributes
The datamodel attributes are:
Version: 1.1.11
Attribute
Type
Array Type
Description
BOX_CHI2float
Reduced chi2 of the model fit for this spectral pixel
BOX_COUNTSfloat
Boxcar flux (counts)
BOX_COUNTS_IVARfloat
Inverse variance of optimally extracted flux using modelivar image (counts^2)
BOX_COUNTS_NIVARfloat
Boxcar extracted noise variance, sky+read noise only (counts^2)
BOX_COUNTS_SIGfloat
Boxcar extracted noise from IVAR (counts)
BOX_COUNTS_SIG_DETfloat
Boxcar extracted detector noise (counts)
BOX_COUNTS_SKYfloat
Boxcar extracted sky (counts)
BOX_FLAMfloat
Boxcar flux (erg/s/cm^2/Ang)
BOX_FLAM_IVARfloat
Boxcar flux inverse variance (1e-17 erg/s/cm^2/Ang)^-2
BOX_FLAM_SIGfloat
Boxcar flux uncertainty (1e-17 erg/s/cm^2/Ang)
BOX_FLATfloat
Boxcar extracted flatfield spectrum, normalized to the peak value.
BOX_FRAC_USEfloat
Fraction of pixels in the object profile subimage used for this extraction
BOX_FWHMfloat
Spectral FWHM (in Angstroms) at every pixel of the boxcar extracted flux.
BOX_MASKMask for boxcar extracted flux. True=good
BOX_NPIXfloat
Number of pixels used for the boxcar extraction; can be fractional
BOX_RADIUSfloat
Size of boxcar radius (pixels)
BOX_WAVEfloat
Boxcar Wavelengths in vacuum (Angstroms)
DECfloat
Declination (J2000) decimal degree
DETstr
A string identifier for the reduced detector or mosaic.
DETECTORObject with the detector or mosaic metadata
ECH_FRACPOSfloat, numpy.floating
Synced echelle fractional location of the object on the slit
ECH_NAMEstr
Name of the object for echelle data. Same as NAME above but order numbers are omitted giving a unique name per object.
ECH_OBJIDint, numpy.integer
Object ID for echelle data. Each object is given an index in the order it appears increasing from from left to right. These are one based.
ECH_ORDERint, numpy.integer
Physical echelle order
ECH_ORDERINDXint, numpy.integer
Order indx, analogous to SLITID for echelle. Zero based.
FLEX_SHIFT_GLOBALfloat
Global shift of the spectrum to correct for spectralflexure (pixels). This is based on the sky spectrum atthe center of the slit
FLEX_SHIFT_LOCALfloat
Local shift of the spectrum to correct for spectralflexure (pixels). This should be a small correction tothe global value, and is based on the sky spectrumextracted near the object
FLEX_SHIFT_TOTALfloat
Total shift of the spectrum to correct for spectralflexure (pixels). This is the sum of the global andlocal FLEX_SHIFT
FWHMfloat
Spatial FWHM of the object (pixels)
FWHMFITfloat
Spatial FWHM across the detector (pixels)
MASKDEF_EXTRACTbool
Boolean indicating if this is a forced extraction at the expected location from slitmask design.
MASKDEF_IDint, numpy.integer
Slitmask definition ID
MASKDEF_OBJMAGfloat
Magnitude of the object from the slitmask definition
MASKDEF_OBJMAG_BANDstr
Magnitude band of the object from the slitmask definition
MASKDEF_OBJNAMEstr
Name of the object from the slitmask definition
NAMEstr
Name of the object following the naming model
OBJIDint, numpy.integer
Object ID for multislit data. Each object is given an index for the slit it appears increasing from from left to right. These are one based.
OBJTYPEstr
Object type (e.g., standard, science)
OPT_CHI2float
Reduced chi2 of the model fit for this spectral pixel
OPT_COUNTSfloat
Optimal flux (counts)
OPT_COUNTS_IVARfloat
Inverse variance of optimally extracted flux using modelivar image (counts^2)
OPT_COUNTS_NIVARfloat
Optimally extracted noise variance, sky+read noise only (counts^2)
OPT_COUNTS_SIGfloat
Optimally extracted noise from IVAR (counts)
OPT_COUNTS_SIG_DETfloat
Optimally extracted detector noise (counts)
OPT_COUNTS_SKYfloat
Optimally extracted sky (counts)
OPT_FLAMfloat
Optimal flux (1e-17 erg/s/cm^2/Ang)
OPT_FLAM_IVARfloat
Optimal flux inverse variance (1e-17 erg/s/cm^2/Ang)^-2
OPT_FLAM_SIGfloat
Optimal flux uncertainty (1e-17 erg/s/cm^2/Ang)
OPT_FLATfloat
Optimally extracted flatfield spectrum, normalised to the peak value.
OPT_FRAC_USEfloat
Fraction of pixels in the object profile subimage used for this extraction
OPT_FWHMfloat
Spectral FWHM (in Angstroms) at every pixel of the optimally extracted flux.
OPT_MASKMask for optimally extracted flux. True=good
OPT_WAVEfloat
Optimal Wavelengths in vacuum (Angstroms)
PYPELINEstr
Name of the PypeIt pipeline mode
RAfloat
Right Ascension (J2000) decimal degree
S2Nfloat
Median signal to noise ratio of the extracted spectrum(OPT if available, otherwise BOX)
SLITIDint, numpy.integer
PypeIt slit ID (aka SPAT_ID).
SPAT_FRACPOSfloat, numpy.floating
Fractional location of the object on the slit
SPAT_FWHMfloat
Spatial FWHM of the object (arcsec)
SPAT_PIXPOSfloat, numpy.floating
Spatial location of the trace on detector (pixel) at half-way
TRACE_SPATfloat
Object trace along the spec (spatial pixel)
VEL_CORRfloat
Relativistic velocity correction for wavelengths
VEL_TYPEstr
Type of heliocentric correction (if any)
WAVE_RMSfloat, numpy.floating
RMS (pix) for the wavelength solution for this slit.
hand_extract_flagbool
Boolean indicating if this is a forced extraction at the location provided by the user.
maskwidthfloat, numpy.floating
Size (in units of spatial fwhm) of the region used for local sky subtraction
smash_peakfluxfloat
Peak value of the spectral direction collapsed spatial profile
smash_snrfloat
Peak S/N ratio of the spectral direction collapsed patial profile
trace_specint, numpy.integer
Array of pixels along the spectral direction
- Parameters:
PYPELINE (
str) – Name of thePypeItpipeline method. Allowed options are MultiSlit, Echelle, or SlicerIFU.DET (
str) – The name of the detector or mosaic from which the spectrum was extracted. For example, DET01.OBJTYPE (
str, optional) – Object type. For example: ‘unknown’, ‘standard’, ‘science’.SLITID (
int, optional) – For multislit and SlicerIFU reductions, this is an identifier for the slit (max=9999).ECH_ORDER (
int, optional) – Physical order number.ECH_ORDERINDX (
int, optional) – Running index for the order.
- __repr__()[source]
Over-ride print representation
- Returns:
Basics of the Data Container
- Return type:
- _bundle(**kwargs)[source]
Override base class to handle inclusion of
DetectorContainerorMosaicobjects for each spectrum.
- apply_flux_calib(wave_zp, zeropoint, exptime, tellmodel=None, extinct_correct=False, airmass=None, longitude=None, latitude=None, extinctfilepar=None, extrap_sens=False)[source]
Apply a sensitivity function to our spectrum
FLAM, FLAM_SIG, and FLAM_IVAR are generated
- Parameters:
wave_zp (numpy.ndarray) – Zeropoint wavelength array
zeropoint (numpy.ndarray) – zeropoint array
exptime (float) – Exposure time
tellmodel – Telluric correction. Note: This is deprecated and will be removed in a future version.
extinct_correct (bool, optional) – If True, extinction correct
airmass (float, optional) – Airmass
longitude (float, optional) – longitude in degree for observatory
latitude (float, optional) – latitude in degree for observatory Used for extinction correction
extinctfilepar (str, optional) – [sensfunc][UVIS][extinct_file] parameter Used for extinction correction
extrap_sens (bool, optional) – Extrapolate the sensitivity function (instead of crashing out)
- apply_helio(vel_corr, refframe)[source]
Apply a heliocentric correction
Wavelength arrays are modified in place
- apply_spectral_flexure(shift, sky_spec)[source]
Apply interpolation with the flexure dict
- Parameters:
shift (float) – additive spectral flexure in pixels
sky_spec (linetools.spectra.xspectrum1d.XSpectrum1D) – Sky Spectrum
- Returns:
New sky spectrum (mainly for QA)
- Return type:
- best_ext_match(extract=None, fluxed=True)[source]
Determine the extraction and calibration type that best matches a user request.
Precedence is given to the requested extraction and calibration types. Beyond that, optimal extraction takes precedence over boxcar extraction, and flux-calibrated data take precedence over uncalibrated counts.
- Parameters:
extract (
str, optional) – The extraction used to produce the spectrum. Must be either None,'BOX'(for a boxcar extraction), or'OPT'for optimal extraction. If None, the optimal extraction will be returned, if it exists, otherwise the boxcar extraction will be returned.fluxed (
bool, optional) – If True, return the flux calibrated spectrum, if it exists. If the flux calibration hasn’t been performed orfluxed=False, the spectrum is returned in counts.
- Returns:
The adjusted extraction type (
'BOX'or'OPT') and the adjusted calibration type (True for flux-calibrated, False for uncalibrated counts).- Return type:
- datamodel = {'BOX_CHI2': {'atype': <class 'float'>, 'descr': 'Reduced chi2 of the model fit for this spectral pixel', 'otype': <class 'numpy.ndarray'>}, 'BOX_COUNTS': {'atype': <class 'float'>, 'descr': 'Boxcar flux (counts)', 'otype': <class 'numpy.ndarray'>}, 'BOX_COUNTS_IVAR': {'atype': <class 'float'>, 'descr': 'Inverse variance of optimally extracted flux using modelivar image (counts^2)', 'otype': <class 'numpy.ndarray'>}, 'BOX_COUNTS_NIVAR': {'atype': <class 'float'>, 'descr': 'Boxcar extracted noise variance, sky+read noise only (counts^2)', 'otype': <class 'numpy.ndarray'>}, 'BOX_COUNTS_SIG': {'atype': <class 'float'>, 'descr': 'Boxcar extracted noise from IVAR (counts)', 'otype': <class 'numpy.ndarray'>}, 'BOX_COUNTS_SIG_DET': {'atype': <class 'float'>, 'descr': 'Boxcar extracted detector noise (counts)', 'otype': <class 'numpy.ndarray'>}, 'BOX_COUNTS_SKY': {'atype': <class 'float'>, 'descr': 'Boxcar extracted sky (counts)', 'otype': <class 'numpy.ndarray'>}, 'BOX_FLAM': {'atype': <class 'float'>, 'descr': 'Boxcar flux (erg/s/cm^2/Ang)', 'otype': <class 'numpy.ndarray'>}, 'BOX_FLAM_IVAR': {'atype': <class 'float'>, 'descr': 'Boxcar flux inverse variance (1e-17 erg/s/cm^2/Ang)^-2', 'otype': <class 'numpy.ndarray'>}, 'BOX_FLAM_SIG': {'atype': <class 'float'>, 'descr': 'Boxcar flux uncertainty (1e-17 erg/s/cm^2/Ang)', 'otype': <class 'numpy.ndarray'>}, 'BOX_FLAT': {'atype': <class 'float'>, 'descr': 'Boxcar extracted flatfield spectrum, normalized to the peak value.', 'otype': <class 'numpy.ndarray'>}, 'BOX_FRAC_USE': {'atype': <class 'float'>, 'descr': 'Fraction of pixels in the object profile subimage used for this extraction', 'otype': <class 'numpy.ndarray'>}, 'BOX_FWHM': {'atype': <class 'float'>, 'descr': 'Spectral FWHM (in Angstroms) at every pixel of the boxcar extracted flux.', 'otype': <class 'numpy.ndarray'>}, 'BOX_MASK': {'atype': <class 'numpy.bool'>, 'descr': 'Mask for boxcar extracted flux. True=good', 'otype': <class 'numpy.ndarray'>}, 'BOX_NPIX': {'atype': <class 'float'>, 'descr': 'Number of pixels used for the boxcar extraction; can be fractional', 'otype': <class 'numpy.ndarray'>}, 'BOX_RADIUS': {'descr': 'Size of boxcar radius (pixels)', 'otype': <class 'float'>}, 'BOX_WAVE': {'atype': <class 'float'>, 'descr': 'Boxcar Wavelengths in vacuum (Angstroms)', 'otype': <class 'numpy.ndarray'>}, 'DEC': {'descr': 'Declination (J2000) decimal degree', 'otype': <class 'float'>}, 'DET': {'descr': 'A string identifier for the reduced detector or mosaic.', 'otype': <class 'str'>}, 'DETECTOR': {'descr': 'Object with the detector or mosaic metadata', 'otype': (<class 'pypeit.images.detector_container.DetectorContainer'>, <class 'pypeit.images.mosaic.Mosaic'>)}, 'ECH_FRACPOS': {'descr': 'Synced echelle fractional location of the object on the slit', 'otype': (<class 'float'>, <class 'numpy.floating'>)}, 'ECH_NAME': {'descr': 'Name of the object for echelle data. Same as NAME above but order numbers are omitted giving a unique name per object.', 'otype': <class 'str'>}, 'ECH_OBJID': {'descr': 'Object ID for echelle data. Each object is given an index in the order it appears increasing from from left to right. These are one based.', 'otype': (<class 'int'>, <class 'numpy.integer'>)}, 'ECH_ORDER': {'descr': 'Physical echelle order', 'otype': (<class 'int'>, <class 'numpy.integer'>)}, 'ECH_ORDERINDX': {'descr': 'Order indx, analogous to SLITID for echelle. Zero based.', 'otype': (<class 'int'>, <class 'numpy.integer'>)}, 'FLEX_SHIFT_GLOBAL': {'descr': 'Global shift of the spectrum to correct for spectralflexure (pixels). This is based on the sky spectrum atthe center of the slit', 'otype': <class 'float'>}, 'FLEX_SHIFT_LOCAL': {'descr': 'Local shift of the spectrum to correct for spectralflexure (pixels). This should be a small correction tothe global value, and is based on the sky spectrumextracted near the object', 'otype': <class 'float'>}, 'FLEX_SHIFT_TOTAL': {'descr': 'Total shift of the spectrum to correct for spectralflexure (pixels). This is the sum of the global andlocal FLEX_SHIFT', 'otype': <class 'float'>}, 'FWHM': {'descr': 'Spatial FWHM of the object (pixels)', 'otype': <class 'float'>}, 'FWHMFIT': {'atype': <class 'float'>, 'descr': 'Spatial FWHM across the detector (pixels)', 'otype': <class 'numpy.ndarray'>}, 'MASKDEF_EXTRACT': {'descr': 'Boolean indicating if this is a forced extraction at the expected location from slitmask design. ', 'otype': <class 'bool'>}, 'MASKDEF_ID': {'descr': 'Slitmask definition ID', 'otype': (<class 'int'>, <class 'numpy.integer'>)}, 'MASKDEF_OBJMAG': {'descr': 'Magnitude of the object from the slitmask definition', 'otype': <class 'float'>}, 'MASKDEF_OBJMAG_BAND': {'descr': 'Magnitude band of the object from the slitmask definition', 'otype': <class 'str'>}, 'MASKDEF_OBJNAME': {'descr': 'Name of the object from the slitmask definition', 'otype': <class 'str'>}, 'NAME': {'descr': 'Name of the object following the naming model', 'otype': <class 'str'>}, 'OBJID': {'descr': 'Object ID for multislit data. Each object is given an index for the slit it appears increasing from from left to right. These are one based.', 'otype': (<class 'int'>, <class 'numpy.integer'>)}, 'OBJTYPE': {'descr': 'Object type (e.g., standard, science)', 'otype': <class 'str'>}, 'OPT_CHI2': {'atype': <class 'float'>, 'descr': 'Reduced chi2 of the model fit for this spectral pixel', 'otype': <class 'numpy.ndarray'>}, 'OPT_COUNTS': {'atype': <class 'float'>, 'descr': 'Optimal flux (counts)', 'otype': <class 'numpy.ndarray'>}, 'OPT_COUNTS_IVAR': {'atype': <class 'float'>, 'descr': 'Inverse variance of optimally extracted flux using modelivar image (counts^2)', 'otype': <class 'numpy.ndarray'>}, 'OPT_COUNTS_NIVAR': {'atype': <class 'float'>, 'descr': 'Optimally extracted noise variance, sky+read noise only (counts^2)', 'otype': <class 'numpy.ndarray'>}, 'OPT_COUNTS_SIG': {'atype': <class 'float'>, 'descr': 'Optimally extracted noise from IVAR (counts)', 'otype': <class 'numpy.ndarray'>}, 'OPT_COUNTS_SIG_DET': {'atype': <class 'float'>, 'descr': 'Optimally extracted detector noise (counts)', 'otype': <class 'numpy.ndarray'>}, 'OPT_COUNTS_SKY': {'atype': <class 'float'>, 'descr': 'Optimally extracted sky (counts)', 'otype': <class 'numpy.ndarray'>}, 'OPT_FLAM': {'atype': <class 'float'>, 'descr': 'Optimal flux (1e-17 erg/s/cm^2/Ang)', 'otype': <class 'numpy.ndarray'>}, 'OPT_FLAM_IVAR': {'atype': <class 'float'>, 'descr': 'Optimal flux inverse variance (1e-17 erg/s/cm^2/Ang)^-2', 'otype': <class 'numpy.ndarray'>}, 'OPT_FLAM_SIG': {'atype': <class 'float'>, 'descr': 'Optimal flux uncertainty (1e-17 erg/s/cm^2/Ang)', 'otype': <class 'numpy.ndarray'>}, 'OPT_FLAT': {'atype': <class 'float'>, 'descr': 'Optimally extracted flatfield spectrum, normalised to the peak value.', 'otype': <class 'numpy.ndarray'>}, 'OPT_FRAC_USE': {'atype': <class 'float'>, 'descr': 'Fraction of pixels in the object profile subimage used for this extraction', 'otype': <class 'numpy.ndarray'>}, 'OPT_FWHM': {'atype': <class 'float'>, 'descr': 'Spectral FWHM (in Angstroms) at every pixel of the optimally extracted flux.', 'otype': <class 'numpy.ndarray'>}, 'OPT_MASK': {'atype': <class 'numpy.bool'>, 'descr': 'Mask for optimally extracted flux. True=good', 'otype': <class 'numpy.ndarray'>}, 'OPT_WAVE': {'atype': <class 'float'>, 'descr': 'Optimal Wavelengths in vacuum (Angstroms)', 'otype': <class 'numpy.ndarray'>}, 'PYPELINE': {'descr': 'Name of the PypeIt pipeline mode', 'otype': <class 'str'>}, 'RA': {'descr': 'Right Ascension (J2000) decimal degree', 'otype': <class 'float'>}, 'S2N': {'descr': 'Median signal to noise ratio of the extracted spectrum(OPT if available, otherwise BOX)', 'otype': <class 'float'>}, 'SLITID': {'descr': 'PypeIt slit ID (aka SPAT_ID).', 'otype': (<class 'int'>, <class 'numpy.integer'>)}, 'SPAT_FRACPOS': {'descr': 'Fractional location of the object on the slit', 'otype': (<class 'float'>, <class 'numpy.floating'>)}, 'SPAT_FWHM': {'descr': 'Spatial FWHM of the object (arcsec)', 'otype': <class 'float'>}, 'SPAT_PIXPOS': {'descr': 'Spatial location of the trace on detector (pixel) at half-way', 'otype': (<class 'float'>, <class 'numpy.floating'>)}, 'TRACE_SPAT': {'atype': <class 'float'>, 'descr': 'Object trace along the spec (spatial pixel)', 'otype': <class 'numpy.ndarray'>}, 'VEL_CORR': {'descr': 'Relativistic velocity correction for wavelengths', 'otype': <class 'float'>}, 'VEL_TYPE': {'descr': 'Type of heliocentric correction (if any)', 'otype': <class 'str'>}, 'WAVE_RMS': {'descr': 'RMS (pix) for the wavelength solution for this slit.', 'otype': (<class 'float'>, <class 'numpy.floating'>)}, 'hand_extract_flag': {'descr': 'Boolean indicating if this is a forced extraction at the location provided by the user. ', 'otype': <class 'bool'>}, 'maskwidth': {'descr': 'Size (in units of spatial fwhm) of the region used for local sky subtraction', 'otype': (<class 'float'>, <class 'numpy.floating'>)}, 'smash_peakflux': {'descr': 'Peak value of the spectral direction collapsed spatial profile', 'otype': <class 'float'>}, 'smash_snr': {'descr': 'Peak S/N ratio of the spectral direction collapsed patial profile', 'otype': <class 'float'>}, 'trace_spec': {'atype': (<class 'int'>, <class 'numpy.integer'>), 'descr': 'Array of pixels along the spectral direction', 'otype': <class 'numpy.ndarray'>}}
Defines the current datmodel.
- classmethod from_arrays(PYPELINE: str, wave: ndarray, counts: ndarray, ivar: ndarray, flat=None, mode='OPT', DET='DET01', SLITID=0, **kwargs)[source]
- internals = ['smash_peakflux', 'smash_snr', 'hand_extract_flag', 'hand_extract_spec', 'hand_extract_spat', 'hand_extract_det', 'hand_extract_fwhm', 'prof_nsigma', 'sign', 'min_spat', 'max_spat', 'ech_frac_was_fit', 'ech_snr']
A list of strings identifying a set of internal attributes that are not part of the datamodel.
- med_s2n()[source]
Return median S/N of the spectrum Uses OPT_COUNTS if present and then BOX_COUNTS
- Returns:
float
- property mnx_wave
Return min, max wavelength of the spectrum Uses OPT_WAVE if present and then BOX_WAVE
- Returns:
min, max (float)
- Return type:
- ready_for_extraction()[source]
Simple method to check all the items are filled and ready for skysub and extraction.
- Returns:
True if all checks have passed
- Return type:
- set_name()[source]
Construct the
PypeItname for this object.The
PypeItname depends on the type of data being processed:For multislit and SlicerIFU data, the name is
SPATnnnn-SLITmmmm-{DET}, wherennnnis the nearest integer pixel in the spatial direction (at the spectral midpoint) where the object was extracted,mmmmis the slit identification number, and{DET}is the string identifier for the detector or mosaic.For echelle data, the name is
OBJnnnn-{DET}-ORDERoooo, wherennnnis 1000 times the fractional position along the spatial direction rounded to the nearest integer,{DET}is the string identifier for the detector or mosaic, andoooois the echelle order.
For echelle data, this modifies both
ECH_NAMEandNAME; otherwise, only the latter is set.
- property slit_order
- property slit_orderindx
- to_hdu(**kwargs)[source]
Override the base class function to force the main datamodel attributes to be written to an astropy.io.fits.BinTableHDU object. This is identical to the base class method except
force_to_bintblis always set to True.
- to_xspec1d(masked=True, extraction='OPT', fluxed=True)[source]
Create an XSpectrum1D using this spectrum.
- Parameters:
- Returns:
Spectrum object
- Return type:
- update_flex_shift(shift, flex_type='local')[source]
Store the total spectral flexure shift in pixels
- Parameters:
shift (float) – additive spectral flexure in pixels
- version = '1.1.11'
Current datamodel version number.