StarFinderCatalogBase#

class photutils.detection.StarFinderCatalogBase(data, xypos, kernel, *, n_brightest=None, peak_max=None)[source]#

Bases: object

Abstract base class for star finder catalogs.

This class provides common functionality for catalog classes that store and compute properties of detected sources. External packages may subclass it to create custom star finder catalogs.

Subclasses must implement:

  • x_centroid property: the object centroid in the x direction.

  • y_centroid property: the object centroid in the y direction.

  • apply_filters method: filter the catalog using algorithm-specific criteria.

  • default_columns attribute: a tuple of column names used by to_table when no explicit columns are given. This should be set in the subclass __init__.

Subclasses may override:

  • _get_init_attributes: return attribute names to copy during slicing. The override should include 'default_columns' in the returned tuple.

  • make_cutouts: customize how cutout arrays are extracted.

  • cutout_data: customize the cutouts used for photometry (e.g., zeroing negative pixels).

Parameters:
data2D ndarray or Quantity

The 2D image. The image should be background-subtracted.

xyposNx2 ndarray

An Nx2 array of (x, y) pixel coordinates denoting the central positions of the stars. The positions are rounded to the nearest pixel.

kernel2D ndarray

A 2D array of the PSF kernel. Internally, the star finder classes may also pass a kernel object.

n_brightestint, None, optional

The number of brightest objects to keep after sorting the source list by flux. If n_brightest is set to None, all objects will be selected.

peak_maxfloat, None, optional

The maximum allowed peak pixel value in an object. Objects with peak pixel values greater than peak_max will be rejected. This keyword may be used, for example, to exclude saturated sources. If the star finder is run on an image that is a Quantity array, then peak_max must have the same units. If peak_max is set to None, then no peak pixel value filtering will be performed.

Attributes Summary

cutout_centroid

The centroids within the cutouts as an Nx2 array in (y, x) order.

cutout_data

The cutout data arrays.

cutout_x_centroid

The cutout x centroids.

cutout_y_centroid

The cutout y centroids.

flux

The instrumental fluxes.

fwhm

The FWHM of the sources.

isscalar

Whether the instance is scalar (e.g., a single source).

mag

The instrumental magnitudes.

moments

The raw image moments.

moments_central

The central image moments up to second order, normalized by the zeroth raw moment (the total cutout flux).

mu_diff

The difference of the second-order central moments in x and y (x minus y).

mu_sum

The sum of the second-order central moments in x and y.

orientation

The angle between the x-axis and the major axis of the 2D Gaussian function that has the same second-order moments as the source.

peak

The peak pixel values.

roundness

The roundness of the sources, computed from the second-order central moments.

x_centroid

Object centroid in the x direction.

y_centroid

Object centroid in the y direction.

Methods Summary

apply_all_filters()

Apply all filters, select the brightest, and reset the source IDs.

apply_filters()

Filter the catalog.

make_cutouts(data)

Make cutouts from the data array.

reset_ids()

Reset the ID column to be consecutive integers.

select_brightest()

Select the n_brightest sources with the largest fluxes.

to_table(*[, columns])

Create a QTable of catalog properties.

Attributes Documentation

cutout_centroid[source]#

The centroids within the cutouts as an Nx2 array in (y, x) order.

cutout_data[source]#

The cutout data arrays.

Subclasses may override this property to customize the cutouts used for moment-based photometry calculations (e.g., zeroing negative pixels or subtracting a local sky background).

cutout_x_centroid[source]#

The cutout x centroids.

cutout_y_centroid[source]#

The cutout y centroids.

flux[source]#

The instrumental fluxes.

fwhm[source]#

The FWHM of the sources.

isscalar[source]#

Whether the instance is scalar (e.g., a single source).

mag[source]#

The instrumental magnitudes.

moments[source]#

The raw image moments.

moments_central[source]#

The central image moments up to second order, normalized by the zeroth raw moment (the total cutout flux).

mu_diff[source]#

The difference of the second-order central moments in x and y (x minus y).

mu_sum[source]#

The sum of the second-order central moments in x and y.

orientation[source]#

The angle between the x-axis and the major axis of the 2D Gaussian function that has the same second-order moments as the source.

The angle increases in the counterclockwise direction and is in the range (-90, 90] degrees.

peak[source]#

The peak pixel values.

roundness[source]#

The roundness of the sources, computed from the second-order central moments.

The value is 0 for a circular source and approaches 1 for a highly elongated source.

x_centroid#

Object centroid in the x direction.

This property must be implemented in subclasses.

y_centroid#

Object centroid in the y direction.

This property must be implemented in subclasses.

Methods Documentation

apply_all_filters()[source]#

Apply all filters, select the brightest, and reset the source IDs.

Returns:
catalogStarFinderCatalogBase or None

The filtered catalog, or None if no sources pass the filters.

abstractmethod apply_filters()[source]#

Filter the catalog.

This method must be implemented in subclasses to apply algorithm-specific filtering criteria.

Returns:
catalogStarFinderCatalogBase or None

The filtered catalog, or None if no sources remain.

make_cutouts(data)[source]#

Make cutouts from the data array.

Parameters:
data2D ndarray or Quantity

The 2D image array. Any units are ignored.

Returns:
cutouts3D ndarray or Quantity

The cutout arrays with shape (n_sources, ny, nx). The catalog unit is attached if it is not None.

reset_ids()[source]#

Reset the ID column to be consecutive integers.

select_brightest()[source]#

Select the n_brightest sources with the largest fluxes.

Returns:
catalogStarFinderCatalogBase

A new catalog of the n_brightest sources sorted by decreasing flux. If n_brightest is None, the catalog itself is returned unchanged. The source IDs are not reset.

to_table(*, columns=None)[source]#

Create a QTable of catalog properties.

Parameters:
columnsstr or list of str, optional

Names of column(s) to include in the table. If None, uses self.default_columns. The valid names are 'id', the names in default_columns, and the cached source properties.

Returns:
tableQTable

A table of the catalog properties.

Raises:
ValueError

If any name in columns is not a valid (or deprecated) column name.