Source Catalogs¶
A module that manages catalogs and source finding algorithms (i.e.,
SExtractor
source finding).
- Author
Mihai Cara (for help, contact HST Help Desk)
- License
-
class
subpixal.catalogs.
ImageCatalog
[source]¶ A class for finding sources in images and handling catalog data: storing, filtering, and retrieving sources.
-
append_filters
(self, fcond)[source]¶ Add one or more conditions for selecting sources from the raw catalog to already set filters. See
set_filters()
for description of parameterfcond
.
-
compute_position_std
(self, catalog)[source]¶ This function is called to compute source position error estimate. This function uses the following simplified estimate: \(\sigma_{\mathrm{pos}}=\sigma_{\mathrm{Gaussian}} / \mathrm{SNR}=\mathrm{FWHM}/(2\sqrt{2 \ln 2}\mathrm{SNR})\). Sub-classes can implement more accurate position error computation.
- Parameters
- catalogastropy.table.Table
A table containing
required_colnames
columns.
- Returns
- pos_stdnumpy.ndarray
Position error computed from input catalog data.
-
compute_weights
(self, catalog)[source]¶ This function is called to compute source weights in a catalog. Currently, all weights are set equal to 1. Sub-classes should implement more meaningful weight computation.
- Parameters
- catalogastropy.table.Table
A table containing
required_colnames
columns.
- Returns
- weightsnumpy.ndarray
Weights computed from input catalog data.
-
abstract
execute
(self)[source]¶ Find sources in the image. Compute catalog applying masks and selecting only sources that satisfy all set filters.
-
property
filters
¶ Get a list of all active selection filters.
-
property
image_extn
¶ Get image extension number when the image was set using a string file name. When image was set (in py:meth:
set_image
) using anumpy.ndarray
, this property isNone
.
-
remove_filter
(self, key, op=None)[source]¶ Remove a specific filter by column name and, optionally, by comparison operator.
- Parameters
- keystr
Column name to which selection criteria (filter) is applied. If more conditions match a column name vale, all of them will be removed.
- opstr, optional
Specifies the comparison operation used in a filter. This allows narrowing down which filters should be removed.
-
property
required_colnames
¶ Get a list of the minimum column names that are required to be present in the raw catalog after catalog column name mapping has been applied.
-
set_filters
(self, fcond)[source]¶ Set conditions for selecting sources from the raw catalog.
- Parameters
- fcondtuple, list of tuples
Each selection condition must be specified as a tuple of the form
(colname, cond, value)
OR(colname, nrows)
where:colname
is a column name from the raw catalog after catalog column name mapping has been applied. Userawcat_colnames
to get a list of available column names.cond
is a string representing a selection condition, i.e., a comparison operator. The following operators are suported:['>', '>=', '==', '!=', '<', '<=', 'h', 'l']
. The'h'
or'l'
operators are used to select a specific number of rows (specified by thevalue
) that have highest or lowest values in the column specified bycolname
. Selection of highest/lowest values is performed last, after all other comparison-based filters have been applied.value
is a numeric value to be used for comparison of column values. Whencond
is either'h'
or'l'
, this value must be a positive integer number of rows to be .
Multiple selection conditions can be provided as a list of the condition tuples described above.
-
set_image
(self, image)[source]¶ Set image to be used for source finding.
- Parameters
- image: numpy.ndarray, str
When setting an image either a
numpy.ndarray
of image data or a string file name is acceptable. Image file name may be followed by an extension specification such as'file1.fits[1]'
or'file1.fits[(sci,1)]'
(by default, the first image-like extension will be used).
-
set_mask
(self, mask)[source]¶ Get/Set mask used to ignore (mask) “bad” sources from the catalog.
- Parameters
- maskstr, tuple of two 1D lists of int, 2D numpy.ndarray
A mask can be provided in several ways:
When
mask
is a string, it is assumed to be the name of a simple FITS file contaning a boolean mask indicating “bad” pixels using valueTrue
(=ignore these pixels) and “good” pixels using valueFalse
(=no need to mask).mask
can also be provided directly as a boolean 2D “image” in the form of a booleannumpy.ndarray
.Finally,
mask
can be a tuple of exactly two lists (or 1Dnumpy.ndarray
) containing integer coordinates of the “pixels” to be masked as “bad”. Any source with coordinates within such a “pixel” will be excluded from the catalog.
-
-
class
subpixal.catalogs.
SExImageCatalog
(image=None, sexconfig=None, max_stellarity=1.0, sextractor_cmd='sex')[source]¶ A catalog class specialized in finding sources using
SExtractor
and then loading and processing rawSExtractor
catalogs and its output files.- Parameters
- imagestr
A
FITS
image file name.- sexconfigstr
File name of the
SExtractor
configuration file to be used for finding sources in theimage
.- max_stellarityfloat, None, optional
Maximum stellarity for selecting sources from the catalog. When
max_stellarity
isNone
, source filtering by ‘stellarity’ is turned off.- sextractor_cmdstr, optional
Command to invoke
SExtractor
.
-
append_filters
(self, fcond)[source]¶ Add one or more conditions for selecting sources from the raw catalog to already set filters. See
set_filters()
for description of parameterfcond
.
-
property
catalog
¶ Get catalog (after applying masks and selection filters).
-
compute_position_std
(self, catalog)¶ This function is called to compute source position error estimate. This function uses the following simplified estimate: \(\sigma_{\mathrm{pos}}=\sigma_{\mathrm{Gaussian}} / \mathrm{SNR}=\mathrm{FWHM}/(2\sqrt{2 \ln 2}\mathrm{SNR})\). Sub-classes can implement more accurate position error computation.
- Parameters
- catalogastropy.table.Table
A table containing
required_colnames
columns.
- Returns
- pos_stdnumpy.ndarray
Position error computed from input catalog data.
-
compute_weights
(self, catalog)[source]¶ This function is called to compute source weights in a catalog. This function estimates weights as \(1/\sigma_{\mathrm{pos}}\).
- Parameters
- catalogastropy.table.Table
A table containing
required_colnames
columns.
- Returns
- weightsastropy.table.Column
Weights computed from input catalog data.
-
execute
(self)[source]¶ Find sources in the image. Compute catalog applying masks and selecting only sources that satisfy all set filters.
-
property
filters
¶ Get a list of all active selection filters.
-
get_segmentation_image
(self)[source]¶ Get segmentation file name stored in the
SExtractor
’s configuration file orNone
.
-
property
image_extn
¶ Get image extension number when the image was set using a string file name. When image was set (in py:meth:
set_image
) using anumpy.ndarray
, this property isNone
.
-
property
required_colnames
¶ Get a list of the minimum column names that are required to be present in the raw catalog after catalog column name mapping has been applied.
-
set_default_filters
(self)[source]¶ Sets default filters for selecting sources from the raw catalog.
Default selection criteria are:
flux > 0
ANDfwhm > 0
ANDsemi-major-a > 0
ANDsemi-major-b > 0
(ANDstellarity <= max_stellarity
, ifmax_stellarity
is notNone
).
-
set_filters
(self, fcond)[source]¶ Set conditions for selecting sources from the raw catalog.
- Parameters
- fcondtuple, list of tuples
Each selection condition must be specified as a tuple of the form
(colname, cond, value)
OR(colname, nrows)
where:colname
is a column name from the raw catalog after catalog column name mapping has been applied. Userawcat_colnames
to get a list of available column names.cond
is a string representing a selection condition, i.e., a comparison operator. The following operators are suported:['>', '>=', '==', '!=', '<', '<=', 'h', 'l']
. The'h'
or'l'
operators are used to select a specific number of rows (specified by thevalue
) that have highest or lowest values in the column specified bycolname
. Selection of highest/lowest values is performed last, after all other comparison-based filters have been applied.value
is a numeric value to be used for comparison of column values. Whencond
is either'h'
or'l'
, this value must be a positive integer number of rows to be .
Multiple selection conditions can be provided as a list of the condition tuples described above.
-
set_image
(self, image)[source]¶ Set image to be used for source finding.
- Parameters
- image: numpy.ndarray, str
When setting an image either a
numpy.ndarray
of image data or a string file name is acceptable. Image file name may be followed by an extension specification such as'file1.fits[1]'
or'file1.fits[(sci,1)]'
(by default, the first image-like extension will be used).
-
set_mask
(self, mask)[source]¶ Get/Set mask used to ignore (mask) “bad” sources from the catalog.
- Parameters
- maskstr, tuple of two 1D lists of int, 2D numpy.ndarray
A mask can be provided in several ways:
When
mask
is a string, it is assumed to be the name of a simple FITS file contaning a boolean mask indicating “bad” pixels using valueTrue
(=ignore these pixels) and “good” pixels using valueFalse
(=no need to mask).mask
can also be provided directly as a boolean 2D “image” in the form of a booleannumpy.ndarray
.Finally,
mask
can be a tuple of exactly two lists (or 1Dnumpy.ndarray
) containing integer coordinates of the “pixels” to be masked as “bad”. Any source with coordinates within such a “pixel” will be excluded from the catalog.
-
property
sexconfig
¶ Set/Get
SExtractor
configuration file.