subtract_background

The purpose of the subtract_background utility is to model the topology of the scattered background light within an image and then remove it.

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

Here’s an example frame requiring the background scattered light to be fitted and removed:

Having unpacked the order location table, a mask is created containing pixels lying within the order-locations. The mask is extended in either direction along the y-axis by a given fraction (recipe parameter) of its original length to make sure all inner-order flux is masked.

The bad-pixel mask is merged with this inner-order mask. For each row in the masked frame, a bspline is fitted to the unmasked pixel fluxes to model the shape of the scattered background light along the row.

For each row, flux-values are generated for all pixels in the row using the bspline fit and added to a first pass model background image.

It’s essential that background fitting is accurate within the order locations, but not outside of these areas, so there is no cause for concern if the fit is poor at the edges and corners of the image.

A median-filter is applied to the image to remove the structure resulting from a bad row fits (light and dark lines along the x-axis).

Finally, the modelled background image is subtracted from the original frame: