stis_cti Modules


stis_cti.stis_cti(science_dir, dark_dir, ref_dir, num_processes, pctetab=None, all_weeks_flag=False, allow=False, clean=False, clean_all=False, crds_update=False, verbose=1)

Runs the HST/STIS/CCD pixel-based CTI-correction on science data and component darks, generating and applying a CTI-corrected super-dark in the process.

Documentation is available at

  • science_dir (str) – Directory containing uncalibrated science data to be corrected.
  • dark_dir (str) – str Directory containing calibrated component darks to be corrected and location where CTI-corrected component darks are placed.
  • ref_dir (str) – str Directory where CTI-corrected super-darks are placed. These will be used again unless they are deleted or clean_all=True.
  • num_processes (int) – Max number of parallel processes to use when running the CTI-correction algorithm.
  • pctetab (str, optional) – The path + name of the PCTETAB reference file to use in the CTI-correction. If not specified, one is selected from (1) the ref_dir, or (2) from the package data directory. The last file (alphabetically) is chosen.
  • all_weeks_flag (bool, optional) – UNTESTED. Generates weekdarks for all weeks within each annealing period to be processed.
  • allow (bool, optional) – UNTESTED. Use more lenient filtering when determining which files should be allowed to be corrected.
  • clean (bool, optional) – Remove intermediate and final products in the science_dir from previous runs of this script.
  • clean_all (bool, optional) – ‘clean’ + remove CTI-corrected super-darks and component darks before reprocessing.
  • crds_update (bool, optional) – Runs crds.bestrefs script to update science file headers and download pipeline reference files.
  • verbose (int {0,1,2}, optional, default=1) – Verbosity of text printed to the screen and saved in the log file.


Unless crds_update is True, the $oref shell variable must be set to the directory of STIS standard pipeline reference files.


Note that the ‘all_week_flag’ and ‘allow’ options have not been tested!


stis_cti.archive_dark_query(files, anneal_data=None, min_exptime=None, verbose=False, print_url=True)

Queries the MAST archive to determine which component darks are needed to generate a CTI-corrected super-dark.


stis_cti.viable_ccd_file(file, earliest_date_allowed=None, amplifiers_allowed=None, gains_allowed=None, offsts_allowed=None)
  • earliest_date_allowed (datetime.datetime object (default=2009-May-01 00:00:00 UTC)) – Beginning datetime allowed.
  • amplifiers_allowed (list of strings (default=['D'])) – CCDAMP values allowed.
  • gains_allowed (list of ints (default=[1,4])) – CCDGAIN values allowed.
  • offsts_allowed (list of ints (default=[3])) – CCDOFFST values allowed

bool – Run stis_cti.stis_cti() on the file?



Prints informative text on manually applying the CTI-correction and creating custom super-darks.


Runs the perturbative part of the correction on a bias-corrected data file.


Functions to apply pixel-based CTE correction to STIS images.

The algorithm implemented in this code was described in detail by [Anderson] as available online at:


  • This code only works for STIS/CCD but can be modified to work on other detectors.
  • It was developed for use with full-frame GAIN={1,4} FLT images as input.
  • It has not been fully tested with any other formats.
  • Noise is slightly enhanced in the output (see [Anderson]).
  • This code assumes a linear time dependence for a given set of coefficients.
  • This algorithm does not account for traps with very long release timescale but it is not an issue.
  • This code also does not account for second-exposure effect.
  • Multi-threading support was not implemented in this version.
Optional preprocessing for nonstandard FLT input:

If you are not using a fully calibrated FLT image as input, you might also need to do one or more of the following before running the task:

  • Convert image to unit of electrons.

  • For combined image (e.g., superdark), set noise_model to 0.

  • Primary FITS header (EXT 0) must have these keywords populated:
    • INSTRUME (must be STIS)
    • DETECTOR (must be CCD)
    • NEXTEND (number of extensions = 3 * number of image sets)
    • CCDAMP (ABCD, AD, BC, A, B, C, or D)
  • SCI FITS header must have these keywords populated:
    • EXTNAME (must be SCI)
    • EXTVER (1 or greater)
  • ERR FITS header must have these keywords populated:
    • EXTNAME (must be ERR)
    • EXTVER (1 or greater)
  • DQ FITS header must have these keywords populated:
    • EXTNAME (must be DQ)
    • EXTVER (1 or greater)

To correct a set of STIS FLT images, with one new CTE-corrected image for each input.

>>> from stistools import StisPixCteCorr
>>> StisPixCteCorr.CteCorr('o*q_flt.fits')
[Anderson](1, 2) Anderson J. & Bedin, L.R., 2010, PASP, 122, 1035