Module: background_estimation

This modules provides the implementation of the Task class DoSetBkgThreshTask used to estimate the background level in images. The Task algorithm is implemented by the func set_thresh()

Classes and Inheritance Structure

Inheritance diagram of DoSetBkgThreshTask

Summary

set_thresh(image[, skewness_range, ...]) Function to estimate the backgorund threshold in a given image.
DoSetBkgThreshTask([name, func, parser])

Methods

Module API

class DoSetBkgThreshTask(name='bkg_treshold', func=<function set_thresh>, parser=None)[source]

Bases: asterism.pipeline_manager.analysis_tasks.AnalysisTask

Methods

add_par(name, \*\*kwargs)
get_par_value(name)
list_parameters()
run([extra_message])
set_par(name, \*\*kwargs)
set_pars_from_parser(args, argv, args_dict)
start_message([extra_message])
stop_message()
set_thresh(image, skewness_range=0.1, n_std_th=4.5, min_size_ratio=0.1, sub_block_frac_size=None, use_fixed_th=None, plot=False, verbose=False, resampling_size=1000000)[source]

Function to estimate the backgorund threshold in a given image.

  • If sub_block_frac_size is provided, the image is partitioned in N-blocks with size=sub_block_frac_size*image, and the block with the lowest flux is used to estimate the bkg level. Otherwise, the full image is used.

  • If skewness_range is provided, then the method is ste to the skewness is minimization. The skewness is minimized using the function minimize_skewness(). The data are clipped over the range \(|m-s1,m+s1|\), where m is the mean of the data, and s1=std(data)*sigma_range. The data are clipped in the range providing the minimum skewness .

  • If threshold is provided, then the backgorund level and the variance are directly evaluated from the background pixels

  • If resampling_size the bkg is estimated from a random resampling of the full image (sub_block_frac_size is None) or of the sub image (sub_block_frac_size is not None). The resampling is performed only if the nubmber of pixels in the image is greater than resampling_size

  • min_size_ratio provides the minimum size to stop the clipping, i.e. if (clipped_size/full_size) <min_size_ratio then the clipping process to minimize the skewness is stopped.

  • n_std_th is used to set the background threshold according to bkg_th=bkg_level+n_std_th * bkg_std where:
    • bkg_std is evaluated from the median absolute deviation (MAD) (clipped or not according to method) of the background pixels
    • bkg_level is the mean of the of the background pixels (clipped or not according to method)
Parameters:

image : Image class object

n_std_th : float (Optional)

see above for description

min_size_ratio :float (Optional)

see above for description

sub_block_frac_size : float (Optional)

see above for description

resampling_size : float (Optional)

see above for description

plot : bool (Optional)

verbose : bool (Optional)

Returns:

bkg_th : float

bkg_th=bkg_level+n_std_th * bkg_sig

bkg_level : float

the mean of the flux in the bkg pixels

bkg_sig : float

the median absolute deviation (MAD) of the flux in the background pixels

test_plot(axarr, flux_bkg, bkg_lvl, bkg_sig=None, th=None, skew_1=None, skew_2=None, pre_skew_min_bkg_lvl=None)[source]