romanimpreprocess.L1_to_L2.gen_cal_image
Main tools to drive exposure level processing.
Functions
- wcs_from_config
Extracts a WCS from the configuration file.
- initializationstep
Creates and initializes L2 data.
- saturation_check
Flags saturated pixels in a 3D cube.
- subtract_dark_current
Subtracts dark current in a 3D cube.
- repackage_wcs
Packages a WCS so that it can be handed to romanisim.
- calibrateimage
L1->L2 driver.
Attributes
Functions
|
Gets a WCS object from the configuration. |
|
Initialization step. |
|
Flags saturated pixels (in both 3D and 2D arrays). |
|
Subtracts dark current from a rate image. |
|
Packages a WCS to feed to romanisim. |
|
Subtracts the dark decay signal from a resultant cube. |
|
Corrects the WFI18 first-read transient. |
|
Embeds the active region into a full region that includes border pixels. |
|
Fit a slope to a ramp model, returning a 2D rate ImageModel. |
|
Main routine to run the specified calibrations from a config file. |
Module Contents
- wcs_from_config(config)[source]
Gets a WCS object from the configuration.
Currently supports FITS headers imported from a simulation.
- Parameters:
config (dict) – Configuration dictionary (usually imported from YAML).
- Returns:
The WCS as a FITS header.
- Return type:
astropy.io.fits.header.Header
- initializationstep(config, caldir, mylog)[source]
Initialization step.
- Parameters:
config (dict) – Configuration dictionary (usually imported from YAML).
caldir (dict) – Locations of calibration files.
mylog (romanimpreprocess.utils.processlog.ProcessLog) – Processing log.
- Returns:
ramp_model (RampModel) – ramp data model including data, groupdq, pixeldq, metadata
meta (dict) – Other metadata (right now: frame_time and read_pattern)
- saturation_check(ramp_model, caldir, mylog, backup=1, skip_firstn=1)[source]
Flags saturated pixels (in both 3D and 2D arrays).
Performs a saturation check on the data cube (data) using the calibration files in caldir. Information is appended to mylog. The flags rdq and pdq are updated in place.
This function serves as a wrapper for
flag_saturation(imported fromromancal).- Parameters:
ramp_model (roman_datamodels.datamodels.RampModel) – data model including resultant cube
caldir (dict) – Locations of calibration files.
mylog (romanimpreprocess.utils.processlog.ProcessLog) – Processing log.
backup (int) – Number of resultants to “back up” when flagging saturation.
skip_firstn (int) – Do not check the first n resultants in ramp_model.data for saturation.
- subtract_dark_current(image_model, caldir, mylog)[source]
Subtracts dark current from a rate image.
image_model is updated in place.
romancal expects to subtract from an active-region image only (4088x4088) rather than a full-frame 4096x4096 image, so there are some gymnastics to handle that difference.
dark subtraction occurs after IPC deconvolution, but the dark reference file is IPC-convolved, so this routine also corrects the dark reference file for IPC.
- Parameters:
image_model (roman_datamodels.datamodels.ImageModel) – 2D Roman image model (DN / s), full 4096x4096 frame.
caldir (dict) – Locations of calibration files.
mylog (romanimpreprocess.utils.processlog.ProcessLog) – Processing log.
- repackage_wcs(thewcs)[source]
Packages a WCS to feed to romanisim.
Right now supports FITS-standard headers from a simulation. Since this for compatibility in ramp-fitting routines, can use this and overwrite the WCS in the L2 ASDF tree with a full-accuracy gwcs at a later stage.
- Parameters:
thewcs (astropy.io.fits.Header or galsim.CelestialWCS) – Input WCS.
- Returns:
Packaged WCS, 2 layers deep for compatibility with romanisim.
- Return type:
class
- correct_dark_decay(ramp_model, caldir, mylog)[source]
Subtracts the dark decay signal from a resultant cube.
ramp_model is updated in place.
- Parameters:
ramp_model (roman_datamodels.datamodels.RampModel) – data model including resultant cube
caldir (dict) – Locations of calibration files.
mylog (romanimpreprocess.utils.processlog.ProcessLog) – Processing log.
- correct_wfi18_transient(ramp_model, config, mylog)[source]
Corrects the WFI18 first-read transient.
Only applies to detector WFI18; for any other detector the model is returned unchanged. The ramp_model is updated in place.
- Parameters:
ramp_model (roman_datamodels.datamodels.RampModel) – data model including resultant cube
config (dict) – Configuration dictionary. If
config["wfi18_mask_rows"]is True, mask the most affected rows instead of fitting and removing the anomaly.mylog (romanimpreprocess.utils.processlog.ProcessLog) – Processing log.
- _embed_active(active, nb=4)[source]
Embeds the active region into a full region that includes border pixels.
- Parameters:
active (np.array) – 2D array covering the active 4088x4088 pixels only
nb (int) – Number of reference-pixel border rows/columns, usually 4.
- Returns:
Full-frame array with the border zeroed and the active region filled. Returned as float32.
- Return type:
np.array
- do_ramp_fit(ramp_model, meta, config, caldir, mylog)[source]
Fit a slope to a ramp model, returning a 2D rate ImageModel.
If config[“romancal_ramp_fit”] is True, use the likelihood-based ramp fitting approach taken in romancal; otherwise, use the specialized ramp fitting approach from fitting.ramp_fit.
romancal expects to return 4088x4088 images (trimming the border pixels), but this pipeline expects 4096x4096 full frame images. We work around that by reembedding the active region in the larger frame. These pixels get trimmed off anyway in the final image.
- Parameters:
ramp_model (roman_datamodels.datamodels.RampModel) – Ramp data model holding the linearized cube, flags, and the border-reference fields.
meta (dict) – Metadata dictionary.
meta["K"](ramp weights) andmeta["ramp_opt_pars"]are set here for downstream bookkeeping.config (dict) – Configuration dictionary.
caldir (dict) – Locations of calibration files.
mylog (romanimpreprocess.utils.processlog.ProcessLog) – Processing log.
- Returns:
2D rate image (DN/s), full 4096x4096 frame.
- Return type:
roman_datamodels.datamodels.ImageModel