Skip to content

PointSourceExtractor

user29A edited this page Dec 14, 2021 · 36 revisions

Overview

PointSourceExtractor provides functionality for identifying and characterizing point sources in an image. The source extraction algorithm is described here:

https://iopscience.iop.org/article/10.1088/1538-3873/ab7ee8

Constructors

PointSourceExtractor() The default constructor for the class object, used when an image is to be examined for sources.

PointSourceExtractor(double[] XCoords, double[] YCoords) The constructor for the class object used when an image already has a given list of coordinate locations for sources in the image. Use overload of Extract_Sources referencing the objects own centroids to determine source characteristics at the coordinate locations.

PointSourceExtractor(JPFITS.FITSBinTable BinTablePSE) The constructor for the class object based on a PointSourceExtractor saved from another session.

Member Methods

void Extract_Sources(double[,] image, double pix_saturation, double pix_min, double pix_max, double kernel_min, double kernel_max, bool threshholds_as_SN, int kernel_radius, int source_separation, bool auto_background, string kernel_filename_template, bool[,]? ROI_region, bool show_waitbar) Searches for sources within a 2D image array.

  • image The 2D image array to find sources in.
  • pix_saturation The saturation threshold of the image pixels, for finding saturation islands. Set equal to zero (0) if not needed.
  • pix_min The minimum pixel threshold value (or SN) to consider a potential source.
  • pix_max The maximum pixel threshold value (or SN) to consider a potential source.
  • kernel_min The minimum kernel pixel sum threshold value (or SN) to consider a potential source.
  • kernel_max The maximum kernel pixel sum threshold value (or SN) to consider a potential source.
  • threshholds_as_SN Treat the thresholds as Signal to Noise instead of pixel values.
  • kernel_radius The radius (pixels) of the kernel to find sources within. Secondary sources within the radius will be ignored.
  • source_separation The separation (pixels) between sources. Only the brightest source within the separation radius is kept.
  • auto_background Automatically determine the local background for potential sources. Not required if background is known to be zeroed, but should have no effect if used in this case.
  • kernel_filename_template The template full file name for the kernels to be saved. Sources will be numbered sequentially. Pass empty string for no saving.
  • ROI_region A boolean array of valid area to examine. Pass null or array of equal dimension to source image all true for entire image search.
  • show_waitbar Show a cancellable wait bar.

void Extract_Sources(double[,] image, double[] XCoords, double[] YCoords, int kernel_radius, bool auto_background, string kernel_filename_template) Determines centroids and other kernel information for known sources at given coordinates.

  • image The 2D image array containing the known sources to extract.
  • XCoords The x-axis coordinates of the sources. These can be PSE.Centroids_X.
  • YCoords The y-axis coordinates of the sources. These can be PSE.Centroids_Y.
  • kernel_radius The radius (pixels) of the kernel to centroid.
  • auto_background Automatically determine the local background for potential sources. Not required if background is known to be zeroed, but should have no effect if used in this case.
  • kernel_filename_template The template full file name for the kernels to be saved. Sources will be numbered sequentially. Pass empty string for no saving.

void Extract_Attempt_N_Sources(int N, double[,] image, double pix_saturation, double pix_min, double pix_max, double kernel_min, double kernel_max, bool threshholds_as_SN, int kernel_radius, int source_separation, bool auto_background, string kernel_filename_template, bool[,]? ROI_region, bool show_waitbar) Attempt to find N strongest sources in an image.

  • N The number of strongest sources to try to find.
  • Other parameters as above.

void Fit_Sources_Gaussian_Circular(double[] Pinit, double[] LBnds, double[] UBnds) Performs a least-squares fit on all sources of the form

G(x,y|P) = P(0) * exp( -((x - P(1)).^2 + (y - P(2)).^2 ) / (2*P(3)^2)) + P(4)

  • Pinit Initial guesses for the fit parameters. Only P(3) and P(4) are used, all other parameter initial estimates are determined locally.
  • LBnds Lower bounds for the fit parameters. Only LBnds(3) and LBnds(4) are used, all other parameter bound estimates are determined locally.
  • UBnds Upper bounds for the fit parameters. Only UBnds(3) and LBnds(4) are used, all other parameter bound estimates are determined locally.

void Fit_Sources_Gaussian_Elliptical(double[] Pinit, double[] LBnds, double[] UBnds) Performs a least-squares fit on all sources of the form

