sourcefinder.stats#
Generic utility routines for number handling and calculating (specific) variances used by the TKP sourcefinder.
Functions#
|
Perform dynamic data clipping. |
|
|
|
This function defines the transcendental equation 2.25 from Spreeuw's |
|
Calculate the number of independent pixels given the total |
Module Contents#
- sourcefinder.stats.data_clipper_dynamic(flat_data, number_of_non_nan_elements, mean, std)[source]#
Perform dynamic data clipping.
Perform dynamic data clipping to calculate the mean and standard deviation of the background pixels in a subimage. This function was written to calculate two grids that together determine the statistics of the background noise of the image. The nodes of those grids are centered on the subimages. The guvectorize decorator allows for 3D input instead of the flattened subimage data. The first and second dimensions correspond to the desired grid dimensions, and the third dimension corresponds to the flattened subimage size. See utils.make_subimages for information on how suitable input for this function is generated. The parameters in this docstring apply to a single subimage. “dynamic” kappa * sigma clipping differs from classical sigma clipping in the sense that a bias correction is applied; sigma as derived from a clipped distribution is biased low.
- Parameters:
- flat_datanumpy.ndarray
The flattened array of subimage data.
- number_of_non_nan_elementsnumpy.ndarray
A single-element array containing the number of non-NaN elements in flat_data.
- meannumpy.ndarray
A single-element array to store the calculated mean of the background pixels of the subimage.
- stdnumpy.ndarray
A single-element array to store the calculated standard deviation of the background pixels of the subimage.
Notes
This function uses an iterative approach to clip the data and calculate the mean and standard deviation of the background pixels. The median is used as a robust approximation of the mean, and the standard deviation is corrected for bias when clipping is applied. The SExtractor approach for estimating the mean in case of skewed vs. not-too-skewed distributions is followed.
- sourcefinder.stats.find_true_std(sigma, clipped_std, clip_limit)[source]#
This function defines the transcendental equation 2.25 from Spreeuw’s thesis, i.e. the root of this function is the true standard deviation, derived from a clipped standard deviation and a clipping limit.
- Parameters:
- sigmafloat
The true standard deviation.
- clipped_stdfloat
The standard deviation of the clipped data.
- clip_limitfloat
The clipping limit.
- Returns:
- float
The value of the function for the given sigma.
Notes
This function, together with its derivative should be input to a root finder algorithm; i.e. we are looking for the value of sigma such that this function returns zero.
- sourcefinder.stats.indep_pixels(n, correlation_lengths)[source]#
Calculate the number of independent pixels given the total number of pixels and the correlation lengths.
- Parameters:
- nint
The total number of pixels.
- correlation_lengthstuple of float
A tuple containing the long and short correlation lengths.
- Returns:
- float
The number of independent pixels.