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
dataimage, if its position or its catalogfluxis not finite, or if its cutout is completely masked and no catalogfluxis given.- Parameters:
- data2D
ndarray,NDData, or list of these A 2D
ndarray, aNDDataobject, or a list of 2D arrays and/orNDDataobjects 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 aNDDataobject to input an uncertainty, mask, or WCS.If an
NDDataobject has anuncertainty, 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., anUnknownUncertainty, whichNDDatacreates for a plain array) is assumed to be a standard deviation. An uncertainty object whoseuncertainty_typeis'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 themaskattribute are given zero weight.If the input
catalogscontain only the sky coordinates (i.e., not the pixel coordinates) of the stars then each image must be aNDDataobject with a validwcsattribute. Any unit of an inputQuantityorNDDataobject is ignored.- catalogs
Table, list ofTable 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 plainEPSFStarinstead of aLinkedEPSFStar.If a list of catalogs is input (or a single catalog with a single
NDDataobject), they are assumed to correspond to the list ofNDDataobjects input indata(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 (inxandycolumns) or sky coordinates (in askycoordcolumn containing aSkyCoordobject). If both are specified, then the pixel coordinates will be used.If a single source catalog is input with multiple
NDDataobjects, then these sources will be extracted from every 2D image in the inputdata. In this case, the sky coordinates for each source must be specified as aSkyCoordobject contained in a column calledskycoord. EachNDDataobject in the inputdatamust also have a validwcsattribute. Pixel coordinates (inxandycolumns) will be ignored.Optionally, each catalog may also contain an
idcolumn representing the ID/name of stars. If this column is not present then theid_labelof each extracted star is set to its table row number (starting at 1). The catalogs may also contain an optionalfluxcolumn 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 inputcatalogswill be ignored.- sizeint or array_like (int), optional
The extraction box size along each axis. If
sizeis a scalar then a square box of sizesizewill be used. Ifsizehas two elements, they must be in(ny, nx)order.sizemust have odd values and be greater than or equal to 3 for both axes.
- data2D
- Returns:
- 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.