G(x,y|P) = P(0) * exp( -((x - P(1))*cosd(P(3)) + (y - P(2))sind(P(3))).^2 / (2P(4)^2) - ( -(x - P(1))*sind(P(3)) + (y - P(2))cosd(P(3))).^2 / (2P(5)^2) ) + P(6).

  • Pinit Initial guesses for the fit parameters. Only P(3), P(4), P(5) and P(6) are used, all other parameter initial estimates are determined locally.
  • LBnds Lower bounds for the fit parameters. Same restrictions as above.
  • UBnds Upper bounds for the fit parameters. Same restrictions as above.

void Fit_Sources_Moffat_Circular(double[] Pinit, double[] LBnds, double[] UBnds) Performs a least-squares fit on all sources of the form

M(x,y|P) = P(0) * ( 1 + { (x - P(1))^2 + (y - P(2))^2 } / P(3)^2 ) ^ (-P(4)) + P(5).

  • Pinit Initial guesses for the fit parameters. Only P(3), P(4), P(5) are used, all other parameter initial estimates are determined locally.
  • LBnds Lower bounds for the fit parameters. Same restrictions as above.
  • UBnds Upper bounds for the fit parameters. Same restrictions as above.

void Fit_Sources_Moffat_Elliptical(double[] Pinit, double[] LBnds, double[] UBnds) Performs a least-squares fit on all sources of the form

M(x,y|P) = P(0) * (1 + { ((x - P(1))*cosd(P(3)) + (y - P(2))*sind(P(3))) ^ 2 } / P(4) ^ 2 + { (-(x - P(1))*sind(P(3)) + (y - P(2))*cosd(P(3))) ^ 2 } / P(5) ^ 2) ^ (-P(6)) + P(7).

  • Pinit Initial guesses for the fit parameters. Only P(3), P(4), P(5), P(6) and P(7) are used, all other parameter initial estimates are determined locally.
  • LBnds Lower bounds for the fit parameters. Same restrictions as above.
  • UBnds Upper bounds for the fit parameters. Same restrictions as above.

void Save_Source_Table(string delimit) Saves the metadata table of the extracted sources as a delimited text file.

  • delimit The delimit argument string: "tab" specifies a tab-delimit, otherwise provide a character (such as the comma "," etc).

void Generate_Source_RADec_Coords(JPFITS.WorldCoordinateSolution wcs) Generates RA and Dec coordinates for the sources in this instance, using the supplied World Coordinate System instance.

  • wcs The world coordinate system to use for converting image pixel locations to world coordinates.

Static Methods

double[,] GetKernel(double[,] image, int x0, int y0, int radius) Gets a sub-array kernel from a primary image given a center position and square half-width radius.

  • image The source image to extract the kernel from.
  • x0 The center pixel of the kernel on the horizontal axis of the image.
  • y0 The center pixel of the kernel on the vertical axis of the image.
  • radius The radius of the kernel.

void Centroid(int[] xdata, int[] ydata, double[,] kernel, out double x_centroid, out double y_centroid) Determines the [x, y] centroid location of a given kernel.

  • xdata The horizontal axis values of the kernel.
  • ydata The vertical axis values of the kernel.
  • kernel The kernel to centroid.
  • x_centroid The weighed mean centroid of the kernel on the horizontal axis.
  • y_centroid The weighed mean centroid of the kernel on the vertical axis.

double[] COG (double[,] ROI, int N_last_fit_pts, out double[] N_points_COG, out double background_signal_per_pix, out double source_signal) Determines the Curve of Growth photometry for a source centered in the ROI image.

  • ROI The region of interest image to determine the curve of growth for.
  • N_last_fit_pts The number of tailing points to fit for linear slope - intercept of this line is source counts, slope is the background count per pixel.
  • N_points_COG The number of points for each curve of growth point. Used as the abscissa against the return value.
  • background_signal_per_pix The slope of the linear fit line to the tailing points, i.e., the counts per pixel background.
  • source_signal The intercept of the linear fit line to the tailing points, i.e., the total central source counts.

Properties

string[,] Source_Table Gets a metadata table of the extracted sources.

double[] Centroids_X Gets or Sets the x-axis centroids of extracted sources.

double[] Centroids_Y Gets or Sets the Y-axis centroids of extracted sources.

double[] Centroids_Volume Gets the volume (total count) of extracted sources.

int N_Sources Gets the total number of extracted sources.

int N_SaturatedSources Gets the number of saturated sources.

double[,] Fitted_Parameter_List Gets a list of the fitted parameters for all sources.

string LSFit_Equation Gets a string of the equation used for least-squares fitting.

bool Fitted Gets a boolean to indicate whether least-squares fits have been performed.

bool[,] SourceBooleanMap Returns the boolean source map.

int[,] SourceIndexMap Returns the integer index source map.

Clone this wiki locally