22 """Definition of measurement plugins.
24 This module defines and registers a series of pure-Python measurement plugins
25 which have trivial implementations. It also wraps measurement algorithms
26 defined in C++ to expose them to the measurement framework.
36 from .pluginRegistry
import register
37 from .pluginsBase
import BasePlugin
38 from .baseMeasurement
import BaseMeasurementPluginConfig
39 from .sfm
import SingleFramePluginConfig, SingleFramePlugin
40 from .forcedMeasurement
import ForcedPluginConfig, ForcedPlugin
41 from .wrappers
import wrapSimpleAlgorithm, wrapTransform, GenericPlugin
42 from .transforms
import SimpleCentroidTransform
44 from .apertureFlux
import ApertureFluxControl, ApertureFluxTransform
45 from .transform
import BaseTransform
46 from .blendedness
import BlendednessAlgorithm, BlendednessControl
47 from .circularApertureFlux
import CircularApertureFluxAlgorithm
48 from .gaussianFlux
import GaussianFluxAlgorithm, GaussianFluxControl, GaussianFluxTransform
49 from .exceptions
import MeasurementError
50 from .localBackground
import LocalBackgroundControl, LocalBackgroundAlgorithm, LocalBackgroundTransform
51 from .naiveCentroid
import NaiveCentroidAlgorithm, NaiveCentroidControl, NaiveCentroidTransform
52 from .peakLikelihoodFlux
import PeakLikelihoodFluxAlgorithm, PeakLikelihoodFluxControl, \
53 PeakLikelihoodFluxTransform
54 from .pixelFlags
import PixelFlagsAlgorithm, PixelFlagsControl
55 from .psfFlux
import PsfFluxAlgorithm, PsfFluxControl, PsfFluxTransform
56 from .scaledApertureFlux
import ScaledApertureFluxAlgorithm, ScaledApertureFluxControl, \
57 ScaledApertureFluxTransform
58 from .sdssCentroid
import SdssCentroidAlgorithm, SdssCentroidControl, SdssCentroidTransform
59 from .sdssShape
import SdssShapeAlgorithm, SdssShapeControl, SdssShapeTransform
62 "SingleFrameFPPositionConfig",
"SingleFrameFPPositionPlugin",
63 "SingleFrameJacobianConfig",
"SingleFrameJacobianPlugin",
64 "VarianceConfig",
"SingleFrameVariancePlugin",
"ForcedVariancePlugin",
65 "InputCountConfig",
"SingleFrameInputCountPlugin",
"ForcedInputCountPlugin",
66 "SingleFramePeakCentroidConfig",
"SingleFramePeakCentroidPlugin",
67 "SingleFrameSkyCoordConfig",
"SingleFrameSkyCoordPlugin",
68 "ForcedPeakCentroidConfig",
"ForcedPeakCentroidPlugin",
69 "ForcedTransformedCentroidConfig",
"ForcedTransformedCentroidPlugin",
70 "ForcedTransformedCentroidFromCoordConfig",
71 "ForcedTransformedCentroidFromCoordPlugin",
72 "ForcedTransformedShapeConfig",
"ForcedTransformedShapePlugin",
73 "EvaluateLocalPhotoCalibPlugin",
"EvaluateLocalPhotoCalibPluginConfig",
74 "EvaluateLocalWcsPlugin",
"EvaluateLocalWcsPluginConfig",
79 TransformClass=PsfFluxTransform, executionOrder=BasePlugin.FLUX_ORDER,
80 shouldApCorr=
True, hasLogName=
True)
82 TransformClass=PeakLikelihoodFluxTransform, executionOrder=BasePlugin.FLUX_ORDER)
84 TransformClass=GaussianFluxTransform, executionOrder=BasePlugin.FLUX_ORDER,
87 TransformClass=NaiveCentroidTransform, executionOrder=BasePlugin.CENTROID_ORDER)
89 TransformClass=SdssCentroidTransform, executionOrder=BasePlugin.CENTROID_ORDER)
91 executionOrder=BasePlugin.FLUX_ORDER)
93 TransformClass=SdssShapeTransform, executionOrder=BasePlugin.SHAPE_ORDER)
95 TransformClass=ScaledApertureFluxTransform, executionOrder=BasePlugin.FLUX_ORDER)
98 TransformClass=ApertureFluxTransform, executionOrder=BasePlugin.FLUX_ORDER)
100 TransformClass=BaseTransform, executionOrder=BasePlugin.SHAPE_ORDER)
103 TransformClass=LocalBackgroundTransform, executionOrder=BasePlugin.FLUX_ORDER)
117 """Configuration for the focal plane position measurment algorithm.
125 """Algorithm to calculate the position of a centroid on the focal plane.
129 config : `SingleFrameFPPositionConfig`
133 schema : `lsst.afw.table.Schema`
134 The schema for the measurement output catalog. New fields will be
135 added to hold measurements produced by this plugin.
136 metadata : `lsst.daf.base.PropertySet`
137 Plugin metadata that will be attached to the output catalog
140 ConfigClass = SingleFrameFPPositionConfig
146 def __init__(self, config, name, schema, metadata):
147 SingleFramePlugin.__init__(self, config, name, schema, metadata)
148 self.
focalValuefocalValue = lsst.afw.table.Point2DKey.addFields(schema, name,
"Position on the focal plane",
150 self.
focalFlagfocalFlag = schema.addField(name +
"_flag", type=
"Flag", doc=
"Set to True for any fatal failure")
151 self.
detectorFlagdetectorFlag = schema.addField(name +
"_missingDetector_flag", type=
"Flag",
152 doc=
"Set to True if detector object is missing")
155 det = exposure.getDetector()
160 center = measRecord.getCentroid()
161 fp = det.transform(center, lsst.afw.cameraGeom.PIXELS, lsst.afw.cameraGeom.FOCAL_PLANE)
164 def fail(self, measRecord, error=None):
165 measRecord.set(self.
focalFlagfocalFlag,
True)
169 """Configuration for the Jacobian calculation plugin.
175 @register("base_Jacobian")
177 """Compute the Jacobian and its ratio with a nominal pixel area.
179 This enables one to compare relative, rather than absolute, pixel areas.
183 config : `SingleFrameJacobianConfig`
187 schema : `lsst.afw.table.Schema`
188 The schema for the measurement output catalog. New fields will be
189 added to hold measurements produced by this plugin.
190 metadata : `lsst.daf.base.PropertySet`
191 Plugin metadata that will be attached to the output catalog
194 ConfigClass = SingleFrameJacobianConfig
200 def __init__(self, config, name, schema, metadata):
201 SingleFramePlugin.__init__(self, config, name, schema, metadata)
202 self.
jacValuejacValue = schema.addField(name +
'_value', type=
"D", doc=
"Jacobian correction")
203 self.
jacFlagjacFlag = schema.addField(name +
'_flag', type=
"Flag", doc=
"Set to 1 for any fatal failure")
208 center = measRecord.getCentroid()
211 result = np.abs(self.
scalescale*exposure.getWcs().linearizePixelToSky(
213 lsst.geom.arcseconds).getLinear().computeDeterminant())
214 measRecord.set(self.
jacValuejacValue, result)
216 def fail(self, measRecord, error=None):
217 measRecord.set(self.
jacFlagjacFlag,
True)
221 """Configuration for the variance calculation plugin.
224 doc=
"Scale factor to apply to shape for aperture")
226 default=[
"DETECTED",
"DETECTED_NEGATIVE",
"BAD",
"SAT"])
230 """Compute the median variance corresponding to a footprint.
232 The aim here is to measure the background variance, rather than that of
233 the object itself. In order to achieve this, the variance is calculated
234 over an area scaled up from the shape of the input footprint.
238 config : `VarianceConfig`
242 schema : `lsst.afw.table.Schema`
243 The schema for the measurement output catalog. New fields will be
244 added to hold measurements produced by this plugin.
245 metadata : `lsst.daf.base.PropertySet`
246 Plugin metadata that will be attached to the output catalog
249 ConfigClass = VarianceConfig
251 FAILURE_BAD_CENTROID = 1
252 """Denotes failures due to bad centroiding (`int`).
255 FAILURE_EMPTY_FOOTPRINT = 2
256 """Denotes failures due to a lack of usable pixels (`int`).
261 return BasePlugin.FLUX_ORDER
263 def __init__(self, config, name, schema, metadata):
264 GenericPlugin.__init__(self, config, name, schema, metadata)
265 self.
varValuevarValue = schema.addField(name +
'_value', type=
"D", doc=
"Variance at object position")
266 self.
emptyFootprintFlagemptyFootprintFlag = schema.addField(name +
'_flag_emptyFootprint', type=
"Flag",
267 doc=
"Set to True when the footprint has no usable pixels")
272 schema.getAliasMap().
set(name +
'_flag_badCentroid', schema.getAliasMap().apply(
"slot_Centroid_flag"))
274 def measure(self, measRecord, exposure, center):
278 if not np.all(np.isfinite(measRecord.getCentroid())):
279 raise MeasurementError(
"Bad centroid and/or shape", self.
FAILURE_BAD_CENTROIDFAILURE_BAD_CENTROID)
281 aperture.scale(self.
configconfig.scale)
284 foot.clipTo(exposure.getBBox(lsst.afw.image.PARENT))
287 maskedImage = exposure.getMaskedImage()
289 maskBits = maskedImage.getMask().getPlaneBitMask(self.
configconfig.mask)
290 logicalMask = np.logical_not(pixels.getMaskArray() & maskBits)
295 if np.any(logicalMask):
296 medVar = np.median(pixels.getVarianceArray()[logicalMask])
297 measRecord.set(self.
varValuevarValue, medVar)
299 raise MeasurementError(
"Footprint empty, or all pixels are masked, can't compute median",
302 def fail(self, measRecord, error=None):
305 if isinstance(error, MeasurementError):
310 measRecord.set(self.
varValuevarValue, np.nan)
311 GenericPlugin.fail(self, measRecord, error)
314 SingleFrameVariancePlugin = VariancePlugin.makeSingleFramePlugin(
"base_Variance")
315 """Single-frame version of `VariancePlugin`.
318 ForcedVariancePlugin = VariancePlugin.makeForcedPlugin(
"base_Variance")
319 """Forced version of `VariancePlugin`.
324 """Configuration for the input image counting plugin.
329 class InputCountPlugin(GenericPlugin):
330 """Count the number of input images which contributed to a a source.
334 config : `InputCountConfig`
338 schema : `lsst.afw.table.Schema`
339 The schema for the measurement output catalog. New fields will be
340 added to hold measurements produced by this plugin.
341 metadata : `lsst.daf.base.PropertySet`
342 Plugin metadata that will be attached to the output catalog
346 Information is derived from the image's `~lsst.afw.image.CoaddInputs`.
347 Note these limitation:
349 - This records the number of images which contributed to the pixel in the
350 center of the source footprint, rather than to any or all pixels in the
352 - Clipping in the coadd is not taken into account.
355 ConfigClass = InputCountConfig
357 FAILURE_BAD_CENTROID = 1
358 """Denotes failures due to bad centroiding (`int`).
361 FAILURE_NO_INPUTS = 2
362 """Denotes failures due to the image not having coadd inputs. (`int`)
367 return BasePlugin.SHAPE_ORDER
369 def __init__(self, config, name, schema, metadata):
370 GenericPlugin.__init__(self, config, name, schema, metadata)
371 self.
numberKeynumberKey = schema.addField(name +
'_value', type=
"I",
372 doc=
"Number of images contributing at center, not including any"
374 self.
noInputsFlagnoInputsFlag = schema.addField(name +
'_flag_noInputs', type=
"Flag",
375 doc=
"No coadd inputs available")
378 schema.getAliasMap().
set(name +
'_flag_badCentroid', schema.getAliasMap().apply(
"slot_Centroid_flag"))
380 def measure(self, measRecord, exposure, center):
381 if not exposure.getInfo().getCoaddInputs():
382 raise MeasurementError(
"No coadd inputs defined.", self.
FAILURE_NO_INPUTSFAILURE_NO_INPUTS)
383 if not np.all(np.isfinite(center)):
384 raise MeasurementError(
"Source has a bad centroid.", self.
FAILURE_BAD_CENTROIDFAILURE_BAD_CENTROID)
386 ccds = exposure.getInfo().getCoaddInputs().ccds
387 measRecord.set(self.
numberKeynumberKey, len(ccds.subsetContaining(center, exposure.getWcs())))
389 def fail(self, measRecord, error=None):
390 if error
is not None:
395 GenericPlugin.fail(self, measRecord, error)
398 SingleFrameInputCountPlugin = InputCountPlugin.makeSingleFramePlugin(
"base_InputCount")
399 """Single-frame version of `InputCoutPlugin`.
402 ForcedInputCountPlugin = InputCountPlugin.makeForcedPlugin(
"base_InputCount")
403 """Forced version of `InputCoutPlugin`.
408 """Configuration for the variance calculation plugin.
413 class EvaluateLocalPhotoCalibPlugin(GenericPlugin):
414 """Evaluate the local value of the Photometric Calibration in the exposure.
416 The aim is to store the local calib value within the catalog for later
417 use in the Science Data Model functors.
419 ConfigClass = EvaluateLocalPhotoCalibPluginConfig
423 return BasePlugin.FLUX_ORDER
425 def __init__(self, config, name, schema, metadata):
426 GenericPlugin.__init__(self, config, name, schema, metadata)
430 doc=
"Local approximation of the PhotoCalib calibration factor at "
431 "the location of the src.")
435 doc=
"Error on the local approximation of the PhotoCalib "
436 "calibration factor at the location of the src.")
438 def measure(self, measRecord, exposure, center):
440 photoCalib = exposure.getPhotoCalib()
441 calib = photoCalib.getLocalCalibration(center)
442 measRecord.set(self.
photoKeyphotoKey, calib)
444 calibErr = photoCalib.getCalibrationErr()
445 measRecord.set(self.
photoErrKeyphotoErrKey, calibErr)
448 SingleFrameEvaluateLocalPhotoCalibPlugin = EvaluateLocalPhotoCalibPlugin.makeSingleFramePlugin(
449 "base_LocalPhotoCalib")
450 """Single-frame version of `EvaluatePhotoCalibPlugin`.
453 ForcedEvaluateLocalPhotoCalibPlugin = EvaluateLocalPhotoCalibPlugin.makeForcedPlugin(
454 "base_LocalPhotoCalib")
455 """Forced version of `EvaluatePhotoCalibPlugin`.
460 """Configuration for the variance calculation plugin.
465 class EvaluateLocalWcsPlugin(GenericPlugin):
466 """Evaluate the local, linear approximation of the Wcs.
468 The aim is to store the local calib value within the catalog for later
469 use in the Science Data Model functors.
471 ConfigClass = EvaluateLocalWcsPluginConfig
472 _scale = (1.0 * lsst.geom.arcseconds).asDegrees()
476 return BasePlugin.FLUX_ORDER
478 def __init__(self, config, name, schema, metadata):
479 GenericPlugin.__init__(self, config, name, schema, metadata)
481 f
"{name}_CDMatrix_1_1",
483 doc=
"(1, 1) element of the CDMatrix for the linear approximation "
484 "of the WCS at the src location. Gives units in radians.")
486 f
"{name}_CDMatrix_1_2",
488 doc=
"(1, 2) element of the CDMatrix for the linear approximation "
489 "of the WCS at the src location. Gives units in radians.")
491 f
"{name}_CDMatrix_2_1",
493 doc=
"(2, 1) element of the CDMatrix for the linear approximation "
494 "of the WCS at the src location. Gives units in radians.")
496 f
"{name}_CDMatrix_2_2",
498 doc=
"(2, 2) element of the CDMatrix for the linear approximation "
499 "of the WCS at the src location. Gives units in radians.")
501 def measure(self, measRecord, exposure, center):
502 wcs = exposure.getWcs()
504 measRecord.set(self.
cdMatrix11KeycdMatrix11Key, localMatrix[0, 0])
505 measRecord.set(self.
cdMatrix12KeycdMatrix12Key, localMatrix[0, 1])
506 measRecord.set(self.
cdMatrix21KeycdMatrix21Key, localMatrix[1, 0])
507 measRecord.set(self.
cdMatrix22KeycdMatrix22Key, localMatrix[1, 1])
510 """Create a local, linear approximation of the wcs transformation
513 The approximation is created as if the center is at RA=0, DEC=0. All
514 comparing x,y coordinate are relative to the position of center. Matrix
515 is initially calculated with units arcseconds and then converted to
516 radians. This yields higher precision results due to quirks in AST.
520 wcs : `lsst.afw.geom.SkyWcs`
522 center : `lsst.geom.Point2D`
523 Point at which to evaluate the LocalWcs.
527 localMatrix : `numpy.ndarray`
528 Matrix representation the local wcs approximation with units
531 skyCenter = wcs.pixelToSky(center)
533 center, skyCenter, np.diag((self.
_scale_scale, self.
_scale_scale)))
534 measurementToLocalGnomonic = wcs.getTransform().
then(
535 localGnomonicWcs.getTransform().inverted()
537 localMatrix = measurementToLocalGnomonic.getJacobian(center)
538 return np.radians(localMatrix / 3600)
541 SingleFrameEvaluateLocalWcsPlugin = EvaluateLocalWcsPlugin.makeSingleFramePlugin(
"base_LocalWcs")
542 """Single-frame version of `EvaluateLocalWcsPlugin`.
545 ForcedEvaluateLocalWcsPlugin = EvaluateLocalWcsPlugin.makeForcedPlugin(
"base_LocalWcs")
546 """Forced version of `EvaluateLocalWcsPlugin`.
551 """Configuration for the single frame peak centroiding algorithm.
558 """Record the highest peak in a source footprint as its centroid.
560 This is of course a relatively poor measure of the true centroid of the
561 object; this algorithm is provided mostly for testing and debugging.
565 config : `SingleFramePeakCentroidConfig`
569 schema : `lsst.afw.table.Schema`
570 The schema for the measurement output catalog. New fields will be
571 added to hold measurements produced by this plugin.
572 metadata : `lsst.daf.base.PropertySet`
573 Plugin metadata that will be attached to the output catalog
576 ConfigClass = SingleFramePeakCentroidConfig
582 def __init__(self, config, name, schema, metadata):
583 SingleFramePlugin.__init__(self, config, name, schema, metadata)
584 self.
keyXkeyX = schema.addField(name +
"_x", type=
"D", doc=
"peak centroid", units=
"pixel")
585 self.
keyYkeyY = schema.addField(name +
"_y", type=
"D", doc=
"peak centroid", units=
"pixel")
586 self.
flagflag = schema.addField(name +
"_flag", type=
"Flag", doc=
"Centroiding failed")
589 peak = measRecord.getFootprint().getPeaks()[0]
590 measRecord.set(self.
keyXkeyX, peak.getFx())
591 measRecord.set(self.
keyYkeyY, peak.getFy())
593 def fail(self, measRecord, error=None):
594 measRecord.set(self.
flagflag,
True)
598 return SimpleCentroidTransform
602 """Configuration for the sky coordinates algorithm.
609 """Record the sky position of an object based on its centroid slot and WCS.
611 The position is record in the ``coord`` field, which is part of the
612 `~lsst.afw.table.SourceCatalog` minimal schema.
616 config : `SingleFrameSkyCoordConfig`
620 schema : `lsst.afw.table.Schema`
621 The schema for the measurement output catalog. New fields will be
622 added to hold measurements produced by this plugin.
623 metadata : `lsst.daf.base.PropertySet`
624 Plugin metadata that will be attached to the output catalog
627 ConfigClass = SingleFrameSkyCoordConfig
637 if not exposure.hasWcs():
638 raise RuntimeError(
"Wcs not attached to exposure. Required for " + self.
namename +
" algorithm")
639 measRecord.updateCoord(exposure.getWcs())
641 def fail(self, measRecord, error=None):
649 class ForcedPeakCentroidConfig(ForcedPluginConfig):
650 """Configuration for the forced peak centroid algorithm.
657 """Record the highest peak in a source footprint as its centroid.
659 This is of course a relatively poor measure of the true centroid of the
660 object; this algorithm is provided mostly for testing and debugging.
662 This is similar to `SingleFramePeakCentroidPlugin`, except that transforms
663 the peak coordinate from the original (reference) coordinate system to the
664 coordinate system of the exposure being measured.
668 config : `ForcedPeakCentroidConfig`
672 schemaMapper : `lsst.afw.table.SchemaMapper`
673 A mapping from reference catalog fields to output
674 catalog fields. Output fields are added to the output schema.
675 metadata : `lsst.daf.base.PropertySet`
676 Plugin metadata that will be attached to the output catalog.
679 ConfigClass = ForcedPeakCentroidConfig
685 def __init__(self, config, name, schemaMapper, metadata):
686 ForcedPlugin.__init__(self, config, name, schemaMapper, metadata)
687 schema = schemaMapper.editOutputSchema()
688 self.
keyXkeyX = schema.addField(name +
"_x", type=
"D", doc=
"peak centroid", units=
"pixel")
689 self.
keyYkeyY = schema.addField(name +
"_y", type=
"D", doc=
"peak centroid", units=
"pixel")
691 def measure(self, measRecord, exposure, refRecord, refWcs):
692 targetWcs = exposure.getWcs()
693 peak = refRecord.getFootprint().getPeaks()[0]
695 result = targetWcs.skyToPixel(refWcs.pixelToSky(result))
696 measRecord.set(self.
keyXkeyX, result.getX())
697 measRecord.set(self.
keyYkeyY, result.getY())
701 return SimpleCentroidTransform
705 """Configuration for the forced transformed centroid algorithm.
710 @
register(
"base_TransformedCentroid")
712 """Record the transformation of the reference catalog centroid.
714 The centroid recorded in the reference catalog is tranformed to the
715 measurement coordinate system and stored.
719 config : `ForcedTransformedCentroidConfig`
723 schemaMapper : `lsst.afw.table.SchemaMapper`
724 A mapping from reference catalog fields to output
725 catalog fields. Output fields are added to the output schema.
726 metadata : `lsst.daf.base.PropertySet`
727 Plugin metadata that will be attached to the output catalog.
731 This is used as the slot centroid by default in forced measurement,
732 allowing subsequent measurements to simply refer to the slot value just as
733 they would in single-frame measurement.
736 ConfigClass = ForcedTransformedCentroidConfig
742 def __init__(self, config, name, schemaMapper, metadata):
743 ForcedPlugin.__init__(self, config, name, schemaMapper, metadata)
744 schema = schemaMapper.editOutputSchema()
746 xKey = schema.addField(name +
"_x", type=
"D", doc=
"transformed reference centroid column",
748 yKey = schema.addField(name +
"_y", type=
"D", doc=
"transformed reference centroid row",
754 if "slot_Centroid_flag" in schemaMapper.getInputSchema():
755 self.
flagKeyflagKey = schema.addField(name +
"_flag", type=
"Flag",
756 doc=
"whether the reference centroid is marked as bad")
760 def measure(self, measRecord, exposure, refRecord, refWcs):
761 targetWcs = exposure.getWcs()
762 if not refWcs == targetWcs:
763 targetPos = targetWcs.skyToPixel(refWcs.pixelToSky(refRecord.getCentroid()))
764 measRecord.set(self.
centroidKeycentroidKey, targetPos)
766 measRecord.set(self.
centroidKeycentroidKey, refRecord.getCentroid())
767 if self.
flagKeyflagKey
is not None:
768 measRecord.set(self.
flagKeyflagKey, refRecord.getCentroidFlag())
772 """Configuration for the forced transformed coord algorithm.
777 @
register(
"base_TransformedCentroidFromCoord")
779 """Record the transformation of the reference catalog coord.
781 The coord recorded in the reference catalog is tranformed to the
782 measurement coordinate system and stored.
786 config : `ForcedTransformedCentroidFromCoordConfig`
790 schemaMapper : `lsst.afw.table.SchemaMapper`
791 A mapping from reference catalog fields to output
792 catalog fields. Output fields are added to the output schema.
793 metadata : `lsst.daf.base.PropertySet`
794 Plugin metadata that will be attached to the output catalog.
798 This can be used as the slot centroid in forced measurement when only a
799 reference coord exist, allowing subsequent measurements to simply refer to
800 the slot value just as they would in single-frame measurement.
803 ConfigClass = ForcedTransformedCentroidFromCoordConfig
805 def measure(self, measRecord, exposure, refRecord, refWcs):
806 targetWcs = exposure.getWcs()
808 targetPos = targetWcs.skyToPixel(refRecord.getCoord())
809 measRecord.set(self.
centroidKeycentroidKey, targetPos)
811 if self.
flagKeyflagKey
is not None:
812 measRecord.set(self.
flagKeyflagKey, refRecord.getCentroidFlag())
816 """Configuration for the forced transformed shape algorithm.
823 """Record the transformation of the reference catalog shape.
825 The shape recorded in the reference catalog is tranformed to the
826 measurement coordinate system and stored.
830 config : `ForcedTransformedShapeConfig`
834 schemaMapper : `lsst.afw.table.SchemaMapper`
835 A mapping from reference catalog fields to output
836 catalog fields. Output fields are added to the output schema.
837 metadata : `lsst.daf.base.PropertySet`
838 Plugin metadata that will be attached to the output catalog.
842 This is used as the slot shape by default in forced measurement, allowing
843 subsequent measurements to simply refer to the slot value just as they
844 would in single-frame measurement.
847 ConfigClass = ForcedTransformedShapeConfig
853 def __init__(self, config, name, schemaMapper, metadata):
854 ForcedPlugin.__init__(self, config, name, schemaMapper, metadata)
855 schema = schemaMapper.editOutputSchema()
857 xxKey = schema.addField(name +
"_xx", type=
"D", doc=
"transformed reference shape x^2 moment",
859 yyKey = schema.addField(name +
"_yy", type=
"D", doc=
"transformed reference shape y^2 moment",
861 xyKey = schema.addField(name +
"_xy", type=
"D", doc=
"transformed reference shape xy moment",
867 if "slot_Shape_flag" in schemaMapper.getInputSchema():
868 self.
flagKeyflagKey = schema.addField(name +
"_flag", type=
"Flag",
869 doc=
"whether the reference shape is marked as bad")
873 def measure(self, measRecord, exposure, refRecord, refWcs):
874 targetWcs = exposure.getWcs()
875 if not refWcs == targetWcs:
878 measRecord.set(self.
shapeKeyshapeKey, refRecord.getShape().
transform(localTransform.getLinear()))
880 measRecord.set(self.
shapeKeyshapeKey, refRecord.getShape())
881 if self.
flagKeyflagKey
is not None:
882 measRecord.set(self.
flagKeyflagKey, refRecord.getShapeFlag())
static std::shared_ptr< geom::SpanSet > fromShape(int r, Stencil s=Stencil::CIRCLE, lsst::geom::Point2I offset=lsst::geom::Point2I())
Factory function for creating SpanSets from a Stencil.
An ellipse defined by an arbitrary BaseCore and a center point.
A FunctorKey used to get or set a geom::ellipses::Quadrupole from a tuple of constituent Keys.
def getExecutionOrder(cls)
def __init__(self, config, name, schema, metadata)
def measure(self, measRecord, exposure, center)
def measure(self, measRecord, exposure, center)
def makeLocalTransformMatrix(self, wcs, center)
def getExecutionOrder(cls)
def __init__(self, config, name, schema, metadata)
def __init__(self, config, name, schemaMapper, metadata)
def getExecutionOrder(cls)
def measure(self, measRecord, exposure, refRecord, refWcs)
def measure(self, measRecord, exposure)
def fail(self, measRecord, error=None)
def getExecutionOrder(cls)
def __init__(self, config, name, schema, metadata)
def fail(self, measRecord, error=None)
def getExecutionOrder(cls)
def __init__(self, config, name, schema, metadata)
def measure(self, measRecord, exposure)
def fail(self, measRecord, error=None)
def measure(self, measRecord, exposure)
def getExecutionOrder(cls)
def __init__(self, config, name, schema, metadata)
def fail(self, measRecord, error=None)
def getExecutionOrder(cls)
def measure(self, measRecord, exposure)
int FAILURE_EMPTY_FOOTPRINT
def __init__(self, config, name, schema, metadata)
def measure(self, measRecord, exposure, center)
def fail(self, measRecord, error=None)
def getExecutionOrder(cls)
daf::base::PropertySet * set
HeavyFootprint< ImagePixelT, MaskPixelT, VariancePixelT > makeHeavyFootprint(Footprint const &foot, lsst::afw::image::MaskedImage< ImagePixelT, MaskPixelT, VariancePixelT > const &img, HeavyFootprintCtrl const *ctrl=nullptr)
Create a HeavyFootprint with footprint defined by the given Footprint and pixel values from the given...
std::shared_ptr< SkyWcs > makeSkyWcs(daf::base::PropertySet &metadata, bool strip=false)
Construct a SkyWcs from FITS keywords.
void wrapTransform(lsst::utils::python::WrapperCollection &)
std::shared_ptr< TransformPoint2ToPoint2 > makeWcsPairTransform(SkyWcs const &src, SkyWcs const &dst)
A Transform obtained by putting two SkyWcs objects "back to back".
lsst::geom::AffineTransform linearizeTransform(TransformPoint2ToPoint2 const &original, lsst::geom::Point2D const &inPoint)
Approximate a Transform by its local linearization.
def wrapSimpleAlgorithm(AlgClass, executionOrder, name=None, needsMetadata=False, hasMeasureN=False, hasLogName=False, **kwds)