22"""Definition of measurement plugins.
24This module defines and registers a series of pure-Python measurement plugins
25which have trivial implementations. It also wraps measurement algorithms
26defined in C++ to expose them to the measurement framework.
37from deprecated.sphinx
import deprecated
38from ._measBaseLib
import (ApertureFluxControl, ApertureFluxTransform,
39 BaseTransform, BlendednessAlgorithm,
40 BlendednessControl, CircularApertureFluxAlgorithm,
41 GaussianFluxAlgorithm, GaussianFluxControl,
42 GaussianFluxTransform, LocalBackgroundAlgorithm,
43 LocalBackgroundControl, LocalBackgroundTransform,
46 NaiveCentroidAlgorithm, NaiveCentroidControl, NaiveCentroidTransform,
47 PeakLikelihoodFluxAlgorithm,
48 PeakLikelihoodFluxControl,
49 PeakLikelihoodFluxTransform, PixelFlagsAlgorithm,
50 PixelFlagsControl, PsfFluxAlgorithm, PsfFluxControl,
51 PsfFluxTransform, ScaledApertureFluxAlgorithm,
52 ScaledApertureFluxControl,
53 ScaledApertureFluxTransform, SdssCentroidAlgorithm,
54 SdssCentroidControl, SdssCentroidTransform,
55 SdssShapeAlgorithm, SdssShapeControl,
58from .baseMeasurement
import BaseMeasurementPluginConfig
59from .forcedMeasurement
import ForcedPlugin, ForcedPluginConfig
60from .pluginRegistry
import register
61from .pluginsBase
import BasePlugin
62from .sfm
import SingleFramePlugin, SingleFramePluginConfig
63from .transforms
import SimpleCentroidTransform
64from .wrappers
import GenericPlugin, wrapSimpleAlgorithm, wrapTransform
67 "SingleFrameFPPositionConfig",
"SingleFrameFPPositionPlugin",
68 "SingleFrameJacobianConfig",
"SingleFrameJacobianPlugin",
69 "VarianceConfig",
"SingleFrameVariancePlugin",
"ForcedVariancePlugin",
70 "InputCountConfig",
"SingleFrameInputCountPlugin",
"ForcedInputCountPlugin",
71 "SingleFramePeakCentroidConfig",
"SingleFramePeakCentroidPlugin",
72 "SingleFrameSkyCoordConfig",
"SingleFrameSkyCoordPlugin",
73 "SingleFrameMomentsClassifierConfig",
"SingleFrameMomentsClassifierPlugin",
74 "SingleFrameClassificationSizeExtendednessConfig",
75 "SingleFrameClassificationSizeExtendednessPlugin",
76 "ForcedPeakCentroidConfig",
"ForcedPeakCentroidPlugin",
77 "ForcedTransformedCentroidConfig",
"ForcedTransformedCentroidPlugin",
78 "ForcedTransformedCentroidFromCoordConfig",
79 "ForcedTransformedCentroidFromCoordPlugin",
80 "ForcedTransformedShapeConfig",
"ForcedTransformedShapePlugin",
81 "EvaluateLocalPhotoCalibPlugin",
"EvaluateLocalPhotoCalibPluginConfig",
82 "EvaluateLocalWcsPlugin",
"EvaluateLocalWcsPluginConfig",
86wrapSimpleAlgorithm(PsfFluxAlgorithm, Control=PsfFluxControl,
87 TransformClass=PsfFluxTransform, executionOrder=BasePlugin.FLUX_ORDER,
88 shouldApCorr=
True, hasLogName=
True)
89wrapSimpleAlgorithm(PeakLikelihoodFluxAlgorithm, Control=PeakLikelihoodFluxControl,
90 TransformClass=PeakLikelihoodFluxTransform, executionOrder=BasePlugin.FLUX_ORDER)
91wrapSimpleAlgorithm(GaussianFluxAlgorithm, Control=GaussianFluxControl,
92 TransformClass=GaussianFluxTransform, executionOrder=BasePlugin.FLUX_ORDER,
95wrapSimpleAlgorithm(NaiveCentroidAlgorithm, Control=NaiveCentroidControl,
96 TransformClass=NaiveCentroidTransform, executionOrder=BasePlugin.CENTROID_ORDER,
97 deprecated=
"Plugin 'NaiveCentroid' is deprecated and will be removed after v27.")
98wrapSimpleAlgorithm(SdssCentroidAlgorithm, Control=SdssCentroidControl,
99 TransformClass=SdssCentroidTransform, executionOrder=BasePlugin.CENTROID_ORDER)
100wrapSimpleAlgorithm(PixelFlagsAlgorithm, Control=PixelFlagsControl,
101 executionOrder=BasePlugin.FLUX_ORDER)
102wrapSimpleAlgorithm(SdssShapeAlgorithm, Control=SdssShapeControl,
103 TransformClass=SdssShapeTransform, executionOrder=BasePlugin.SHAPE_ORDER)
104wrapSimpleAlgorithm(ScaledApertureFluxAlgorithm, Control=ScaledApertureFluxControl,
105 TransformClass=ScaledApertureFluxTransform, executionOrder=BasePlugin.FLUX_ORDER)
107wrapSimpleAlgorithm(CircularApertureFluxAlgorithm, needsMetadata=
True, Control=ApertureFluxControl,
108 TransformClass=ApertureFluxTransform, executionOrder=BasePlugin.FLUX_ORDER)
109wrapSimpleAlgorithm(BlendednessAlgorithm, Control=BlendednessControl,
110 TransformClass=BaseTransform, executionOrder=BasePlugin.SHAPE_ORDER)
112wrapSimpleAlgorithm(LocalBackgroundAlgorithm, Control=LocalBackgroundControl,
113 TransformClass=LocalBackgroundTransform, executionOrder=BasePlugin.FLUX_ORDER)
115wrapTransform(PsfFluxTransform)
116wrapTransform(PeakLikelihoodFluxTransform)
117wrapTransform(GaussianFluxTransform)
119wrapTransform(NaiveCentroidTransform)
120wrapTransform(SdssCentroidTransform)
121wrapTransform(SdssShapeTransform)
122wrapTransform(ScaledApertureFluxTransform)
123wrapTransform(ApertureFluxTransform)
124wrapTransform(LocalBackgroundTransform)
126log = logging.getLogger(__name__)
130 """Configuration for the focal plane position measurment algorithm.
134@register(
"base_FPPosition")
136 """Algorithm to calculate the position of a centroid on the focal plane.
140 config : `SingleFrameFPPositionConfig`
144 schema : `lsst.afw.table.Schema`
145 The schema for the measurement output catalog. New fields will be
146 added to hold measurements produced by this plugin.
147 metadata : `lsst.daf.base.PropertySet`
148 Plugin metadata that will be attached to the output catalog
151 ConfigClass = SingleFrameFPPositionConfig
157 def __init__(self, config, name, schema, metadata):
158 SingleFramePlugin.__init__(self, config, name, schema, metadata)
159 self.
focalValue = lsst.afw.table.Point2DKey.addFields(schema, name,
"Position on the focal plane",
161 self.
focalFlag = schema.addField(name +
"_flag", type=
"Flag", doc=
"Set to True for any fatal failure")
162 self.
detectorFlag = schema.addField(name +
"_missingDetector_flag", type=
"Flag",
163 doc=
"Set to True if detector object is missing")
166 det = exposure.getDetector()
171 center = measRecord.getCentroid()
172 fp = det.transform(center, lsst.afw.cameraGeom.PIXELS, lsst.afw.cameraGeom.FOCAL_PLANE)
175 def fail(self, measRecord, error=None):
180 """Configuration for the Jacobian calculation plugin.
183 pixelScale = lsst.pex.config.Field(dtype=float, default=0.5, doc=
"Nominal pixel size (arcsec)")
186@register("base_Jacobian")
188 """Compute the Jacobian and its ratio with a nominal pixel area.
190 This enables one to compare relative, rather than absolute, pixel areas.
194 config : `SingleFrameJacobianConfig`
198 schema : `lsst.afw.table.Schema`
199 The schema for the measurement output catalog. New fields will be
200 added to hold measurements produced by this plugin.
201 metadata : `lsst.daf.base.PropertySet`
202 Plugin metadata that will be attached to the output catalog
205 ConfigClass = SingleFrameJacobianConfig
211 def __init__(self, config, name, schema, metadata):
212 SingleFramePlugin.__init__(self, config, name, schema, metadata)
213 self.
jacValue = schema.addField(name +
'_value', type=
"D", doc=
"Jacobian correction")
214 self.
jacFlag = schema.addField(name +
'_flag', type=
"Flag", doc=
"Set to 1 for any fatal failure")
220 center = measRecord.getCentroid()
223 result = np.abs(self.
scale*exposure.getWcs().linearizePixelToSky(
225 lsst.geom.arcseconds).getLinear().computeDeterminant())
226 measRecord.set(self.
jacValue, result)
228 def fail(self, measRecord, error=None):
229 measRecord.set(self.
jacFlag,
True)
233 """Configuration for the variance calculation plugin.
235 scale = lsst.pex.config.Field(dtype=float, default=5.0, optional=
True,
236 doc=
"Scale factor to apply to shape for aperture")
237 mask = lsst.pex.config.ListField(doc=
"Mask planes to ignore", dtype=str,
238 default=[
"DETECTED",
"DETECTED_NEGATIVE",
"BAD",
"SAT"])
242 """Compute the median variance corresponding to a footprint.
244 The aim here is to measure the background variance, rather than that of
245 the object itself. In order to achieve this, the variance is calculated
246 over an area scaled up from the shape of the input footprint.
250 config : `VarianceConfig`
254 schema : `lsst.afw.table.Schema`
255 The schema for the measurement output catalog. New fields will be
256 added to hold measurements produced by this plugin.
257 metadata : `lsst.daf.base.PropertySet`
258 Plugin metadata that will be attached to the output catalog
261 ConfigClass = VarianceConfig
263 FAILURE_BAD_CENTROID = 1
264 """Denotes failures due to bad centroiding (`int`).
267 FAILURE_EMPTY_FOOTPRINT = 2
268 """Denotes failures due to a lack of usable pixels (`int`).
273 return BasePlugin.FLUX_ORDER
275 def __init__(self, config, name, schema, metadata):
276 GenericPlugin.__init__(self, config, name, schema, metadata)
277 self.
varValue = schema.addField(name +
'_value', type=
"D", doc=
"Variance at object position")
279 doc=
"Set to True when the footprint has no usable pixels")
284 schema.getAliasMap().set(name +
'_flag_badCentroid', schema.getAliasMap().apply(
"slot_Centroid_flag"))
286 def measure(self, measRecord, exposure, center):
290 if not np.all(np.isfinite(measRecord.getCentroid())):
292 aperture = lsst.afw.geom.Ellipse(measRecord.getShape(), measRecord.getCentroid())
293 aperture.scale(self.
config.scale)
296 foot.clipTo(exposure.getBBox(lsst.afw.image.PARENT))
299 maskedImage = exposure.getMaskedImage()
301 maskBits = maskedImage.getMask().getPlaneBitMask(self.
config.mask)
302 logicalMask = np.logical_not(pixels.getMaskArray() & maskBits)
307 if np.any(logicalMask):
308 medVar = np.median(pixels.getVarianceArray()[logicalMask])
309 measRecord.set(self.
varValue, medVar)
311 raise MeasurementError(
"Footprint empty, or all pixels are masked, can't compute median",
314 def fail(self, measRecord, error=None):
317 if isinstance(error, MeasurementError):
322 measRecord.set(self.
varValue, np.nan)
323 GenericPlugin.fail(self, measRecord, error)
326SingleFrameVariancePlugin = VariancePlugin.makeSingleFramePlugin(
"base_Variance")
327"""Single-frame version of `VariancePlugin`.
330ForcedVariancePlugin = VariancePlugin.makeForcedPlugin(
"base_Variance")
331"""Forced version of `VariancePlugin`.
336 """Configuration for the input image counting plugin.
340class InputCountPlugin(GenericPlugin):
341 """Count the number of input images which contributed to a source.
345 config : `InputCountConfig`
346 Plugin configuration.
349 schema : `lsst.afw.table.Schema`
350 The schema for the measurement output catalog. New fields will be
351 added to hold measurements produced by this plugin.
352 metadata : `lsst.daf.base.PropertySet`
353 Plugin metadata that will be attached to the output catalog
357 Information is derived from the image's `~lsst.afw.image.CoaddInputs`.
358 Note these limitation:
360 - This records the number of images which contributed to the pixel in the
361 center of the source footprint, rather than to any or all pixels in the
363 - Clipping in the coadd is not taken into account.
366 ConfigClass = InputCountConfig
368 FAILURE_BAD_CENTROID = 1
369 """Denotes failures due to bad centroiding (`int`).
372 FAILURE_NO_INPUTS = 2
373 """Denotes failures due to the image not having coadd inputs. (`int`)
378 return BasePlugin.SHAPE_ORDER
380 def __init__(self, config, name, schema, metadata):
381 GenericPlugin.__init__(self, config, name, schema, metadata)
382 self.
numberKey = schema.addField(name +
'_value', type=
"I",
383 doc=
"Number of images contributing at center, not including any"
385 self.
noInputsFlag = schema.addField(name +
'_flag_noInputs', type=
"Flag",
386 doc=
"No coadd inputs available")
390 schema.getAliasMap().set(name +
'_flag_badCentroid', schema.getAliasMap().apply(
"slot_Centroid_flag"))
392 def measure(self, measRecord, exposure, center):
393 if not exposure.getInfo().getCoaddInputs():
395 if not np.all(np.isfinite(center)):
398 ccds = exposure.getInfo().getCoaddInputs().ccds
399 measRecord.set(self.
numberKey, len(ccds.subsetContaining(center, exposure.getWcs())))
401 def fail(self, measRecord, error=None):
402 if error
is not None:
407 GenericPlugin.fail(self, measRecord, error)
410SingleFrameInputCountPlugin = InputCountPlugin.makeSingleFramePlugin(
"base_InputCount")
411"""Single-frame version of `InputCoutPlugin`.
414ForcedInputCountPlugin = InputCountPlugin.makeForcedPlugin(
"base_InputCount")
415"""Forced version of `InputCoutPlugin`.
420 """Configuration for the variance calculation plugin.
424class EvaluateLocalPhotoCalibPlugin(GenericPlugin):
425 """Evaluate the local value of the Photometric Calibration in the exposure.
427 The aim is to store the local calib value within the catalog for later
428 use in the Science Data Model functors.
430 ConfigClass = EvaluateLocalPhotoCalibPluginConfig
434 return BasePlugin.FLUX_ORDER
436 def __init__(self, config, name, schema, metadata):
437 GenericPlugin.__init__(self, config, name, schema, metadata)
441 doc=
"Local approximation of the PhotoCalib calibration factor at "
442 "the location of the src.")
446 doc=
"Error on the local approximation of the PhotoCalib "
447 "calibration factor at the location of the src.")
449 def measure(self, measRecord, exposure, center):
450 photoCalib = exposure.getPhotoCalib()
451 if photoCalib
is None:
453 "%s: photoCalib is None. Setting localPhotoCalib to NaN for record %d",
461 calib = photoCalib.getLocalCalibration(center)
462 calibErr = photoCalib.getCalibrationErr()
463 measRecord.set(self.
photoKey, calib)
467SingleFrameEvaluateLocalPhotoCalibPlugin = EvaluateLocalPhotoCalibPlugin.makeSingleFramePlugin(
468 "base_LocalPhotoCalib")
469"""Single-frame version of `EvaluatePhotoCalibPlugin`.
472ForcedEvaluateLocalPhotoCalibPlugin = EvaluateLocalPhotoCalibPlugin.makeForcedPlugin(
473 "base_LocalPhotoCalib")
474"""Forced version of `EvaluatePhotoCalibPlugin`.
479 """Configuration for the variance calculation plugin.
483class EvaluateLocalWcsPlugin(GenericPlugin):
484 """Evaluate the local, linear approximation of the Wcs.
486 The aim is to store the local calib value within the catalog for later
487 use in the Science Data Model functors.
489 ConfigClass = EvaluateLocalWcsPluginConfig
490 _scale = (1.0 * lsst.geom.arcseconds).asDegrees()
494 return BasePlugin.FLUX_ORDER
496 def __init__(self, config, name, schema, metadata):
497 GenericPlugin.__init__(self, config, name, schema, metadata)
499 f
"{name}_CDMatrix_1_1",
501 doc=
"(1, 1) element of the CDMatrix for the linear approximation "
502 "of the WCS at the src location. Gives units in radians.")
504 f
"{name}_CDMatrix_1_2",
506 doc=
"(1, 2) element of the CDMatrix for the linear approximation "
507 "of the WCS at the src location. Gives units in radians.")
509 f
"{name}_CDMatrix_2_1",
511 doc=
"(2, 1) element of the CDMatrix for the linear approximation "
512 "of the WCS at the src location. Gives units in radians.")
514 f
"{name}_CDMatrix_2_2",
516 doc=
"(2, 2) element of the CDMatrix for the linear approximation "
517 "of the WCS at the src location. Gives units in radians.")
519 def measure(self, measRecord, exposure, center):
520 wcs = exposure.getWcs()
523 "%s: WCS is None. Setting localWcs matrix values to NaN for record %d",
527 localMatrix = np.array([[np.nan, np.nan], [np.nan, np.nan]])
537 """Create a local, linear approximation of the wcs transformation
540 The approximation is created as if the center is at RA=0, DEC=0. All
541 comparing x,y coordinate are relative to the position of center. Matrix
542 is initially calculated with units arcseconds and then converted to
543 radians. This yields higher precision results due to quirks in AST.
547 wcs : `lsst.afw.geom.SkyWcs`
549 center : `lsst.geom.Point2D`
550 Point at which to evaluate the LocalWcs.
554 localMatrix : `numpy.ndarray`
555 Matrix representation the local wcs approximation with units
558 skyCenter = wcs.pixelToSky(center)
561 measurementToLocalGnomonic = wcs.getTransform().then(
562 localGnomonicWcs.getTransform().inverted()
564 localMatrix = measurementToLocalGnomonic.getJacobian(center)
565 return np.radians(localMatrix / 3600)
568SingleFrameEvaluateLocalWcsPlugin = EvaluateLocalWcsPlugin.makeSingleFramePlugin(
"base_LocalWcs")
569"""Single-frame version of `EvaluateLocalWcsPlugin`.
572ForcedEvaluateLocalWcsPlugin = EvaluateLocalWcsPlugin.makeForcedPlugin(
"base_LocalWcs")
573"""Forced version of `EvaluateLocalWcsPlugin`.
578 """Configuration for the single frame peak centroiding algorithm.
582@register(
"base_PeakCentroid")
584 """Record the highest peak in a source footprint as its centroid.
586 This is of course a relatively poor measure of the true centroid of the
587 object; this algorithm is provided mostly for testing and debugging.
591 config : `SingleFramePeakCentroidConfig`
595 schema : `lsst.afw.table.Schema`
596 The schema for the measurement output catalog. New fields will be
597 added to hold measurements produced by this plugin.
598 metadata : `lsst.daf.base.PropertySet`
599 Plugin metadata that will be attached to the output catalog
602 ConfigClass = SingleFramePeakCentroidConfig
608 def __init__(self, config, name, schema, metadata):
609 SingleFramePlugin.__init__(self, config, name, schema, metadata)
610 self.
keyX = schema.addField(name +
"_x", type=
"D", doc=
"peak centroid", units=
"pixel")
611 self.
keyY = schema.addField(name +
"_y", type=
"D", doc=
"peak centroid", units=
"pixel")
612 self.
flag = schema.addField(name +
"_flag", type=
"Flag", doc=
"Centroiding failed")
615 peak = measRecord.getFootprint().getPeaks()[0]
616 measRecord.set(self.
keyX, peak.getFx())
617 measRecord.set(self.
keyY, peak.getFy())
619 def fail(self, measRecord, error=None):
620 measRecord.set(self.
flag,
True)
624 return SimpleCentroidTransform
628 """Configuration for the sky coordinates algorithm.
632@register(
"base_SkyCoord")
634 """Record the sky position of an object based on its centroid slot and WCS.
636 The position is record in the ``coord`` field, which is part of the
637 `~lsst.afw.table.SourceCatalog` minimal schema.
641 config : `SingleFrameSkyCoordConfig`
645 schema : `lsst.afw.table.Schema`
646 The schema for the measurement output catalog. New fields will be
647 added to hold measurements produced by this plugin.
648 metadata : `lsst.daf.base.PropertySet`
649 Plugin metadata that will be attached to the output catalog
652 ConfigClass = SingleFrameSkyCoordConfig
662 if not exposure.hasWcs():
663 raise RuntimeError(
"Wcs not attached to exposure. Required for " + self.
name +
" algorithm")
664 measRecord.updateCoord(exposure.getWcs())
666 def fail(self, measRecord, error=None):
674class SingleFrameClassificationSizeExtendednessConfig(SingleFramePluginConfig):
675 """Configuration for moments-based star-galaxy classifier."""
677 exponent = lsst.pex.config.Field[float](
678 doc=
"Exponent to raise the PSF size squared (Ixx + Iyy) to, "
679 "in the likelihood normalization",
684@register("base_ClassificationSizeExtendedness")
686 """Classify objects by comparing their moments-based trace radius to PSF's.
688 The plugin computes chi^2 as ((T_obj - T_psf)/T_psf^exponent)^2, where
689 T_obj is the sum of Ixx and Iyy moments of the object, and T_psf is the
690 sum of Ixx and Iyy moments of the PSF. The exponent is configurable.
691 The measure of being a galaxy is then 1 - exp(-0.5*chi^2).
695 config : `SingleFrameClassificationSizeExtendednessConfig`
696 Plugin configuration.
699 schema : `~lsst.afw.table.Schema`
700 The schema for the measurement output catalog. New fields will be
701 added to hold measurements produced by this plugin.
702 metadata : `~lsst.daf.base.PropertySet`
703 Plugin metadata that will be attached to the output catalog.
707 The ``measure`` method of the plugin requires a value for the ``exposure``
708 argument to maintain consistent API, but it is not used in the measurement.
711 ConfigClass = SingleFrameClassificationSizeExtendednessConfig
713 FAILURE_BAD_SHAPE = 1
714 """Denotes failures due to bad shape (`int`).
721 def __init__(self, config, name, schema, metadata):
722 SingleFramePlugin.__init__(self, config, name, schema, metadata)
723 self.
key = schema.addField(name +
"_value",
725 doc=
"Measure of being a galaxy based on trace of second order moments",
727 self.
flag = schema.addField(name +
"_flag", type=
"Flag", doc=
"Moments-based classification failed")
729 def measure(self, measRecord, exposure) -> None:
732 if measRecord.getShapeFlag():
733 raise MeasurementError(
734 "Shape flag is set. Required for " + self.
name +
" algorithm",
738 shape = measRecord.getShape()
739 psf_shape = measRecord.getPsfShape()
743 ixx_psf = psf_shape.getIxx()
744 iyy_psf = psf_shape.getIyy()
747 psf_t = ixx_psf + iyy_psf
749 chi_sq = ((object_t - psf_t)/(psf_t**self.
config.exponent))**2.
750 likelihood = 1. - np.exp(-0.5*chi_sq)
751 measRecord.set(self.
key, likelihood)
753 def fail(self, measRecord, error=None) -> None:
755 measRecord.set(self.
key, np.nan)
756 measRecord.set(self.
flag,
True)
759@deprecated(reason=
"Use SingleFrameClassificationSizeExtendednessConfig instead", version=
"v29.0.0",
760 category=FutureWarning)
765@deprecated(reason=
"Use SingleFrameClassificationSizeExtendednessPlugin instead", version=
"v29.0.0",
766 category=FutureWarning)
768 ConfigClass = SingleFrameMomentsClassifierConfig
772 """Configuration for the forced peak centroid algorithm.
776@register(
"base_PeakCentroid")
778 """Record the highest peak in a source footprint as its centroid.
780 This is of course a relatively poor measure of the true centroid of the
781 object; this algorithm is provided mostly for testing and debugging.
783 This is similar to `SingleFramePeakCentroidPlugin`, except that transforms
784 the peak coordinate from the original (reference) coordinate system to the
785 coordinate system of the exposure being measured.
789 config : `ForcedPeakCentroidConfig`
793 schemaMapper : `lsst.afw.table.SchemaMapper`
794 A mapping from reference catalog fields to output
795 catalog fields. Output fields are added to the output schema.
796 metadata : `lsst.daf.base.PropertySet`
797 Plugin metadata that will be attached to the output catalog.
800 ConfigClass = ForcedPeakCentroidConfig
806 def __init__(self, config, name, schemaMapper, metadata):
807 ForcedPlugin.__init__(self, config, name, schemaMapper, metadata)
808 schema = schemaMapper.editOutputSchema()
809 self.
keyX = schema.addField(name +
"_x", type=
"D", doc=
"peak centroid", units=
"pixel")
810 self.
keyY = schema.addField(name +
"_y", type=
"D", doc=
"peak centroid", units=
"pixel")
812 def measure(self, measRecord, exposure, refRecord, refWcs):
813 targetWcs = exposure.getWcs()
814 peak = refRecord.getFootprint().getPeaks()[0]
816 result = targetWcs.skyToPixel(refWcs.pixelToSky(result))
817 measRecord.set(self.
keyX, result.getX())
818 measRecord.set(self.
keyY, result.getY())
822 return SimpleCentroidTransform
826 """Configuration for the forced transformed centroid algorithm.
830@register(
"base_TransformedCentroid")
832 """Record the transformation of the reference catalog centroid.
834 The centroid recorded in the reference catalog is tranformed to the
835 measurement coordinate system and stored.
839 config : `ForcedTransformedCentroidConfig`
843 schemaMapper : `lsst.afw.table.SchemaMapper`
844 A mapping from reference catalog fields to output
845 catalog fields. Output fields are added to the output schema.
846 metadata : `lsst.daf.base.PropertySet`
847 Plugin metadata that will be attached to the output catalog.
851 This is used as the slot centroid by default in forced measurement,
852 allowing subsequent measurements to simply refer to the slot value just as
853 they would in single-frame measurement.
856 ConfigClass = ForcedTransformedCentroidConfig
862 def __init__(self, config, name, schemaMapper, metadata):
863 ForcedPlugin.__init__(self, config, name, schemaMapper, metadata)
864 schema = schemaMapper.editOutputSchema()
867 xKey = schema.addField(name +
"_x", type=
"D", doc=
"transformed reference centroid column",
869 yKey = schema.addField(name +
"_y", type=
"D", doc=
"transformed reference centroid row",
875 if "slot_Centroid_flag" in schemaMapper.getInputSchema():
876 self.
flagKey = schema.addField(name +
"_flag", type=
"Flag",
877 doc=
"whether the reference centroid is marked as bad")
881 def measure(self, measRecord, exposure, refRecord, refWcs):
882 targetWcs = exposure.getWcs()
883 if not refWcs == targetWcs:
884 targetPos = targetWcs.skyToPixel(refWcs.pixelToSky(refRecord.getCentroid()))
887 measRecord.set(self.
centroidKey, refRecord.getCentroid())
889 measRecord.set(self.
flagKey, refRecord.getCentroidFlag())
893 """Configuration for the forced transformed coord algorithm.
897@register(
"base_TransformedCentroidFromCoord")
899 """Record the transformation of the reference catalog coord.
901 The coord recorded in the reference catalog is tranformed to the
902 measurement coordinate system and stored.
906 config : `ForcedTransformedCentroidFromCoordConfig`
910 schemaMapper : `lsst.afw.table.SchemaMapper`
911 A mapping from reference catalog fields to output
912 catalog fields. Output fields are added to the output schema.
913 metadata : `lsst.daf.base.PropertySet`
914 Plugin metadata that will be attached to the output catalog.
918 This can be used as the slot centroid in forced measurement when only a
919 reference coord exist, allowing subsequent measurements to simply refer to
920 the slot value just as they would in single-frame measurement.
923 ConfigClass = ForcedTransformedCentroidFromCoordConfig
925 def measure(self, measRecord, exposure, refRecord, refWcs):
926 targetWcs = exposure.getWcs()
928 targetPos = targetWcs.skyToPixel(refRecord.getCoord())
936 """Configuration for the forced transformed shape algorithm.
940@register(
"base_TransformedShape")
942 """Record the transformation of the reference catalog shape.
944 The shape recorded in the reference catalog is tranformed to the
945 measurement coordinate system and stored.
949 config : `ForcedTransformedShapeConfig`
953 schemaMapper : `lsst.afw.table.SchemaMapper`
954 A mapping from reference catalog fields to output
955 catalog fields. Output fields are added to the output schema.
956 metadata : `lsst.daf.base.PropertySet`
957 Plugin metadata that will be attached to the output catalog.
961 This is used as the slot shape by default in forced measurement, allowing
962 subsequent measurements to simply refer to the slot value just as they
963 would in single-frame measurement.
966 ConfigClass = ForcedTransformedShapeConfig
972 def __init__(self, config, name, schemaMapper, metadata):
973 ForcedPlugin.__init__(self, config, name, schemaMapper, metadata)
974 schema = schemaMapper.editOutputSchema()
977 xxKey = schema.addField(name +
"_xx", type=
"D", doc=
"transformed reference shape x^2 moment",
979 yyKey = schema.addField(name +
"_yy", type=
"D", doc=
"transformed reference shape y^2 moment",
981 xyKey = schema.addField(name +
"_xy", type=
"D", doc=
"transformed reference shape xy moment",
987 if "slot_Shape_flag" in schemaMapper.getInputSchema():
988 self.
flagKey = schema.addField(name +
"_flag", type=
"Flag",
989 doc=
"whether the reference shape is marked as bad")
993 def measure(self, measRecord, exposure, refRecord, refWcs):
994 targetWcs = exposure.getWcs()
995 if not refWcs == targetWcs:
998 measRecord.set(self.
shapeKey, refRecord.getShape().transform(localTransform.getLinear()))
1000 measRecord.set(self.
shapeKey, refRecord.getShape())
1002 measRecord.set(self.
flagKey, refRecord.getShapeFlag())
static std::shared_ptr< geom::SpanSet > fromShape(int r, Stencil s=Stencil::CIRCLE, lsst::geom::Point2I offset=lsst::geom::Point2I())
__init__(self, config, name, schema, metadata)
measure(self, measRecord, exposure, center)
__init__(self, config, name, schema, metadata)
measure(self, measRecord, exposure, center)
makeLocalTransformMatrix(self, wcs, center)
measure(self, measRecord, exposure, refRecord, refWcs)
__init__(self, config, name, schemaMapper, metadata)
None fail(self, measRecord, error=None)
__init__(self, config, name, schema, metadata)
None measure(self, measRecord, exposure)
fail(self, measRecord, error=None)
measure(self, measRecord, exposure)
__init__(self, config, name, schema, metadata)
measure(self, measRecord, exposure)
fail(self, measRecord, error=None)
__init__(self, config, name, schema, metadata)
fail(self, measRecord, error=None)
__init__(self, config, name, schema, metadata)
measure(self, measRecord, exposure)
fail(self, measRecord, error=None)
measure(self, measRecord, exposure)
int FAILURE_EMPTY_FOOTPRINT
__init__(self, config, name, schema, metadata)
fail(self, measRecord, error=None)
measure(self, measRecord, exposure, center)
HeavyFootprint< ImagePixelT, MaskPixelT, VariancePixelT > makeHeavyFootprint(Footprint const &foot, lsst::afw::image::MaskedImage< ImagePixelT, MaskPixelT, VariancePixelT > const &img, HeavyFootprintCtrl const *ctrl=nullptr)
std::shared_ptr< SkyWcs > makeSkyWcs(daf::base::PropertySet &metadata, bool strip=false)
std::shared_ptr< TransformPoint2ToPoint2 > makeWcsPairTransform(SkyWcs const &src, SkyWcs const &dst)
lsst::geom::AffineTransform linearizeTransform(TransformPoint2ToPoint2 const &original, lsst::geom::Point2D const &inPoint)