|
lsst.meas.algorithms g1581cd22ba+880e5d07f7
|
Public Member Functions | |
| __init__ (self, ComputeRoughPsfShapeletsConfig|None config=None, *, Schema schema, **Any kwargs) | |
| Struct | run (self, *, MaskedImageF masked_image, SourceCatalog catalog, int seed) |
| dict[int, SpanSetMoments] | compute_raw_moments (self, *, MaskedImageF masked_image, SourceCatalog catalog) |
| Struct | select_stars (self, SourceCatalog catalog, int seed) |
| None | plot_selection (self, matplotlib.figure.Figure figure, *, SourceCatalog catalog, Struct results) |
| None | plot_shapelets (self, matplotlib.figure.Figure figure, *, ImageF image, SourceCatalog catalog, Struct results, int n_stars=3, float stamp_size=2.0) |
Public Attributes | |
| schema = schema | |
Static Public Attributes | |
| ConfigClass = ComputeRoughPsfShapeletsConfig | |
Protected Member Functions | |
| np.ndarray | _threshold_with_bounds (self, np.ndarray values, float threshold, int min_count, int max_count, str name, Literal["<", ">"] kind) |
| tuple[float, KernelDensity] | _find_first_radius_mode (self, np.ndarray radii) |
Static Protected Member Functions | |
| matplotlib.patches.Ellipse | _draw_ellipse (matplotlib.axes.Axes axes, ellipses.BaseCore|ellipses.Ellipse ellipse, *, float|None x=None, float|None y=None, float scale=1.0, **Any kwargs) |
| matplotlib.image.AxesImage | _draw_image (matplotlib.axes.Axes axes, ImageF image, **Any kwargs) |
Protected Attributes | |
| _flux_key = schema.addField("RawPsfMoments_flux", type=float, doc="Unweighted zeroth moment.") | |
| _flux_err_key | |
| _center_key | |
| _shape_key | |
| _flag_key | |
| _candidate_key | |
| _used_key | |
Static Protected Attributes | |
| str | _DefaultName = "computeRoughPsfShapelets" |
A task that computes a rough shapelet expansion of the PSF from a set of high S/N detections. Notes ----- This task is expected to be run early in single-epoch processing - just after background subtraction and an initial high S/N detection phase, and before any deblending or measurement - in order to identify out-of-focus or otherwise bad PSFs. Given a background-subtracted `lsst.afw.image.MaskedImage`, an `lsst.afw.table.SourceCatalog` with footprints attached, and a random number generator seed, the `run` method will: - Compute the *unweighted* 0th-2nd moments of every non-child source over the footprint (except certain configurable masked pixels). This is delegated to the `compute_raw_moments` method (which uses the C++ `SpanSetMoments` class for the pixel-level processing). Unweighted moments are used to avoid "latching onto" a small piece of PSF substructure, but can be much noiser than the Gaussian-weighed moments we usually use. - Select a "candidate" sample of sources with successfully measured moments that satisfy a S/N cut and a radius cut (determined from the first mode of the radius distribution, via kernel density estimation), and then use a robust covariance estimator (`scikit_learn.MinCovDet`) to select presumed isolated stars that are close to the center of that distribution, in 3-parameter shape space. This is delegated to the `select_stars` method. - Fit a single shapelet expansion to the selected stars. This is mostly delegated to the `SpanSetMoments.fit_shapelets` method. The radial shapelet terms at 0th, 2nd, and 4th order are expected to form a space in which donut-shaped PSFs are well-separated from those with monotonic profiles. Other terms *may* be useful in identifying other kinds of undesirable PSF structure.
Definition at line 158 of file computeRoughPsfShapelets.py.
| lsst.meas.algorithms.computeRoughPsfShapelets.ComputeRoughPsfShapeletsTask.__init__ | ( | self, | |
| ComputeRoughPsfShapeletsConfig | None | config = None, | ||
| * | , | ||
| Schema | schema, | ||
| **Any | kwargs ) |
Definition at line 202 of file computeRoughPsfShapelets.py.
|
staticprotected |
Definition at line 748 of file computeRoughPsfShapelets.py.
|
staticprotected |
Definition at line 782 of file computeRoughPsfShapelets.py.
|
protected |
Find the first peak in a 1-d distribution of radii.
Definition at line 735 of file computeRoughPsfShapelets.py.
|
protected |
Return the indices of an array that satisfy an inequality
and/or lower and upper bounds on the number of indices returned.
Parameters
----------
values
Array of values to threshold on.
threshold
Threshold value that selected elements must be above or below.
min_count
The minimum number of indices returned. When thresholding would
yield fewer than this number, the threshold is ignored. Note that
the number of indices may still be less than this if the size of
``values`` is less than this.
max_count
The maximum number of indices returned.
name
Name of the quantity being thresholded, for log messages.
kind
Whether the threshold is a upper bound (``<``) or lower bound
(``>``). This also sets how values are ranked when they are added
or dropped to satisfy the count constraints.
Returns
-------
indices
Indices into ``values``.
Definition at line 659 of file computeRoughPsfShapelets.py.
| dict[int, SpanSetMoments] lsst.meas.algorithms.computeRoughPsfShapelets.ComputeRoughPsfShapeletsTask.compute_raw_moments | ( | self, | |
| * | , | ||
| MaskedImageF | masked_image, | ||
| SourceCatalog | catalog ) |
Compute the unweighted moments of the footprints in a catalog.
Parameters
----------
masked_image
Masked image to measure on. Must be background-subtracted.
catalog
Catalog of detections to extract footprints from and fill output
columns of. Its schema must be a superset of ``self.schema``.
Returns
-------
`dict` [`int`, `SpanSetMoments`]
Objects used to construct and hold the unweighted moments and the
pixel region used to computed them, keyed by source ID.
Definition at line 285 of file computeRoughPsfShapelets.py.
| None lsst.meas.algorithms.computeRoughPsfShapelets.ComputeRoughPsfShapeletsTask.plot_selection | ( | self, | |
| matplotlib.figure.Figure | figure, | ||
| * | , | ||
| SourceCatalog | catalog, | ||
| Struct | results ) |
Create plots of the shape distribution space used to select stars.
Parameters
----------
figure
Matplotlib figure to plot to.
catalog
Catalog of sources with columns populated by the `run` method (at
least through the `select_stars` step).
results
Result struct returned by `run` or `select_stars`.
Definition at line 441 of file computeRoughPsfShapelets.py.
| None lsst.meas.algorithms.computeRoughPsfShapelets.ComputeRoughPsfShapeletsTask.plot_shapelets | ( | self, | |
| matplotlib.figure.Figure | figure, | ||
| * | , | ||
| ImageF | image, | ||
| SourceCatalog | catalog, | ||
| Struct | results, | ||
| int | n_stars = 3, | ||
| float | stamp_size = 2.0 ) |
Create data/model/residual plots of stars and the shapelet model.
Parameters
----------
figure
Matplotlib figure to plot to.
image
The image the stars were measured on.
catalog
Catalog of sources with columns populated by the `run` method .
results
Result struct returned by `run`.
n_stars
Number of stars to include.
stamp_size
Stamp size in inches.
Definition at line 586 of file computeRoughPsfShapelets.py.
| Struct lsst.meas.algorithms.computeRoughPsfShapelets.ComputeRoughPsfShapeletsTask.run | ( | self, | |
| * | , | ||
| MaskedImageF | masked_image, | ||
| SourceCatalog | catalog, | ||
| int | seed ) |
Compute raw moments, select stars, and fit a shapelet expansion to
them.
Parameters
----------
masked_image
Masked image to measure on. Must be background-subtracted.
catalog
Catalog of detections to extract footprints from and fill output
columns of. Its schema must be a superset of ``self.schema``.
seed
A random-number generator seed, used for the robust covariance
estimator.
Returns
-------
`lsst.pipe.base.Struct`
A struct of results containing:
- ``shapelet`` (`lsst.shapelet.ShapeletFunction`): A
Gauss-Laguerre (polar shaplet) expansion of the PSF.
- ``radial`` (`list` [`float`]): the purely radial coefficients
of the shapelet expansion.
- all attributes returned by the `select_stars` method.
Definition at line 242 of file computeRoughPsfShapelets.py.
| Struct lsst.meas.algorithms.computeRoughPsfShapelets.ComputeRoughPsfShapeletsTask.select_stars | ( | self, | |
| SourceCatalog | catalog, | ||
| int | seed ) |
Select probable stars from the distribution of second moments.
Parameters
----------
catalog
Catalog of detections to extract footprints from and fill output
columns of. Its schema must be a superset of ``self.schema``.
seed
A random-number generator seed, used for the robust covariance
estimator.
Returns
-------
`lsst.pipe.base.Struct`
A struct of results containing:
- ``star_ids`` (`numpy.ndarray`): the source IDs that are expected
to be stars.
- ``mean_shape`` (`lsst.afw.geom.ellipses.BaseCore`): the mean of
the shape distribution.
- ``shape_covariance`` (`numpy.ndarray`): the covariance of the
distribution of shapes; a 3x3 matrix. This uses the same
parameterization of the shapes as ``mean_shape``.
- ``radius_cut`` (`float`): the indended radius cut (i.e. the
mode of the radius distribution multipled by the
``radius_factor`` configuration option).
- ``radius_kde`` (`sklearn.neighbors.KernelDensity`): kernel
density estimator on the radius distribution, used to determine
the radius cut.
Definition at line 345 of file computeRoughPsfShapelets.py.
|
protected |
Definition at line 228 of file computeRoughPsfShapelets.py.
|
protected |
Definition at line 217 of file computeRoughPsfShapelets.py.
|
staticprotected |
Definition at line 199 of file computeRoughPsfShapelets.py.
|
protected |
Definition at line 223 of file computeRoughPsfShapelets.py.
|
protected |
Definition at line 212 of file computeRoughPsfShapelets.py.
|
protected |
Definition at line 211 of file computeRoughPsfShapelets.py.
|
protected |
Definition at line 220 of file computeRoughPsfShapelets.py.
|
protected |
Definition at line 233 of file computeRoughPsfShapelets.py.
|
static |
Definition at line 198 of file computeRoughPsfShapelets.py.
| lsst.meas.algorithms.computeRoughPsfShapelets.ComputeRoughPsfShapeletsTask.schema = schema |
Definition at line 210 of file computeRoughPsfShapelets.py.