Single-Orient Extraction (Single())

The single-orient extraction refers to extraction of one-dimensional spectra from a collection of WFSS images using a methodology very similar to that of hstaxe, with a few notable exceptions.

  • Each pixel in the direct imaging is dispersed (with its unique trace and wavelength model) and the fractional pixel area is collected (see pypolyclip).

  • This represents a complete forward model, which can be used in optimization strategy (such as fitting SED models with MCMC or greedy algorithm).

  • The contamination model (easily) permits arbitrary complexity for the contaminating source spectra.

Note

The Single-Orient Extraction is only applicable to a simple source, as the (self-)contamination is too severe to be addressed with this algorithm.

Extraction Details

The single-orient extraction is essentially the optimal spectroscopy algorithm presented by Horne 1986, with a few modifications related to details of WFSS data and/or the preprocessing that is expected. The method is

  • For each WFSS image in the WFSS Collection:

    • For each source in the Source Collection:

      1. load the PDTs for each direct imaging pixel in the source

      2. decimate the PDTs over the unique combinations of WFSS pixel and wavelength.

      3. For each unique \(x\)-coordinate:

        • compute average wavelength (weighted by the forward-model profile) for this vertical slice; now \(x\rightarrow \lambda\)

        • divide each \(y\)-pixel in the WFSS image by their flat-field, sensitivity curve, pixel-area map, fluxscale (see the configuration object), and the instantaneous dispersion for this average wavelength

        • compute the Horne 1986 optimal parameters:

        \[\begin{split}\begin{aligned} f_{\lambda,i} &=& \frac{\sum_y P_{x,y}S_{x,y}/U_{x,y}^2}{\sum_y P_{x,y}^2/U_{x,y}^2}\\ u_{\lambda,i} &=& \sqrt{\frac{\sum_y P_{x,y}}{\sum_y P_{x,y}^2/U_{x,y}^2}}\\ c_{\lambda,i} &=& \frac{\sum_y P_{x,y}C_{x,y}/U_{x,y}^2}{\sum_y P_{x,y}^2/U_{x,y}^2} \end{aligned}\end{split}\]

        where \(f_{\lambda,i}\), \(u_{\lambda,i}\), and \(c_{\lambda,i}\) are the optimal flux, uncertainty, and contamination, respectively for the \(i^\mathrm{th}\) WFSS image. Additionally, \(S_{x,y}\), \(U_{x,y}\), \(P_{x,y}\), and \(C_{x,y}\) are the science, uncertainty, cross-dispersion profile, and contamination images (more on this below in Contamination Model), respectively. Slitlessutils offers three choices for the cross-dispersion profile \(P_{x,y}\):

        • uniform This does no profile weighting and instead just sums the pixels within the aperture. This is effectively the box-extraction in hstaxe

        • forward This uses the forward model to establish the cross dispersion weights.

        • data This uses the science image, masked for the DQA as the weights. This is effectively the Horne 1986 algorithm.

        these can be selected by the keyword argument: profile. The default behavior is profile='data'.

        • record these values in a temporary data structure used to combine the spectra from different WFSS images

This produces a single spectrum for each source for each WFSS image, and these spectra are combined in the next section. The two key differences between this and the Horne 1986 algorithm are (1) there is no iterative reassessment of either the profile (\(P_{x,y}\)), the cosmic ray mask, or the pixel variances; and (2) the science image is not smoothed in the dispersion direction.

Important

In the above algorithm, vertical slices in \(x\) are taken as the HST WFSS modes very nearly disperse along the \(x\)-axis (though WFC3/UVIS has significant curvature). However, these summations in the above should be carried out over a fixed wavelength interval, but this is very similar to the method in hstaxe. This assumption will be addressed in future releases.

Contamination Model

The contamination model is initialized by converting the spectral traces for every object into a polygon from the Shapely from the information in the PDTs. If the contamination is requested, then slitlessutils will select all polygons that intersect with the spectral-trace polygon in question. For those that intersect, a simulated image is created (see Simulation for details), however this is only done in a small postage stamp. This simulation is the contamination image \(C_{x,y}\) described in the above section. Therefore, the quality of the contamination model is directly related to the quality of the available broadband photometry. Lastly, this methodology is the same as the fluxcube settings in hstaxe.

Important

The contamination will be computed if-and-only-if the mskorders keyword is set. This can be either a single string for the orders to mask, the string 'all' to mask all orders, or None to mask no orders. The default behavior is mskorders='all'.

Note

The class setting savecont=True to the Single() module will save the two-dimensional contamination models as a multi-extension fits file to disk, where each extension will refer to a different segmentation ID.

Exposure Combination

The results from the Extraction module are combined into a single one-dimensional spectrum for each source.

  • For each source in the Source Collection:

    • bin the wavelengths according to the extraction wavelengths

    • initialize the weights as the inverse of the square of the uncertainties: \(w=1/u^2\).

    • Compute the number of non-zero weights for each wavelength \(n_{\lambda}\), and the weighted moments of the photometric data:

    \[\begin{split}f_{\lambda} &=& \frac{\sum_i f_{\lambda,i}\,w_{\lambda,i}}{\sum_i w_{\lambda,i}}\\ u_{\lambda} &=& \frac{1}{\sqrt{\sum_i w_{\lambda,i}}}\\ c_{\lambda} &=& \frac{\sum_i c_{\lambda,i}\,w_{\lambda,i}}{\sum_i w_{\lambda,i}}\end{split}\]

    where \(f_{\lambda}\), \(u_{\lambda}\), and \(c_{\lambda}\) are the averaged spectrum, uncertainty, and contamination model that slitlessutils reports for this source

    • Output the table of \(\lambda\), \(f_{\lambda}\), \(u_{\lambda}\), and \(c_{\lambda}\), and \(n_{\lambda}\) into an output fits file, whose suffix will be x1d.fits.

Important

The extraction wavelengths are specified for each source, but can be globally set for each of them in the Source Collections.

Example

See slitlessutils.examples.starfield for a working example.