KernelBackgroundEstimator

class gammapy.detect.KernelBackgroundEstimator(kernel_src, kernel_bkg, significance_threshold=5, mask_dilation_radius=<Quantity 0.02 deg>, delete_intermediate_results=False, save_intermediate_results=False, base_dir='temp')[source]

Bases: object

Estimate background and exclusion mask iteratively.

Starting from an initial background estimate and exclusion mask (both provided, optionally) the algorithm works as follows:

  1. Compute significance image
  2. Create exclusion mask by thresholding significance image
  3. Compute improved background estimate based on new exclusion mask

The steps are executed repeatedly until the exclusion mask does not change anymore.

For flexibility the algorithm takes arbitrary source and background kernels.

Parameters:

kernel_src : numpy.ndarray

Source kernel as a numpy array.

kernel_bkg : numpy.ndarray

Background convolution kernel as a numpy array.

significance_threshold : float

Significance threshold above which regions are excluded.

mask_dilation_radius : Quantity

Radius by which mask is dilated with each iteration.

delete_intermediate_results : bool

Specify whether results of intermediate iterations should be deleted. (Otherwise, these are held in memory). Default True.

save_intermediate_results : bool

Specify whether to save intermediate results as FITS files to disk. Default False.

base_dir : str (optional)

Base of filenames if save_intermediate_results = True. Default ‘temp’.

Methods Summary

images_stack_show([dpi]) Show image stack.
run(images[, niter_min, niter_max]) Run iterations until mask does not change (stopping condition).

Methods Documentation

images_stack_show(dpi=120)[source]

Show image stack.

Parameters:

dpi : int

Dots per inch to scale the image.

run(images, niter_min=2, niter_max=10)[source]

Run iterations until mask does not change (stopping condition).

Parameters:

images : SkyImageList

Input sky images.

niter_min : int

Minimum number of iterations, to prevent early termination of the algorithm.

niter_max : int

Maximum number of iterations after which the algorithm is terminated, if the termination condition (no change of mask between iterations) is not already satisfied.

Returns:

images : SkyImageList

List of sky images containing ‘background’, ‘exclusion’ mask and ‘significance’ images.