subtract_background

The subtract_background utility fits, models and removes the background scattered light within an image.

Here’s the workflow for subtracting a frame’s background:

Fig. 76 The algorithm fits, models, and subtracts the scattered background light from an image.

Fig. 77 shows an example frame with background scattered light present. The first task of the utility is to use the order location table to mask pixels within the echelle orders and the locations of bad pixels (see Fig. 78).

image-20240920135732439

Fig. 77 An example NIR lamp flat frame containing scattered background light.

image-20240920140302799

Fig. 78 The NIR lamp flat now with inter-order and bad pixels masked.

For each column in the masked frame, a bspline is fitted to the unmasked fluxes to model the shape of the scattered background light along the entire column length (including the masked regions). See Fig. 79.

image-20240920140729800

Fig. 79 The red points are the unmasked data located along a single column in the masked frame. The blue line is the bspline fitted to the data, providing a model for the scattered background light contaminating the inter-order regions. The frame in this instance is a master flat frame.

A Gaussian filter is applied to the image to remove the structure resulting from bad row fits, and finally, the modelled background image is subtracted from the original frame.

image-20240920135302518

Fig. 80 The final image of the model background scattered light, which is then subtracted from the original data frame. The frame in this instance is a master flat frame.

Utility API

:::{autodoc2-object} soxspipe.commonutils.subtract_background.subtract_background
:::