pypeit.exposure module
- pypeit.exposure.adjust_for_slitmask(sciImg_dict, spectrograph, fitstbl, par, frame0, all_specobjs_objfind, calib_slits)[source]
Adjust slitmask information for a given set of science images.
This function processes slitmask design information, applies spatial flexure corrections, computes dither offsets, and updates the slitmask calibration data. It also matches slitmask design to detected objects and adds undetected objects based on the design.
- Parameters:
sciImg_dict (
dict) – A dict of science image objects, one for each detector, containing information such as spatial flexure and detector properties.spectrograph (
Spectrograph) – Spectrograph objectfitstbl (
PypeItMetaData) – The class holding the metadata for all the frames in this PypeIt run.par (
PypeItPar) – The parameter set for the reduction process, including slitmask and object finding parameters.frame0 (
int) – The index of the current frame in the FITS table.binning (
str) – The binning string (e.g., ‘2,2’) specifying the spectral and spatial binning.all_specobjs_objfind (
list) – A list of SpecObj objects representing detected objects for all detectors.calib_slits (
list) – A list of SlitTraceSet objects containing slitmask calibration data for all detectors.
- Returns:
list: Updated list of SlitTraceSet objects with adjusted slitmask information, including object positions and offsets. SpecObjs: Updated SpecObjs object with matched and added objects
- Return type:
- pypeit.exposure.extract_exposure(sciImg_dict, spectrograph, fitstbl, par, frames, detectors, calib_ID, calibrations_path, all_specobjs_objfind, final_sky_dict, bkg_redux_final_sky_dict, calib_slits, bkg_redux=False, find_negative=False)[source]
Extracts spectral data from a set of science images and performs background subtraction, sky subtraction, and object extraction.
Calls
extract_det()for each detector.- Parameters:
sciImg_dict (
dict) – A dict of science image objects, one for each detector, containing information such as spatial flexure and detector properties.spectrograph (
Spectrograph) – Spectrograph objectfitstbl (
PypeItMetaData) – The class holding the metadata for all the frames in this PypeIt run.par (
PypeItPar) – The parameter set for the reduction process,frames (
list) – A list of frame indices to process.detectors – List of detectors to process.
calib_ID (
str) – The calibration group ID.calibrations_path (
str) – The path to the calibration files.all_specobjs_objfind – SpecObjs object containing objects found during object finding.
final_sky_dict (
dict) – Dictionary containing final sky models for each detector.bkg_redux_final_sky_dict (
dict) – Dictionary containing final bkg_redux sky models for each detector.calib_slits (
list) – A list of SlitTraceSet objects for all detectors updatedsubtraction. (after slitmask adjustment and findobj+sky)
bkg_redux (bool, optional) – If True, perform background reduction. Default is False.
find_negative (bool, optional) – If True, search for negative objects. Default is False.
- Returns:
- A tuple containing:
all_spec2d (AllSpec2DObj): Container for all extracted 2D spectra.
all_specobjs_extract (SpecObjs): Container for all extracted objects.
- Return type:
- pypeit.exposure.findobj_on_exposure(sciImg_dict, bkg_redux_sciimg_dict, spectrograph, fitstbl, par, frames, detectors, calib_ID, calibrations_path, std_outfile=None, bkg_redux=False, find_negative=False, show=False)[source]
Identifies objects on a set of exposures for the specified detectors. This function loops over the provided detectors, science images, and identifies objects using the findobj_on_det method. It returns the initial sky model for each detector and a collection of identified spectral objects.
Calls
process_one_det()for each detector.- Parameters:
sciImg_dict (
dict) – A dict of science image objects, one for each detector, containing information such as spatial flexure and detector properties.bkg_redux_sciimg_dict (dict) – A dict of background image objects, one for each detector, containing information such as spatial flexure and detector properties.
spectrograph (
Spectrograph) – Spectrograph objectfitstbl (
PypeItMetaData) – The class holding the metadata for all the frames in this PypeIt run.par (
PypeItPar) – The parameter set for the reduction process,frames (
list) – A list of frame indices to process.calib_ID (
str) – The calibration group ID.detectors (list) – List of detectors to process.
calibrations_path (
str) – The path to the calibration files.std_outfile (str, optional) – Path to the standard star output file. Defaults to None.
bkg_redux (bool, optional) – If True, perform A-B background subtraction. Defaults to False.
find_negative (bool, optional) – If True, search for negative objects. Defaults to False.
show (bool, optional) – If True, display intermediate results. Defaults to False.
- Returns:
final_sky_dict (dict): Dictionary containing the final sky model; keys are each detector.
bkg_redux_final_sky_dict (dict): Dictionary containing the final bkg_redux sky model; keys are each detector.
all_specobjs_objfind (SpecObjs): Collection of all identified spectral objects.
all_silts (list): List of Slits objects, detector by detector
sciImg_dict (dict): Dictionary containing updated sciImg objects with global spectral flexure and scaleimg information.
- Return type:
- pypeit.exposure.process_exposure(spectrograph, fitstbl, par, frames, calib_ID, detectors, calibrations_path, bg_frames=None)[source]
Process all detectors for a given exposure.
Calls
process_one_det()for each detector.This function processes exposure data for a list of detectors by performing the necessary reduction steps and generating science images and background reduced science images.
- Parameters:
spectrograph (
Spectrograph) – Spectrograph objectfitstbl (
PypeItMetaData) – The class holding the metadata for all the frames in this PypeIt run.par (
PypeItPar) – The parameter set for the reduction process, including slitmask and object finding parameters.frames (
list) – A list of frame indices to process.calib_ID (
str) – The calibration group ID.detectors (
list) – A list of detector indices to process.calibrations_path (
str) – The path to the calibration files.bg_frames (
list, optional) – A list of background frame indices. Defaults to None.
- Returns:
- Return type:
- pypeit.exposure.reduce_exposure(spectrograph, fitstbl, par, frames, calib_ID, calibrations_path, bg_frames=None, reuse_calibs=True, run_state=None, std_outfile=None, show=False)[source]
Reduce a set of exposures for a given spectrograph and calibration setup.
This function performs the full reduction process for a set of science frames, including background subtraction, object finding, sky subtraction, and extraction.
- Parameters:
spectrograph (
Spectrograph) – Spectrograph objectfitstbl (
PypeItMetaData) – The class holding the metadata for all the frames in this PypeIt run.par (
PypeItPar) – The parameter set for the reduction process, including slitmask and object finding parameters.frames (
list) – A list of frame indices to process.calib_ID (
str) – The calibration group ID.calibrations_path (
str) – The path to the calibration files.bg_frames (
list, optional) – A list of background frame indices. Defaults to None.reuse_calibs (bool, optional) – Whether to reuse existing calibrations. Defaults to True.
run_state (dict, optional) – Dictionary to track the state of the reduction process. Defaults to None.
std_outfile (str, optional) – Path to the standard star output file. Defaults to None.
show (bool, optional) – Whether to display intermediate results (e.g., using Ginga). Defaults to False.
- Returns:
all_spec2d (dict): Dictionary containing the 2D spectral data for all detectors.
all_specobjs_extract (list): List of extracted spectral objects.
- Return type:
Notes
The function handles background subtraction and finding negative traces if applicable.
Calibrations are performed for each detector, and unsuccessful calibrations are skipped.
Object finding, sky subtraction, and extraction are performed for the specified frames.
Slitmask adjustments are applied if enabled in the parameters.
- pypeit.exposure.save_exposure(spectrograph, fitstbl, par, frame, all_spec2d, all_specobjs, calibrations_path, history=None, in_update_det=None, skip_write_2d=False)[source]
Save the outputs from extraction for a given exposure
- Parameters:
spectrograph (
Spectrograph) – Spectrograph objectfitstbl (
PypeItMetaData) – The class holding the metadata for all the frames in this PypeIt run.par (
PypeItPar) – The parameter set for the reduction process, including slitmask and object finding parameters.frame (
int) – 0-indexed row in the metadata table with the frame that has been reduced.all_spec2d (
AllSpec2DObj) – The 2D reduced spectrum objects.all_specobjs (
SpecObjs) – The 1D spectral extraction objects.calibrations_path (
str) – The path to the calibration files.history (
History, optional) – History entries to be added to fits headerin_update_det (
int, optional) – Detector number to use when writing the output files. If not None, overwrite the value of par[‘rdx’][‘detnum’]skip_write_2d (
bool, optional) – Skip writing the 2D spectrum to disk