pypeit.calibrations module
Class for guiding calibration object generation in PypeIt.
- class pypeit.calibrations.Calibrations(fitstbl, par, spectrograph, caldir, qadir=None, reuse_calibs=False, show=False, user_slits=None, chk_version=True)[source]
Bases:
object
Class designed to guide the generation of calibration images and objects in PypeIt.
- Parameters:
fitstbl (
PypeItMetaData
) – The class holding the metadata for all the frames in this PypeIt run. If None, we are using this class as a glorified dict to hold the objects.par (
CalibrationsPar
) – Parameter set defining optional parameters of PypeIt’s algorithms for Calibrationsspectrograph (
Spectrograph
) – Spectrograph objectcaldir (
str
, Path) – Path for the processed calibration files.qadir (
str
, optional) – Path for quality assessment output. If not provided, no QA plots are saved.reuse_calibs (
bool
, optional) – Instead of reprocessing them, load existing calibration files from disk if they exist.show (
bool
, optional) – Show plots of PypeIt’s results as the code progresses. Requires interaction from the user.user_slits (
dict
, optional) – A limited set of slits selected by the user for analysis. Seeuser_mask()
.chk_version (
bool
, optional) – When reading in existing files written by PypeIt, perform strict version checking to ensure a valid file. If False, the code will try to keep going, but this may lead to faults and quiet failures. User beware!
- fitstbl
See instantiation arguments.
- Type:
- par
See instantiation arguments.
- Type:
- spectrograph
See instantiation arguments.
- Type:
- alignments
Alignment calibration frame
- Type:
- msbpm
Boolean array with the bad-pixel mask (pixels that should masked are set to True).
- Type:
- slits
Slit tracing calibration frame
- Type:
- flatimages
Flat-field calibration frame
- Type:
- steps
A list of strings setting the set of processing steps to be completed (not necessarily those that were successful). See the
default_steps
functions of each subclass.- Type:
- failed_step
If the calibrations were unsuccessful, this is the step that led to the fault.
- Type:
- _chk_set(items)[source]
Check whether a needed attribute has previously been set
- Parameters:
items (list) – Attributes to check
- static association_summary(ofile, fitstbl, spectrograph, caldir, subset=None, det=None, overwrite=False)[source]
Write a file listing the associations between the processed calibration frames and their source raw files for every setup and every calibration group.
- Parameters:
fitstbl (
PypeItMetaData
) – The class holding the metadata for all the frames to process.spectrograph (
pypeit.spectrographs.spectrograph.Spectrograph
) – Spectrograph objectcaldir (
str
, Path) – Path for the processed calibration frames.subset (numpy.ndarray, optional) – A boolean array selecting a subset of rows from
fitstbl
for output.det (
int
,tuple
, optional) – The specific detector (or mosaic) to use when constructing the output processed calibration group file names. If None, a placeholder is used.overwrite (
bool
, optional) – Overwrite any existing file of the same name.
- find_calibrations(frametype, frameclass)[source]
Find calibration files and identifiers.
- Parameters:
frametype (
str
) – Calibration frame type. Must be a valid frame type; seevalid_frametype()
.frameclass (
CalibFrame
) – The subclass used to store the processed calibration data.
- Returns:
raw_files (
list
) – The list of raw files infitstbl
with the provided frametype.cal_file (Path) – The path with/for the processed calibration frame
calib_key (
str
) – The calibration identifiersetup (
str
) – The setup/configuration identifiercalib_id (
list
) – The calibration groupsdetname (
str
) – The detector/mosaic identifier
- get_align()[source]
Load or generate the alignment calibration frame.
- Returns:
The processed alignment image.
- Return type:
- get_arc()[source]
Load or generate the arc calibration frame.
- Returns:
The processed calibration image.
- Return type:
- static get_association(fitstbl, spectrograph, caldir, setup, calib_ID, det, must_exist=True, subset=None, include_science=False, proc_only=False)[source]
Construct a dictionary with the association between raw files and processed calibration frames.
- Parameters:
fitstbl (
PypeItMetaData
) – The class holding the metadata for all the frames to process.spectrograph (
pypeit.spectrographs.spectrograph.Spectrograph
) – Spectrograph objectcaldir (
str
, Path) – Path for the processed calibration frames.setup (
str
) – The setup/configuration of the association.calib_ID (
str
,int
) – The single calibration group of the association.must_exist (
bool
, optional) – If True, only existing calibration frames in the association are included. If False, the nominal set of processed calibration frame file names are returned, regardless of whether or not they exist.subset (numpy.ndarray, optional) – A boolean array selecting a subset of rows from
fitstbl
for output.include_science (
bool
, optional) – Include science and standard frames in the association. This parameter is mutually exclusive withproc_only
; if both are true,proc_only
takes precedence.proc_only (
bool
, optional) – If True, only return a dictionary with the names of the processed calibration frames. The dictionary sets the calibration directory toDIR
, and the other keys are the capitalized versions of the calibration type keywords; e.g.,asn['ARC']
is the processed arc frame. This parameter is mutually exclusive withinclude_science
; if both are true,proc_only
takes precedence.
- Returns:
The set of raw and processed calibration frames associated with the selected calibration group. This only includes the processed frames if
proc_only
is True, and it includes the science/standard frames ifinclude_science
is True.- Return type:
- get_bias()[source]
Load or generate the bias calibration frame.
- Returns:
The processed calibration image.
- Return type:
- get_bpm(frame=None)[source]
Load or generate the bad pixel mask.
This is primarily a wrapper for
bpm()
.- Returns:
The bad pixel mask, which should match the shape and orientation of a trimmed and PypeIt-oriented science image!
- Return type:
- get_dark()[source]
Load or generate the dark calibration frame.
- Returns:
The processed calibration image.
- Return type:
- get_flats()[source]
Load or generate the flat-field calibration images.
- Returns:
The processed calibration image.
- Return type:
- static get_instance(fitstbl, par, spectrograph, caldir, **kwargs)[source]
Get the instance of the appropriate subclass of
Calibrations
to use for reducing data from the providedspectrograph
. For argument descriptions, seeCalibrations
.
- get_scattlight()[source]
Load or generate the scattered light model.
- Returns:
The processed calibration image including the model.
- Return type:
- get_slits()[source]
Load or generate the definition of the slit boundaries.
- Returns:
Traces of the slit edges; also kept internally as
slits
.- Return type:
- get_tiltimg()[source]
Load or generate the tilt calibration frame.
- Returns:
The processed calibration image.
- Return type:
- get_tilts()[source]
Load or generate the wavelength tilts calibration frame
- Returns:
Object containing the wavelength tilt calibration.
- Return type:
- get_wv_calib()[source]
Load or generate the 1D wavelength calibrations
- Returns:
Object containing wavelength calibrations and the updated slit mask array.
- Return type:
- set_config(frame, det, par=None)[source]
Specify the critical attributes of the class to perform a set of calibrations.
Operations are:
Set the frame
Use the frame to find the calibration group
Set the detector/mosaic
Set the parameters
- Parameters:
frame (
int
) – The row index infitstbl
with the frame to calibrate.det (
int
) – Detector number.par (
CalibrationsPar
, optional) – Parameters used by the calibration procedures. If None, usepar
.
- class pypeit.calibrations.IFUCalibrations(fitstbl, par, spectrograph, caldir, qadir=None, reuse_calibs=False, show=False, user_slits=None, chk_version=True)[source]
Bases:
Calibrations
Child of Calibrations class for performing IFU calibrations. See
Calibrations
for arguments.
- class pypeit.calibrations.MultiSlitCalibrations(fitstbl, par, spectrograph, caldir, qadir=None, reuse_calibs=False, show=False, user_slits=None, chk_version=True)[source]
Bases:
Calibrations
Calibration class for performing multi-slit calibrations (and also long-slit and echelle). See
Calibrations
for arguments.Note
Calibrations are not sufficiently different yet to warrant a different class for echelle reductions. This may change if a different order is eventually required for the set of processing steps (see
default_steps()
).
- pypeit.calibrations.check_for_calibs(par, fitstbl, raise_error=True, cut_cfg=None)[source]
Perform a somewhat quick and dirty check to see if the user has provided all of the calibration frametype’s to reduce the science frames
- Parameters:
par (
PypeItPar
)fitstbl (
PypeItMetaData
, None) – The class holding the metadata for all the frames in this PypeIt run.raise_error (
bool
, optional) – If True, crash outcut_cfg (numpy.ndarray, optional) – Also cut on this restricted configuration (mainly for chk_calibs)
- Returns:
True if we passed all checks
- Return type: