tkp.sourcefinder.extract – Source extraction routines

Source Extraction Helpers.

These are used in conjunction with image.ImageData.

class tkp.sourcefinder.extract.Detection(paramset, imagedata, chunk=None, eps_ra=0, eps_dec=0)[source]

The result of a measurement at a given position in a given image.

distance_from(x, y)[source]

Distance from center

serialize(ew_sys_err, ns_sys_err)[source]

Return source properties suitable for database storage.

We manually add ew_sys_err, ns_sys_err

returns: a list of tuples containing all relevant fields

class tkp.sourcefinder.extract.Island(data, rms, chunk, analysis_threshold, detection_map, beam, deblend_nthresh, deblend_mincont, structuring_element, rms_orig=None, flux_orig=None, subthrrange=None)[source]

The source extraction process forms islands, which it then fits. Each island needs to know its position in the image (ie, x, y pixel value at one corner), the threshold above which it is detected (analysis_threshold by default, but will increase if the island is the result of deblending), and a data array.

The island should provide a means of deblending: splitting itself apart and returning multiple sub-islands, if necessary.


Return a decomposed numpy array of all the subislands.

Iterate up through subthresholds, looking for our island splitting into two. If it does, start again, with two or more separate islands.


Fit the position


Noise at maximum position





class tkp.sourcefinder.extract.ParamSet(clean_bias=0.0, clean_bias_error=0.0, frac_flux_cal_error=0.0, alpha_maj1=2.5, alpha_min1=0.5, alpha_maj2=0.5, alpha_min2=2.5, alpha_maj3=1.5, alpha_min3=1.5)[source]

All the source fitting methods should go to produce a ParamSet, which gives all the information necessary to make a Detection.

calculate_errors(noise, beam, threshold)[source]

Calculate positional errors

Uses _condon_formulae() if this object is based on a Gaussian fit, _error_bars_from_moments() if it’s based on moments.


Deconvolve with the clean beam

tkp.sourcefinder.extract.source_profile_and_errors(data, threshold, noise, beam, fixed=None, residuals=True)[source]

Return a number of measurable properties with errorbars

Given an island of pixels it will return a number of measurable properties including errorbars. It will also compute residuals from Gauss fitting and export these to a residual map. And it will make a map of the decomposed sources.

  • data (numpy.ndarray) – array of pixel values, can be a masked array, which is necessary for proper Gauss fitting, because the pixels below the threshold in the corners and along the edges should not be included in the fitting process
  • threshold (float) – Threshold used for selecting pixels for the source (ie, building an island)
  • noise (float) – Noise level in data
  • beam (3-tuple of float) – beam parameters


fixed (dict): parameters to keep fixed while fitting. passed
on to fitting.fitgaussian(): this will lock fit to only occur at that pixel coordinate.
Returns:a populated ParamSet, and a residual array.
Return type:(tuple)