Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-43982: Raise FatalAlgorithmError in sizeExtendedness plugin #271

Merged
merged 2 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions python/lsst/meas/base/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
from ._measBaseLib import (ApertureFluxControl, ApertureFluxTransform,
BaseTransform, BlendednessAlgorithm,
BlendednessControl, CircularApertureFluxAlgorithm,
FatalAlgorithmError,
GaussianFluxAlgorithm, GaussianFluxControl,
GaussianFluxTransform, LocalBackgroundAlgorithm,
LocalBackgroundControl, LocalBackgroundTransform,
Expand Down Expand Up @@ -677,6 +678,11 @@ class SingleFrameMomentsClassifierPlugin(SingleFramePlugin):
metadata : `~lsst.daf.base.PropertySet`
Plugin metadata that will be attached to the output catalog.

Raises
------
FatalAlgorithmError
Raised if either of `slot_Shape` or `slot_PsfShape` is unavailable.

Notes
-----
The ``measure`` method of the plugin requires a value for the ``exposure``
Expand All @@ -695,6 +701,16 @@ def getExecutionOrder(cls):

def __init__(self, config, name, schema, metadata):
SingleFramePlugin.__init__(self, config, name, schema, metadata)

# Check that the required columns are already in the schema.
try:
schema.find("slot_Shape_xx")
schema.find("slot_PsfShape_xx")
except KeyError:
raise FatalAlgorithmError(
"Both 'slot_Shape' and 'slot_psfShape' must be available for " + name + "algorithm.",
)

self.key = schema.addField(name + "_value",
type="D",
doc="Measure of being a galaxy based on trace of second order moments",
Expand Down
11 changes: 11 additions & 0 deletions tests/test_MomentsClassifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,17 @@ def testFailure(self):
with self.assertRaisesRegex(measBase.MeasurementError, "Shape flag is set"):
plugin.measure(record, exposure)

def testFatalFailure(self):
"""Test that FatalAlgorithmError is raised if PSF shape is unavailable.
"""
config = measBase.SingleFrameMeasurementConfig()

# Remove slot_psfShape to trigger a failure.
delattr(config.slots, "psfShape")

with self.assertRaises(measBase.FatalAlgorithmError):
self.makeSingleFrameMeasurementTask(config=config)

@lsst.utils.tests.methodParameters(noise=(0.001, 0.01))
def testMonteCarlo(self, noise: float, n_trials: int = 100):
"""Test an ideal simulation, with no noise.
Expand Down