pypeit.wavecalib module
Module for guiding 1D Wavelength Calibration
- class pypeit.wavecalib.BuildWaveCalib(msarc, slits, spectrograph, par, lamps, meta_dict=None, det=1, qa_path=None, msbpm=None)[source]
Bases:
object
Class to guide wavelength calibration
- Parameters
msarc (
pypeit.images.pypeitimage.PypeItImage
) – Arc image, created by the ArcImage classslits (
pypeit.slittrace.SlitTraceSet
) – Slit edgesspectrograph (
pypeit.spectrographs.spectrograph.Spectrograph
) – The Spectrograph instance that sets the instrument used to take the observations. Used to setspectrograph
.par (
pypeit.par.pypeitpar.WaveSolutionPar
) – The parameters used for the wavelength solution Uses [‘calibrations’][‘wavelengths’](dict (meta_dict) –
optional): Dictionary containing meta information required for wavelength calibration. Specifically for non-fixed format echelles this dict must contain the following keys:
'echangle'
: the echelle angle'xdangle'
: the cross-disperser angle'dispmame'
: the disperser name
det (int, optional) – Detector number
msbpm (ndarray, optional) – Bad pixel mask image
qa_path (str, optional) – For QA
- steps
list List of the processing steps performed
- wv_calib
dict Primary output. Keys 0, 1, 2, 3 are solution for individual previously slit steps
- arccen
(nwave, nslit) Extracted arc(s) down the center of the slit(s)
- Type
ndarray
- maskslits
ndarray (nslit); bool Slits to ignore because they were not extracted. WARNING: Outside of this Class, it is best to regenerate the mask using make_maskslits()
- gpm
Good pixel mask Eventually, we might attach this to self.msarc although that would then require that we write it to disk with self.msarc.image
- Type
- wvc_bpm
Mask for slits attempted to have a wv_calib solution
- Type
- build_wv_calib(arccen, method, skip_QA=False)[source]
Main routine to generate the wavelength solutions in a loop over slits Wrapper to arc.simple_calib or arc.calib_with_arclines
self.maskslits is updated for slits that fail
- Parameters
method – str ‘simple’ – arc.simple_calib ‘arclines’ – arc.calib_with_arclines ‘holy-grail’ – wavecal.autoid.HolyGrail ‘reidentify’ – wavecal.auotid.ArchiveReid ‘identify’ – wavecal.identify.Identify ‘full_template’ – wavecal.auotid.full_template
skip_QA (bool, optional) –
- Returns
self.wv_calib
- Return type
- echelle_2dfit(wv_calib, debug=False, skip_QA=False)[source]
Fit a two-dimensional wavelength solution for echelle data.
Primarily a wrapper for
pypeit.core.arc.fit2darc()
, using data unpacked from thewv_calib
dictionary.- Parameters
wv_calib (
pypeit.wavecalib.WaveCalib
) – Wavelength calibration objectdebug (
bool
, optional) – Show debugging infoskip_QA (
bool
, optional) – Flag to skip construction of the nominal QA plots.
- Returns
- list of
pypeit.fitting.PypeItFit
: objects containing information from 2-d fit. Frequently a list of 1 fit. The main exception is for a mosaic when one sets echelle_separate_2d=True
- list of
- Return type
- extract_arcs(slitIDs=None)[source]
Extract the arcs down each slit/order
Wrapper to arc.get_censpec()
- Parameters
slitIDs (
list
, optional) – A list of the slit IDs to extract (if None, all slits will be extracted)- Returns
- Returns the following:
self.arccen: ndarray, (nspec, nslit): arc spectrum for all slits
self.arc_maskslit: ndarray, bool (nsit): boolean array containing a mask indicating which slits are good True = masked (bad)
- Return type
- frametype = 'wv_calib'
- run(skip_QA=False, debug=False)[source]
Main driver for wavelength calibration
- Code flow:
Extract 1D arc spectra down the center of each unmasked slit/order
Load the parameters guiding wavelength calibration
Generate the 1D wavelength fits
Generate a mask
- Parameters
skip_QA – bool, optional
- Returns
wv_calib dict
- Return type
- class pypeit.wavecalib.WaveCalib(wv_fits=None, nslits=None, spat_ids=None, PYP_SPEC=None, strpar=None, wv_fit2d=None, arc_spectra=None, lamps=None, det_img=None)[source]
Bases:
CalibFrame
Calibration frame containing the wavelength calibration.
All of the items in the datamodel are required for instantiation, although they can be None (but shouldn’t be)
The datamodel attributes are:
Version: 1.1.0
Attribute
Type
Array Type
Description
PYP_SPEC
str
PypeIt spectrograph name
arc_spectra
2D array: 1D extracted spectra, slit by slit (nspec, nslits)
det_img
Detector image which indicates which pixel in the mosaic corresponds to which detector; used occasionally by echelle. Currently only saved if ech_separate_2d=True
lamps
str
List of arc lamps used for the wavelength calibration
nslits
int
Total number of slits. This can include masked slits
spat_ids
Slit spat_ids. Named distinctly from that in WaveFit
strpar
str
Parameters as a string
wv_fit2d
2D wavelength solution(s) (echelle). If there is more than one, they must be aligned to the separate detectors analyzed
wv_fits
WaveFit to each 1D wavelength solution
- _bundle()[source]
Override base class function to write one HDU per image. Any extras are in the HDU header of the primary image.
- Returns
A list of dictionaries, each list element is written to its own fits extension.
- Return type
- classmethod _parse(hdu, **kwargs)[source]
See
_parse()
for description and list of returned objects. All keyword arguments are ignored by this function!
- build_waveimg(tilts, slits, spat_flexure=None, spec_flexure=None)[source]
Main algorithm to build the wavelength image
- Only applied to good slits, which means any non-flagged or flagged
in the exclude_for_reducing list
- Parameters
tilts (numpy.ndarray) – Image holding tilts
slits (
pypeit.slittrace.SlitTraceSet
) –spat_flexure (float, optional) – Spatial flexure correction in pixels.
spec_flexure (float, numpy.ndarray, optional) – Spectral flexure correction in pixels. If a float, the same spectral flexure correction will be applied to all slits. If a numpy array, the length of the array should be the same as the number of slits. The value of each element is the spectral shift in pixels to be applied to each slit.
- Returns
The wavelength image.
- Return type
- calib_file_format = 'fits'
The extension and file format of the output file. Should be
'fits'
or'fits.gz'
(for gzipped output).
- calib_type = 'WaveCalib'
The type of the calibration frame, primarily used to set the name of the output file.
- chk_synced(slits)[source]
Confirm the slits in WaveCalib are aligned to that in SlitTraceSet
Barfs if not
- Parameters
slits (
pypeit.slittrace.SlitTraceSet
) –
- datamodel = {'PYP_SPEC': {'descr': 'PypeIt spectrograph name', 'otype': <class 'str'>}, 'arc_spectra': {'atype': <class 'numpy.floating'>, 'descr': '2D array: 1D extracted spectra, slit by slit (nspec, nslits)', 'otype': <class 'numpy.ndarray'>}, 'det_img': {'atype': <class 'numpy.integer'>, 'descr': 'Detector image which indicates which pixel in the mosaic corresponds to which detector; used occasionally by echelle. Currently only saved if ech_separate_2d=True', 'otype': <class 'numpy.ndarray'>}, 'lamps': {'descr': 'List of arc lamps used for the wavelength calibration', 'otype': <class 'str'>}, 'nslits': {'descr': 'Total number of slits. This can include masked slits', 'otype': <class 'int'>}, 'spat_ids': {'atype': <class 'numpy.integer'>, 'descr': 'Slit spat_ids. Named distinctly from that in WaveFit ', 'otype': <class 'numpy.ndarray'>}, 'strpar': {'descr': 'Parameters as a string', 'otype': <class 'str'>}, 'wv_fit2d': {'atype': <class 'pypeit.core.fitting.PypeItFit'>, 'descr': '2D wavelength solution(s) (echelle). If there is more than one, they must be aligned to the separate detectors analyzed', 'otype': <class 'numpy.ndarray'>}, 'wv_fits': {'atype': <class 'pypeit.core.wavecal.wv_fitting.WaveFit'>, 'descr': 'WaveFit to each 1D wavelength solution', 'otype': <class 'numpy.ndarray'>}}
Default datamodel for any
CalibFrame
. Derived classes should instantiate their datamodels by first inheriting from the base class. E.g.:class ArcFrame(CalibFrame): datamodel = {**CalibFrame.datamodel, ...}
- property par
- version = '1.1.0'
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.