tkp.sourcefinder.stats – Statistics specific to source finding for radio images.

Generic utility routines for number handling and calculating (specific) variances used by the TKP sourcefinder.

tkp.sourcefinder.stats.sigma_clip(data, beam, sigma=<function unbiased_sigma>, max_iter=100, centref=<function median>, distf=<function var>, my_iterations=0, corr_clip=1.0)[source]

Iterative clipping

By default, this performs clipping of the standard deviation about the median of the data. But by tweaking centref/distf, it could be much more general.

max_iter sets the maximum number of iterations used.

my_iterations is a counter for recursive operation of the code; leave it alone unless you really want to pretend to jump into the middle of a loop.

sigma is subtle: if a callable is given, it is passed a copy of the data array and can calculate a clipping limit. See, for e.g., unbiased_sigma() defined above. However, if it isn’t callable, sigma is assumed to just set a hard limit.

To do: Improve documentation
-Returns??? -How does it make use of the beam? (It estimates the noise correlation)
tkp.sourcefinder.stats.unbiased_sigma(N_indep)[source]

Calculate an unbiased sigma for using in sigma clipping.

The formula below for cliplim is pretty subtle. Kappa, sigma clipping should be such that the noise is not biased by it. Consequently, the clipping boundaries should be such that exactly half an independent pixel should exceed it if the map were source free. A rigid boundary of 3 sigma is appropriate only if the number of independent pixels is about 185 (the number of independent pixels equals the number of pixels divided by the beamsize in pixels).

The condition that kappa, sigma clipping may not bias the noise is translated in the formula below, using Gaussian statistics. A disadvantage of this is that more iterations of kappa, sigma clipping are needed, compared to 3 sigma clipping. However, the noise values derived are generally significantly different (lower) compared to 3 sigma clipping.

tkp.sourcefinder.stats.var_helper(N)[source]

Correct for the fact the rms noise is computed from a clipped distribution.

That noise will always be lower than the noise from the complete distribution. The correction factor is a function of the computed rms noise only.