galmex.Background_module module

class galmex.Background_module.BackgroundEstimator(galaxy_name, image)[source]

Bases: object

Class to estimate the background of an astronomical image.

flat_background(value, std)[source]

Apply a flat background model with constant value.

Parameters:
  • value (float) – Background value.

  • std (float) – Background standard deviation.

Returns:

  • value (float) – Background median value.

  • std (float) – Background standard deviation.

  • bkg_image (ndarray) – Flat background image.

  • galaxy_nobkg (ndarray) – Background-subtracted image.

frame_background(image_fraction=0.1, sigma_clipping=True, clipping_threshold=3)[source]

Estimate background using image borders and optional sigma clipping.

Parameters:
  • image_fraction (float) – Fraction of image edges to consider.

  • sigma_clipping (bool) – Apply iterative sigma clipping to remove outliers.

  • clipping_threshold (float) – Clipping threshold in standard deviations.

Returns:

  • bkg_median (float) – Estimated background median.

  • bkg_std (float) – Estimated background standard deviation.

  • bkg_image (ndarray) – Simulated noise background image.

  • galaxy_nobkg (ndarray) – Background-subtracted image.

load_background(bkg_file=None, bkg_image_path='./', bkg_image_prefix='', bkg_image_sufix='', bkg_image_HDU=0)[source]

Load a pre-computed background FITS file.

Parameters:
  • bkg_file (str or None) – Specific FITS filename or inferred from galaxy_name.

  • bkg_image_path (str) – Directory containing the file.

  • bkg_image_prefix (str) – Prefix for the file.

  • bkg_image_sufix (str) – Suffix for the file.

  • bkg_image_HDU (int) – HDU index from which to read the image.

Returns:

  • bkg_median (float) – Background median value.

  • bkg_std (float) – Background standard deviation.

  • bkg_image (ndarray) – Background image array.

  • galaxy_nobkg (ndarray) – Background-subtracted image.

Raises:
  • FileNotFoundError – If the specified file does not exist.

  • ValueError – If image dimensions do not match.

sep_background(bw=32, bh=32, fw=3, fh=3, **kwargs)[source]

Estimate background using SEP’s global 2D model.

Parameters:
  • bw (int) – Background mesh block sizes.

  • bh (int) – Background mesh block sizes.

  • fw (int) – Filter window sizes.

  • fh (int) – Filter window sizes.

  • **kwargs (dict) – Additional arguments passed to sep.Background.

Returns:

  • globalback (float) – Global background level.

  • globalrms (float) – Global background RMS.

  • bkg_image (ndarray) – 2D background model.

  • galaxy_nobkg (ndarray) – Background-subtracted image.