instrument_monitors

pipeline_tools.py

Various utility functions related to the JWST calibration pipeline

Authors

  • Bryan Hilbert

Use

This module can be imported as such:

from jwql.instrument_monitors import pipeline_tools
pipeline_steps = pipeline_tools.completed_pipeline_steps(filename)
jwql.instrument_monitors.pipeline_tools.aperture_size_check(mast_dicts, instrument_name, aperture_name)[source]

Check that the aperture size in a science file is consistent with what is listed in the SUBARRAY header keyword. The motivation for this check comes from NIRCam ASIC Tuning data, where file apertures are listed as FULL, but the data are in fact SUBSTRIPE256. Note that at the moment this function will only work for a subset of apertures, because the mapping of SUBARRAY header keyword value to pysiaf-recognized aperture name is not always straightforward. Initially, this function is being built only to support checking files listed as full frame.

Parameters:
mast_dictslist

List of file metadata dictionaries, as returned from a MAST query

instrument_namestr

JWST instrument name

aperture_namestr

Name of the aperture, in order to load the proper SIAF information

Returns:
consistent_fileslist

List of metadata dictionaries where the array size in the metadata matches that retrieved from SIAF

jwql.instrument_monitors.pipeline_tools.calwebb_detector1_save_jump(input_file, output_dir, ramp_fit=True, save_fitopt=True)[source]

Call calwebb_detector1 on the provided file, running all steps up to the ramp_fit step, and save the result. Optionally run the ramp_fit step and save the resulting slope file as well.

Parameters:
input_filestr

Name of fits file to run on the pipeline

output_dirstr

Directory into which the pipeline outputs are saved

ramp_fitbool

If False, the ramp_fit step is not run. The output file will be a *_jump.fits file. If True, the *jump.fits file will be produced and saved. In addition, the ramp_fit step will be run and a *rate.fits or *_rateints.fits file will be saved. (rateints if the input file has >1 integration)

save_fitoptbool

If True, the file of optional outputs from the ramp fitting step of the pipeline is saved.

Returns:
jump_outputstr

Name of the saved file containing the output prior to the ramp_fit step.

pipe_outputstr

Name of the saved file containing the output after ramp-fitting is performed (if requested). Otherwise None.

jwql.instrument_monitors.pipeline_tools.completed_pipeline_steps(filename)[source]

Return a list of the completed pipeline steps for a given file.

Parameters:
filenamestr

File to examine

Returns:
completedcollections.OrderedDict

Dictionary with boolean entry for each pipeline step, indicating which pipeline steps have been run on filename

jwql.instrument_monitors.pipeline_tools.get_pipeline_steps(instrument)[source]

Get the names and order of the calwebb_detector1 pipeline steps for a given instrument. Use values that match up with the values in the PIPE_STEP defintion in definitions.py

Parameters:
instrumentstr

Name of JWST instrument

Returns:
stepscollections.OrderedDict

Dictionary of step names

jwql.instrument_monitors.pipeline_tools.image_stack(file_list)[source]

Given a list of fits files containing 2D images, read in all data and place into a 3D stack

Parameters:
file_listlist

List of fits file names

Returns:
cubenumpy.ndarray

3D stack of the 2D images

jwql.instrument_monitors.pipeline_tools.run_calwebb_detector1_steps(input_file, steps)[source]

Run the steps of calwebb_detector1 specified in the steps dictionary on the input file

Parameters:
input_filestr

File on which to run the pipeline steps

stepscollections.OrderedDict

Keys are the individual pipeline steps (as seen in the PIPE_KEYWORDS values above). Boolean values indicate whether a step should be run or not. Steps are run in the official calwebb_detector1 order.

jwql.instrument_monitors.pipeline_tools.steps_to_run(all_steps, finished_steps)[source]

Given a list of pipeline steps that need to be completed as well as a list of steps that have already been completed, return a list of steps remaining to be done.

Parameters:
all_stepscollections.OrderedDict

A dictionary of all steps that need to be completed

finished_stepscollections.OrderedDict

A dictionary with keys equal to the pipeline steps and boolean values indicating whether a particular step has been completed or not (i.e. output from completed_pipeline_steps)

Returns:
steps_to_runcollections.OrderedDict

A dictionaru with keys equal to the pipeline steps and boolean values indicating whether a particular step has yet to be run.