Skip to main content
January 27, 2015

About This Article

Relevant PR Details

PR #79304  CALCOS should implement two-zone extraction

CALCOS was upgraded to Version 3.0 to support the move of the COS FUV channel to Lifetime Position 3.  This move involves changing the aperture block position so that the spectrum will be located approximately x pixels (y arcsec) below its location during Lifetime Position 1. As a result of this move, some of the gain sagged regions from LP1 will be close to the edge of the extraction aperture at LP3.

CALCOS Version 3.0 addresses this by splitting the extraction region into two parts: the inner region, where most of the flux is, will be where DQ flags are propagated to the output extracted spectrum. The outer region, containing a much smaller fraction of the flux, will contribute to the total flux measurement, but its DQ flags will be ignored. This 'two zone' extraction algorithm involves several significant changes to CALCOS. Most of the significant changes are confined to and the new module,  The former now has two extractSegment methods: extractSegmentBoxcar and extractSegmentTwozone, with all of the new extraction algorithms in the latter function.

The new module includes code to perform two new calibration steps: trace correction (trcecorr) and profile alignment (algncorr). In the trace correction step, the 1-d profile of the centroid of the spectrum is corrected for its up-and-down wiggles to make a horizontal spectrum. In the profile alignment step, the centroid of this spectrum in the cross dispersion direction is measured and compared to the centroid of a high signal to noise template, and shifted to make the science data spectrum and reference profile have the same centroid.  This ensures that the (narrower) extraction regions are still centered on the spectrum. 

Modules changed:


Version and author(s) changed


New module to ensure that the regions around airglow lines are not included in the profile alignment centroid calculations.


Added sp_err_X to list of segment-specific keywords. Added MissingColumnError exception.


Added code to deal with 3 new reference file types: TRACETAB, PROFTAB and TWOZXTAB.


New calling sequence for extract.extractCorrtag


Major changes.  extractSegment() is now split into extractSegmentBoxcar() and extractSegmentTwozone(). Calling sequence to extractSegmentBoxcar is different from extractSegment because of the new columns added to the x1d file.  extractSegmentTwoZone contains the code to do the two-zone extraction, and uses the following new functions:

  • getProfileCentroid()
  • getBackgroundCenters()
  • getBackgroundRegion()
  • getBackground()
  • getPercentiles()
  • NormalizeProfile()
  • getPercentileVectors()
  • bitwise_or_vector()
  • next_power_of_two()
  • remove_unwanted_columns()


Remove added columns from x1dsum files.


Added new correction steps (trcecorr, algncorr) and reference files (tracetab, proftab, twozxtab) to getSwitchValues() and getRefFileNames()


Added three new functions to do trace correction and profile alignment:

  • createTraceMask()
  • doTraceCorr()
  • doProfileAlignmentCorr()


New module that holds all the code for trace correction and alignment correction.  Includes functions

  • def doTrace()
  • def getTrace()
  • def cleanTrace()
  • def applyTrace()
  • def doProfileAlignment()
  • def rebinData()
  • def rebinCounts()
  • def maskAirglowLines()
  • def applyWavelengthLimits()
  • def getWavelengthLimits()
  • def getGoodRows()
  • def getRegions()
  • def getGoodColumns()
  • def getScienceCentroid()
  • def getBackground()
  • def getCentroid()
  • def getCentroidError()
  • def calculateCentroidError()
  • def getReferenceBackground()
  • def getReferenceCentroid()
  • def applyOffset()
  • def updateTraceKeywords()


HST Help Desk 

Please contact the HST Help Desk with any questions.