extract_stars#

photutils.psf.extract_stars(data, catalogs, *, size=(11, 11))[source]#

Extract cutout images centered on stars defined in the input catalog(s).

A star is not extracted, and a warning is issued, if its cutout bounds lie partially or completely outside the input data image, if its position or its catalog flux is not finite, or if its cutout is completely masked and no catalog flux is given.

Parameters:
data2D ndarray, NDData, or list of these

A 2D ndarray, a NDData object, or a list of 2D arrays and/or NDData objects containing the 2D image(s) from which to extract the stars.

A plain array carries no uncertainty or WCS, so its stars are given uniform weights and the star positions must be in pixel coordinates. If the array is a MaskedArray, its masked pixels are given zero weight. Use a NDData object to input an uncertainty, mask, or WCS.

If an NDData object has an uncertainty, it is converted to a standard deviation and the weights of each star are the inverse of the standard deviation. An uncertainty that cannot be converted (e.g., an UnknownUncertainty, which NDData creates for a plain array) is assumed to be a standard deviation. An uncertainty object whose uncertainty_type is 'weights' is used directly as the weights. Nonfinite weights (e.g., from a zero uncertainty) are set to zero, and a warning is issued. Pixels that are masked in the mask attribute are given zero weight.

If the input catalogs contain only the sky coordinates (i.e., not the pixel coordinates) of the stars then each image must be a NDData object with a valid wcs attribute. Any unit of an input Quantity or NDData object is ignored.

catalogsTable, list of Table

A catalog or list of catalogs of sources to be extracted from the input data. To link stars in multiple images as a single source, you must use a single source catalog where the positions are defined in sky coordinates. If a linked star can be extracted from only one of the input images, it is returned as a plain EPSFStar instead of a LinkedEPSFStar.

If a list of catalogs is input (or a single catalog with a single NDData object), they are assumed to correspond to the list of NDData objects input in data (i.e., a separate source catalog for each 2D image). For this case, the center of each source can be defined either in pixel coordinates (in x and y columns) or sky coordinates (in a skycoord column containing a SkyCoord object). If both are specified, then the pixel coordinates will be used.

If a single source catalog is input with multiple NDData objects, then these sources will be extracted from every 2D image in the input data. In this case, the sky coordinates for each source must be specified as a SkyCoord object contained in a column called skycoord. Each NDData object in the input data must also have a valid wcs attribute. Pixel coordinates (in x and y columns) will be ignored.

Optionally, each catalog may also contain an id column representing the ID/name of stars. If this column is not present then the id_label of each extracted star is set to its table row number (starting at 1). The catalogs may also contain an optional flux column giving the flux of each star. If present, these values are used instead of estimating the flux from the cutout data. Any other columns present in the input catalogs will be ignored.

sizeint or array_like (int), optional

The extraction box size along each axis. If size is a scalar then a square box of size size will be used. If size has two elements, they must be in (ny, nx) order. size must have odd values and be greater than or equal to 3 for both axes.

Returns:
starsEPSFStars instance

An EPSFStars instance containing the extracted stars.

Warns:
AstropyUserWarning

If any star is not extracted, if a cutout has nonfinite weights or nonfinite data values, if all unmasked values in a cutout are zero, or if an input catalog is empty.