From c4d71a3ee776ff3ced24385893eb3a957f0aed78 Mon Sep 17 00:00:00 2001 From: Merlin Fisher-Levine Date: Wed, 14 Aug 2024 04:52:03 -0700 Subject: [PATCH] Switch to PeekExposureTask from QuickFrameMeasurementTask --- python/lsst/atmospec/centroiding.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/python/lsst/atmospec/centroiding.py b/python/lsst/atmospec/centroiding.py index 919a18f..7ebd27d 100644 --- a/python/lsst/atmospec/centroiding.py +++ b/python/lsst/atmospec/centroiding.py @@ -24,7 +24,8 @@ from lsst.meas.algorithms import LoadReferenceObjectsConfig, MagnitudeLimit, ReferenceObjectLoader from lsst.meas.astrom import AstrometryTask, FitAffineWcsTask -from lsst.pipe.tasks.quickFrameMeasurement import (QuickFrameMeasurementTask) +from lsst.pipe.tasks.quickFrameMeasurement import QuickFrameMeasurementTask +from lsst.pipe.tasks.peekExposure import PeekExposureTask from lsst.pipe.base.task import TaskError import lsst.pipe.base.connectionTypes as cT import lsst.pex.config as pexConfig @@ -77,9 +78,9 @@ class SingleStarCentroidTaskConfig(pipeBase.PipelineTaskConfig, target=AstrometryTask, doc="Task to perform astrometric calibration to refine the WCS", ) - qfmTask = pexConfig.ConfigurableField( - target=QuickFrameMeasurementTask, - doc="XXX", + centroidingFallbackTask = pexConfig.ConfigurableField( + target=PeekExposureTask, + doc="The task to run find the brightest star if astrometry fails", ) referenceFilterOverride = pexConfig.Field( dtype=str, @@ -116,7 +117,7 @@ def __init__(self, initInputs=None, **kwargs): super().__init__(**kwargs) self.makeSubtask("astrometry", refObjLoader=None) - self.makeSubtask('qfmTask') + self.makeSubtask('centroidingFallbackTask') def runQuantum(self, butlerQC, inputRefs, outputRefs): inputs = butlerQC.get(inputRefs) @@ -135,6 +136,18 @@ def runQuantum(self, butlerQC, inputRefs, outputRefs): outputs = self.run(**inputs) butlerQC.put(outputs, outputRefs) + def runFallbackTask(self, exp): + task = self.centroidingFallbackTask + if isinstance(task, QuickFrameMeasurementTask): + result = task.run(exp) + return result.brightestObjCentroid # tuple + elif isinstance(task, PeekExposureTask): + result = task.run(exp) + centroid = result.brightestCentroid # Point2D + return (centroid[0], centroid[1]) + else: + raise ValueError(f"Unsupported fallback task: {task}") + def run(self, inputExp, inputSources): """XXX Docs """ @@ -176,8 +189,7 @@ def run(self, inputExp, inputSources): successfulFit = False self.log.warning(f'Failed to find target centroid for {target} via WCS') if not centroid: - result = self.qfmTask.run(inputExp) - centroid = result.brightestObjCentroid + centroid = self.runFallbackTask(inputExp) centroidTuple = (centroid[0], centroid[1]) # unify Point2D or tuple to tuple self.log.info(f"Centroid of main star found at {centroidTuple} found"