3.5 Manual Recalibration of WFC3 Data

3.5.1 Requirements for Manual Recalibration

Retrieving Software and Input Data Files

Data retrieved from MAST (Barbara A. Mikulski Archive for Space Telescopes), via the Portal or the search form, will have been processed with the most up-to-date calibration reference files and software. Nevertheless, some users may wish to reprocess existing WFC3 observations with e.g. alternative reference files.  To do so, the following must be available on their system:

  • Software for data processing (distributed in the Astroconda package)
  • Reference files may be obtained from CRDS, as described in Section 3.1.4.
  • Uncalibrated (raw) data files from MAST
  • Any association tables that describe observation sets.

Setting the Path to Reference Files

Before any recalibration can be done, the user must define a local directory containing the calibration reference files. For WFC3, this directory is referred to as ‘iref’. The raw image headers already contain the appropriate keywords that list the reference file names that were assigned during STScI pipeline processing. The user must simply define the location of the ‘iref’ directory in their Unix environment:

setenv iref /mydisk/myiref/

If executed from the command line, this setup must be done in the same window in which python will be started. (Setting ‘iref’ from within python will not work, even though subsequently typing ‘show iref’ would suggest it might.) For convenience, this setup command can be added to the '.setenv' file, so that the 'iref' environment variable will always be defined. The ‘iref’ environment variable is required whether reprocessing through python or from the OS command line.

An alternate method of accessing WFC3 reference files is shown in a new python tutorial in Section 3.5.2. In this example, the best WFC3 reference files for a given set of input images are retrieved directly from CRDS and placed in a local 'crds_cache/' directory.  The notebook shows how to update the header keywords to point to these new reference files and sets the 'iref' environment variable for subsequent calwf3 processing.

Selecting Calibration Switches

The MAST HST Data Processing uses the most up-to-date calibration reference files by default. In order to use non-default reference files, manual recalibration is required and in this case, the calibration reference file keywords will need to be updated manually in the raw data files with the desired file names before running calwf3. In addition, the user can choose to change which calibration steps are performed by calwf3 by resetting the values of the calibration switch keywords. These keywords are listed in Table 3.7 along with their default values as used in the STScI pipeline. To change the values of any of the keyword switches, a FITS keyword editor such as the python package astropy.io.fits may be used.

from astropy.io import fits
fits.setval(‘myfile_raw.fits’, keyword= ‘DARKCORR’, value= ‘OMIT’, ext=0)

Table 3.7: Calibration switch and default settings.



Perform CTE correction (UVIS)

DEFAULT = ‘PERFORM’ (cte-corrected) else 'OMIT'(non-cte-corrected)


Data Quality Array Initialization



Analog-to-Digital Correction



Zero-read Signal Correction (IR)



CCD Overscan Region Subtraction (UVIS)

Reference Pixel Bias Correction (IR)



Bias Image Subtraction (UVIS)



Post-flash Image Subtraction (UVIS)

If FLASHLVL > 0 then ‘PERFORM’ else ‘OMIT’


UVIS Cosmic Ray Rejection:

If CRSPLIT or NRPTEXP > 1 then 'PERFORM’, else ‘OMIT’

IR Cosmic Ray Rejection:

DEFAULT = ‘PERFORM’  (else 'OMIT' for scan observations)


Zero-read Image Subtraction (IR)



Non-linearity Correction (IR)



Dark Image Subtraction



Flat-Field Correction



Shutter Shading Correction (UVIS)



Units Conversion (IR)



Photometric Processing



Photometric normalization of the two UVIS chips



Repeat-Obs Processing (IR)

If NRPTEXP > 1 then ‘PERFORM’, else ‘OMIT’


Full calibration of individual exposures in an association



Drizzle Processing


3.5.2 calwf3 Examples   

Documentation for the calwf3 software is provided at readthedocs, with version history available on the STScI github repository or readthedocs software history. Users may reprocess either a single RAW image, an image association, or a list of raw files:

A single RAW exposure       

from wfc3tools import calwf3

An image association (ASN)


A list of RAW files (not part of an ASN)

import glob
for raws in glob.glob('ibohbf*_raw.fits'):

A new WFC3 notebook tutorial provides calwf3 reprocessing examples to improve calibrated WFC3/IR images affected by time-variable background. The notebook shows how to diagnose images with poor-quality ramp fits and rerun calwf3 with the 'CRCORR' step turned off.

Time-variable background is described in Section 7.10 and is likely caused by Helium I emission in the Earth's atmosphere at 1.083 microns (WFC3 ISR 2014-03). For the imaging filters F105W and F110W, this produces a flat excess signal which is added to the total background for a subset of reads. When strong enough, this non-linear signal may compromise the ramp fitting performed by calwf3, which is designed to flag and remove cosmic rays and saturated reads. The affected calibrated FLT data products will have much larger noise and a distinctly non-gaussian background.

In this tutorial, the images are reprocessed using the 'Last-minus-first' technique described in WFC3 ISR 2016-16. This turns off calwf3's ramp fitting step (CRCORR) and treats the IR detector like a CCD that accumulates charge and is read out only at the end of the exposure. In this case, the observed count rate is determined by simply subtracting the first from the last read of the detector and dividing by the time elapsed between the two reads.

Note: while time-variable background also impacts the IR grisms, the methods used for imaging data should not be used to correct G102 and G141 observations, which are affected by a combination of zodiacal background, helium line emission, and scattered Earth light, each of which vary spatially across the detector. More detail on background corrections for grism data is provided in WFC3 ISR 2020-04.