The algorithms for CALWEBB_SPEC3, the 3rd stage of the JWST calibration pipeline for imaging data, are described. These algorithms process the data from calibrated slope images to combined spectral data (2D or 3D) and extracted spectra.
The CALWEBB_SPEC3 module is the 3rd stage in the calibration pipeline for spectroscopic data. The inputs to this stage are the calibrated slope images (CALWEBB_SPEC2 output) and the output is combined 2D images/3D spectral cubes and extracted spectra.The steps are listed in Figure 1 with the flow from the top to the bottom.
Unless otherwise stated, the algorithms described are the baseline version.
Master background subtraction
The background can be improved over the CALWEBB_SPEC2 step under the assumption that the background does not change across the field of view. With this assumption, a high signal-to-noise spectrum of the background can be measured by averaging over the spatial dimension(s). Then the master background spectrum can be used to create the equivalent 2D background image for subtraction from the target exposures. This step would be done instead of the CALWEBB_SPEC2 background subtraction step. When to do master background subtraction versus background subtraction is still to-be-decided. Hence this step is an optimal pipeline step.
A 2nd pass at outlier detection is done using the overlapping regions observed in different exposures. The majority of the outliers will be due to cosmic rays undetected during the 1st pass at outlier detection done in CALWEBB_DETECTOR1. The presence of an outlier results in a pixel flag being set.
Combinations of dithered spectral observations are done in 2D and 3D as appropriate. 2D images (spectral versus spatial) are created for NIRSpec Fixed Slit/MIRI LRS nodded observations, NIRSpec MSA data taken with shutters above/below, and NIRISS/NIRCam WFSS dithered observations. 3D images (spectral versus ra/dec) are created for NIRSpec and MIRI IFU and MIRI LRS observations taken with cross-slit steps. The combination is done in a single step/interpolation to avoid propagating noise through multiple interpolations.
Note that moving targets are supported and the cubes are created in the moving target reference frame.
Create exposure level products
The exposure level products are re-created at this stage to provide the highest quality products that include the results of the ensemble processing (updated WCS, matching backgrounds, a 2nd pass outlier detection). These products are for the archive and include the rectified 2D (spatial versus spectral, all except IFUs) or 3D (spectral cubes, IFUs) products
For point sources, the extraction is done using a boxcar (2D data) or circular aperture (3D data) with local background subtraction measured from apertures outside the extraction aperture.
For extended sources, the extraction is done with rectangular apertures with no local background subtraction.
The extraction of spectra is done from the rectified observations for the baseline pipeline. An optimal version of spectral extraction that extracts directly from the unrectified data is under investigation.
The background levels in observations can vary as a function of time due to the thermal telescope emission, zodiacal emission, etc. This step corrects the overall level of each spectral cube so that the overlapping regions between exposures have the same background. This step is only done for MIRI IFU observations.
Residual fringe correction
The correction for fringes in CALWEBB_SPEC2 uses a static calibration reference file. The fringes change slightly between observations due to the exact placement of the source in the IFU slices. A residual fringe correction is made by fitting the residual fringes in each spatial pixel using a model that is constrained to only have certain spatial frequencies. This step is only done for MIRI IFU observations.
Spectral leak subtraction
The MIRI IFU observations have a spectral leak in channel 3A at 12.2 μm due to 2nd order light at 6.1 μm with a throughput of ~2%. If observations exist for band 1B, an appropriately scaled 1B extracted spectrum is subtracted from the extracted 3A spectrum.