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.

deblend(niter=0)[source]

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(fixed=None)[source]

Fit the position

noise()[source]

Noise at maximum position

sig()[source]

Deviation

threshold()[source]

Threshold

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_from_clean_beam(beam)[source]

Deconvolve with the clean beam

keys()[source]
tkp.sourcefinder.extract.source_profile_and_errors(data, threshold, noise, beam, fixed=None)[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.

In addition to handling the initial parameter estimation, and any fits which fail to converge, this function runs the goodness-of-fit calculations - see tkp.sourcefinder.fitting.goodness_of_fit() for details.

Parameters:
  • 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 (tuple) – beam parameters (semimaj,semimin,theta)

Kwargs:

fixed (dict): Parameters (and their values) to hold fixed while fitting.
Passed on to fitting.fitgaussian().
Returns:a populated ParamSet, and a residuals map. Note the residuals map is a regular ndarray, where masked (unfitted) regions have been filled with 0-values.
Return type:tuple