|
lsst.meas.algorithms g412e8c0db5+c0a824bbfa
|
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) |
| Struct | compute_shapelets_only_iq_score (self, Struct results) |
| 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) |
Static Public Member Functions | |
| Struct | compute_shapelets_iq_score (Struct shapelets_results, SourceCatalog catalog, float centroid_offset_scale, str shapelets_base_name, Logger|None log=None) |
Public Attributes | |
| schema = schema | |
| str | shapelets_base_name = "RoughPsfShapelets" |
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 | |
| _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 186 of file computeRoughPsfShapelets.py.
| lsst.meas.algorithms.computeRoughPsfShapelets.ComputeRoughPsfShapeletsTask.__init__ | ( | self, | |
| ComputeRoughPsfShapeletsConfig | None | config = None, | ||
| * | , | ||
| Schema | schema, | ||
| **Any | kwargs ) |
Definition at line 230 of file computeRoughPsfShapelets.py.
|
staticprotected |
Definition at line 981 of file computeRoughPsfShapelets.py.
|
staticprotected |
Definition at line 1015 of file computeRoughPsfShapelets.py.
|
protected |
Find the first peak in a 1-d distribution of radii.
Definition at line 968 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 892 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 320 of file computeRoughPsfShapelets.py.
|
static |
Compute the image quality "score" that includes power from the
median centroid offset in addition to that of the non-atmospheric
coefficents.
The "shapelets_iq_score" is a dimensionless image quality score that
includes power from the median centroid offset between those used in
shapelet decomposition and those in the centroid slot of the provided
source catalog, in addition to the non-atmospheric coefficents from
the shapelet decomposition. The score spans the range [0.0, 1.0] with
lower values indicating better image quality. When present (non-nan)
the shapelets_iq_score should be considered authoritative over the
shapelets_only_iq_score.
Parameters
----------
shapelets_results
Results struct as returned by `run` method of
ComputeRoughPsfShapeletsTask. To be updated in-place.
catalog
Catalog of detections to extract footprints from and fill output
columns of. Its schema must be a superset of ``self.schema``.
Must contain the columns added by ComputeRoughPsfShapeletsTask.
centroid_offset_scale
Value (in pixels) by which to scale the centroid offset to set
and appropriate amount by which the centroid offsets can
contribute to the computed power.
shapelets_base_name
Base name for the catalog columns added by
ComputeRoughPsfShapeletsTask.
log
Logger to write to.
Returns
-------
`lsst.pipe.base.Struct`
Additional results struct components include:
- ``shapelets_summary`` (`lsst.afw.image.ExposureSummaryStats`):
An ExposureSummaryStats object with the following parameters
initialized:
- ``shapeletsIqScore`` (`float`): the image quality score which
includes power from the centroid shift in addition to the
non-atmospheric decomposition coefficients.
- ``centroidDiffShapeletsVsSlotMedian`` (`float`): The median
centroid difference
(sqrt((slot_x - shapelet_x)**2 + (slot_y - shapelet_y)**2))
for sources used in the shapelet decomposition (pixels).
Definition at line 564 of file computeRoughPsfShapelets.py.
| Struct lsst.meas.algorithms.computeRoughPsfShapelets.ComputeRoughPsfShapeletsTask.compute_shapelets_only_iq_score | ( | self, | |
| Struct | results ) |
Compute the image quality "score" that only includes the
non-atmospheric coefficents.
The "shapelet_only_iq_score" is a dimensionless image quality score
as determined from the shapelets decomposition that only includes
power from the non-atmospheric coefficents from the shapelet
decomposition. The score spans the range [0.0, 1.0] with lower
values indicating better image quality.
Parameters
----------
results
Result struct returned by `run`. To be updated in-place.
Returns
-------
`lsst.pipe.base.Struct`
Additional results struct components include:
- ``shapelets_summary`` (`lsst.afw.image.ExposureSummaryStats`):
An ExposureSummaryStats object with the following parameters
initialized:
- ``shapeletsCoeffs`` (`list`[`float`]): The coefficients
from the shapelet decomposition.
- ``nShapeletsStar`` (`int`): The number of sources used in the
shapelet decomposition.
- ``shapeletsOnlyIqScore`` (`float`): The image quality score
which only includes power from the non-atmospheric
decomposition coefficients.
- ``shapeletsStarEMedian`` (`float`): The median ellipticity
(sqrt(starE1**2.0 + starE2**2.0)) of the stars used in the
shapelet decomposition.
- ``shapeletsStarUnNormalizedEMedian`` (`float`): The median
un-normalized ellipticity
(sqrt((starXX - starYY)**2.0 + (2.0*starXY)**2.0)) of the
stars used in the shapelet decomposition.
Definition at line 486 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 672 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 819 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 275 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 380 of file computeRoughPsfShapelets.py.
|
protected |
Definition at line 261 of file computeRoughPsfShapelets.py.
|
protected |
Definition at line 250 of file computeRoughPsfShapelets.py.
|
staticprotected |
Definition at line 227 of file computeRoughPsfShapelets.py.
|
protected |
Definition at line 256 of file computeRoughPsfShapelets.py.
|
protected |
Definition at line 245 of file computeRoughPsfShapelets.py.
|
protected |
Definition at line 240 of file computeRoughPsfShapelets.py.
|
protected |
Definition at line 253 of file computeRoughPsfShapelets.py.
|
protected |
Definition at line 266 of file computeRoughPsfShapelets.py.
|
static |
Definition at line 226 of file computeRoughPsfShapelets.py.
| lsst.meas.algorithms.computeRoughPsfShapelets.ComputeRoughPsfShapeletsTask.schema = schema |
Definition at line 238 of file computeRoughPsfShapelets.py.
| str lsst.meas.algorithms.computeRoughPsfShapelets.ComputeRoughPsfShapeletsTask.shapelets_base_name = "RoughPsfShapelets" |
Definition at line 239 of file computeRoughPsfShapelets.py.