pypeit.pypeit module
Main driver class for PypeIt run
- class pypeit.pypeit.PypeIt(pypeit_file, verbosity=2, overwrite=True, reuse_calibs=False, logname=None, show=False, redux_path=None, calib_only=False)[source]
Bases:
object
This class runs the primary calibration and extraction in PypeIt
Todo
Fill in list of attributes!
- Parameters:
pypeit_file (
str
) – PypeIt filename.verbosity (
int
, optional) –Verbosity level of system output. Can be:
0: No output
1: Minimal output (default)
2: All output
overwrite (
bool
, optional) – Flag to overwrite any existing files/directories.reuse_calibs (
bool
, optional) – Reuse any pre-existing calibration fileslogname (
str
, optional) – The name of an ascii log file with the details of the reduction.show – (
bool
, optional): Show reduction steps via plots (which will block further execution until clicked on) and outputs to ginga. Requires remote control ginga session viaginga --modules=RC,SlitWavelength &
redux_path (
str
, optional) – Over-ride reduction path in PypeIt file (e.g. Notebook usage)calib_only – (
bool
, optional): Only generate the calibration files that you can
- pypeit_file
Name of the pypeit file to read. PypeIt files have a specific set of valid formats. A description can be found PypeIt Reduction File.
- Type:
- fitstbl
holds the meta info
- calib_all()[source]
Process all calibration frames.
Provides an avenue to reduce a dataset without (or omitting) any science/standard frames.
- calib_one(frames, det)[source]
Run Calibration for a single exposure/detector pair
- Parameters:
- Returns:
caliBrate (
pypeit.calibrations.Calibrations
)
- extract_one(frames, det, sciImg, bkg_redux_sciimg, objFind, initial_sky, sobjs_obj)[source]
Extract Objects in a single exposure/detector pair
sci_ID and det need to have been set internally prior to calling this method
- Parameters:
frames (
list
) – List of frames to extract; stacked if more than one is provideddet (
int
) – Detector number (1-indexed)sciImg (
PypeItImage
) – Data container that holds a single image from a single detector and its related images (e.g. ivar, mask)bkg_redux_sciimg (
PypeItImage
, optional) – Data container that holds a single image from a single detector and its related images (e.g. ivar, mask) before background subtraction if self.bkg_redux is True, otherwise None. It’s used to generate a global sky model without bkg subtraction.objFind –
FindObjects
Object finding objectinitial_sky (numpy.ndarray) – Initial global sky model
sobjs_obj (
pypeit.specobjs.SpecObjs
) – List of objects found during run_objfind
- Returns:
Returns six numpy.ndarray objects and a
pypeit.specobjs.SpecObjs
object with the extracted spectra from this exposure/detector pair. The six numpy.ndarray objects are (1) the science image, (2) its inverse variance, (3) the sky model, (4) the object model, (5) the model inverse variance, and (6) the mask.- Return type:
- get_sci_metadata(frame, det)[source]
Grab the meta data for a given science frame and specific detector
- Parameters:
- Returns:
- 5 objects are returned::
str: Object type; science or standard
str: Setup/configuration string
astropy.time.Time: Time of observation
str: Basename of the frame
str: Binning of the detector
- get_std_outfile(standard_frames)[source]
Return the spec1d file name for a reduced standard to use as a tracing crutch.
The file is either constructed using the provided standard frame indices or it is directly pulled from the
FindObjPar
parameters inpar
. The latter takes precedence. If more than one row is provided bystandard_frames
, the first index is used.
- load_skyregions(initial_slits=False, scifile=None, frame=None, spat_flexure=None)[source]
Generate or load sky regions, if defined by the user.
Sky regions are defined by the internal provided parameters; see
user_regions
inSkySubPar
. If included in the pypeit file like so,[reduce] [[skysub]] user_regions = :25,75:
The first and last 25% of all slits are used as sky. If the user has used the
pypeit_skysub_regions
GUI to generate a sky mask for a given frame, this can be searched for and loaded by setting the parameter touser
:[reduce] [[skysub]] user_regions = user
- Parameters:
initial_slits (
bool
, optional) – Flag to use the initial slits before any tweaking based on the slit-illumination profile; seeselect_edges()
.scifile (
str
, optional) – The file name used to define the user-based sky regions. Only used ifuser_regions = user
.frame (
int
, optional) – The index of the frame used to construct the calibration key. Only used ifuser_regions = user
.spat_flexure (
float
, None, optional) – The spatial flexure (measured in pixels) of the science frame relative to the trace frame.
- Returns:
skymask – A boolean array used to select sky pixels; i.e., True is a pixel that corresponds to a sky region. If the
user_regions
parameter is not set (or an empty string), the returned value is None.- Return type:
- objfind_one(frames, det, bg_frames=None, std_outfile=None)[source]
Reduce + Find Objects in a single exposure/detector pair
sci_ID and det need to have been set internally prior to calling this method
- Parameters:
frames (
list
) – List of frames to extract; stacked if more than one is provideddet (
int
) – Detector number (1-indexed)bg_frames (
list
, optional) – List of frames to use as the background. Can be empty.std_outfile (
str
, optional) – Filename for the standard star spec1d file. Passed directly toget_std_trace()
.
- Returns:
global_sky (numpy.ndarray) – Initial global sky model
sobjs_obj (
SpecObjs
) – List of objects foundsciImg (
PypeItImage
) – Science imagebkg_redux_sciimg (
PypeItImage
) – Science image before background subtraction if self.bkg_redux is True, otherwise None. It’s used to generate a global sky model without bkg subtraction.objFind (
FindObjects
) – Object finding speobject
- property qa_path
Return the path to the top-level QA directory.
- reduce_all()[source]
Main driver of the entire reduction
Calibration and extraction via a series of calls to
reduce_exposure()
.
- reduce_exposure(frames, bg_frames=None, std_outfile=None)[source]
Reduce a single exposure
- Parameters:
- Returns:
The dictionary containing the primary outputs of extraction.
- Return type:
- refframe_correct(slits, ra, dec, obstime, slitgpm=None, waveimg=None, sobjs=None)[source]
Correct the calibrated wavelength to the user-supplied reference frame
- Parameters:
slits (
SlitTraceSet
) – Slit trace set objectobstime (astropy.time.Time) – Observation time
slitgpm (numpy.ndarray, None, optional) – 1D boolean array indicating the good slits (True). If None, the gpm will be taken from slits
waveimg (numpy.ndarray, optional) – Two-dimensional image specifying the wavelength of each pixel
sobjs (
SpecObjs
, None, optional) – Spectrally extracted objects
- save_exposure(frame, all_spec2d, all_specobjs, basename, history=None)[source]
Save the outputs from extraction for a given exposure
- Parameters:
frame (
int
) – 0-indexed row in the metadata table with the frame that has been reduced.all_spec2d (
pypeit.spec2dobj.AllSpec2DObj
)sci_dict (
dict
) – Dictionary containing the primary outputs of extractionbasename (
str
) – The root name for the output file.history (
pypeit.history.History
) – History entries to be added to fits header
- Returns:
All of the objects saved to disk
- Return type:
None or SpecObjs
- property science_path
Return the path to the science directory.
- static select_detectors(spectrograph, detnum, slitspatnum=None)[source]
Get the set of detectors to be reduced.
This is mostly a wrapper for
select_detectors()
, except that it applies any limitations set by theReduxPar
parameters.- Parameters:
spectrograph (
Spectrograph
) – Spectrograph instance that defines the allowed detectors/mosaics.slitspatnum (
str
, optional) – Used to restrict the reduction to a specified slit. SeeReduxPar
.
- Returns:
List of unique detectors or detector mosaics to be reduced.
- Return type: