Background estimation functions#

Code author: Wilfried Mercier - LAM <wilfried.mercier@lam.fr>

Functions used to determine the the background threshold in an image.

bg_threshold_n_sigma(image, model, mask_bg, n_sigma=2)[source]#

Code author: Wilfried Mercier - LAM <wilfried.mercier@lam.fr>

Given an image with background pixels, measure n times the standard deviation of the background in the residuals.

Parameters:
  • image (NDArray) – image of the galaxy

  • model (NDArray) – 2D model of the galaxy. If image corresponds to the residuals, use model = 0.

  • mask_bg (NDArray) – mask with True for pixels that belong to the background

  • n_sigma (int or float) – number of standard deviations of the background to estimate

Returns:

n times the standard deviation of the background signal in the residuals.

Return type:

float

find_bg_threshold(image, model, mask_bg, surface, positive=True, precision=0.1)[source]#

Code author: Wilfried Mercier - LAM <wilfried.mercier@lam.fr>

Find the lowest background threshold that does not detect substructures in the background pixels of a residual image.

Parameters:
  • image (NDArray) – image of the galaxy

  • model (NDArray) – 2D model of the galaxy. If image corresponds to the residuals, use model = 0.

  • mask_bg (NDArray) – mask with True for pixels that belong to the background

  • surface (int) – minimum surface in pixels that a structure must have in order to be detected

  • positive (bool) –

    whether to find the best threshold for substructures with

    • positive fluxes (positive = True) or

    • negative fluxes (positive = False)

  • precision (float) – precision on the flux threshold used to stop the dichotomy

Returns:

Number of standard deviations in the background regions of the residuals.

Return type:

float