Spitzer Documentation & Tools
IRS Instrument Handbook

## 5.5  Description of Modules in the 2-Dimensional Coadder Pipeline

This pipeline consists of only one module, COADD2D, and is considered an ensemble pipeline, because multiple input bcd.fits files are combined. The pipeline selects all BCDs of the same exposure (EXPID) within an AORKEY, to form the list of files to be combined.

The module COADD2D (“2-Dimensional Coadder”) computes the asymmetric trim mean of several input files bcd.fits, whose names are listed in the text file inputlist-coadd. Other inputs to the module are the corresponding uncertainty files func.fits and BCD masks bmask.fits, respectively listed in the text files inputlist_unc_coadd, and inputlist_bmask_coadd.

The “asymmetric trim mean” algorithm is carried out for each pixel, independently of other pixels. Asymmetric trimming consists of successively discarding pixel values at the upper or lower extremes of the set that will be averaged. The algorithm details are as follows:

Denote by pixi (i=1...N) the set of N pixels to be trim-averaged, where N is the number of BCDs being co-added. The asymmetric trim fraction parameter fasym, also denoted as “Cut-off Fraction” (with default value 0.2) determines the maximum number Nasym of pixel values pixi that are discarded at the extremes of the set: Nasym  = Npix fasym.  That is, using the default for fasym up to 20% of pixel values may be discarded. The iterative process for discarding extreme pixi consists of four steps:

1. Compute median(pix) of the set pixi, where

2. Determine which of the two extreme values (the highest or the lowest) of the set pixi deviates more from median(pix); denote it as Pext, and its absolute deviation from median(pix) as Dext.

3. Excluding Pext, compute the median absolute deviation Dmed of the set pixi from median(pix).

4. If Dext <mcut Dmed,  where the parameter mcut also known as “Cut-off Multiple,” has a default value of 5.0, then terminate the iteration and compute the mean of the remaining set pixi. Otherwise, discard Pext from the set pixi; if fewer than Nasym pixels have been discarded through these iterations, go back to step 1 and continue. Else, if Nasym pixels have been discarded from the set, terminate the iteration and compute the mean of the remaining set.

In the main output of the module, coa2d.fits, pixels are set to NaN whenever there are no non-NaN values in the trimmed set pixi. Equivalently, output NaN values result whenever all pixels in the trimmed set are fatally masked in their respective bmask.fits or pmask.fits files. The inter-order regions are NaN in coa2d.fits.

The output uncertainties in c2unc.fits are the sum in quadrature of the input uncertainties in func.fits for the trimmed set, divided by the number of pixels in the trimmed set. Weights are not used in this procedure.

The output mask file c2msk.fits has bits # 12 and 13 set whenever there are no values in the trimmed set pixi that are not NaN. Bit # 7 is set for pixels tagged in the input bmask.fits as “questionable flatfield applied.”