Skip to content

Commit

Permalink
Remove external* calibs system in DetectorMeasurementTask.
Browse files Browse the repository at this point in the history
  • Loading branch information
TallJimbo committed Apr 9, 2024
1 parent 08f8b81 commit b9413cc
Showing 1 changed file with 1 addition and 141 deletions.
142 changes: 1 addition & 141 deletions python/lsst/faro/measurement/DetectorMeasurement.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.

import lsst.pipe.base as pipeBase
import lsst.pex.config as pexConfig

from lsst.faro.base.CatalogMeasurementBase import (
CatalogMeasurementBaseConnections,
Expand All @@ -34,19 +33,6 @@
class DetectorMeasurementConnections(
CatalogMeasurementBaseConnections,
dimensions=("instrument", "visit", "detector", "band"),
# TODO: remove deprecated templates on DM-39854.
defaultTemplates={
"photoCalibName": "calexp.photoCalib",
"externalPhotoCalibName": "fgcm",
"wcsName": "calexp.wcs",
"externalWcsName": "gbdesAstrometricFit",
},
deprecatedTemplates={
"photoCalibName": "Deprecated in favor of visitSummary; will be removed after v26.",
"externalPhotoCalibName": "Deprecated in favor of visitSummary; will be removed after v26.",
"wcsName": "Deprecated in favor of visitSummary; will be removed after v26.",
"externalWcsName": "Deprecated in favor of visitSummary; will be removed after v26.",
},
):

catalog = pipeBase.connectionTypes.Input(
Expand All @@ -61,124 +47,18 @@ class DetectorMeasurementConnections(
storageClass="ExposureCatalog",
name="finalVisitSummary",
)
skyWcs = pipeBase.connectionTypes.Input(
doc="WCS for the catalog.",
dimensions=("instrument", "visit", "detector", "band"),
storageClass="Wcs",
name="{wcsName}",
# TODO: remove on DM-39854.
deprecated="Deprecated in favor of visitSummary and already ignored; will be removed after v26."
)
photoCalib = pipeBase.connectionTypes.Input(
doc="Photometric calibration object.",
dimensions=("instrument", "visit", "detector", "band"),
storageClass="PhotoCalib",
name="{photoCalibName}",
# TODO: remove on DM-39854.
deprecated="Deprecated in favor of visitSummary and already ignored; will be removed after v26."
)
externalSkyWcsTractCatalog = pipeBase.connectionTypes.Input(
doc=(
"Per-tract, per-visit wcs calibrations. These catalogs use the detector "
"id for the catalog id, sorted on id for fast lookup."
),
name="{externalWcsName}SkyWcsCatalog",
storageClass="ExposureCatalog",
dimensions=("instrument", "visit", "tract"),
# TODO: remove on DM-39854.
deprecated="Deprecated in favor of visitSummary; will be removed after v26."
)
externalSkyWcsGlobalCatalog = pipeBase.connectionTypes.Input(
doc=(
"Per-visit wcs calibrations computed globally (with no tract information). "
"These catalogs use the detector id for the catalog id, sorted on id for "
"fast lookup."
),
name="{externalWcsName}SkyWcsCatalog",
storageClass="ExposureCatalog",
dimensions=("instrument", "visit"),
# TODO: remove on DM-39854.
deprecated="Deprecated in favor of visitSummary; will be removed after v26."
)
externalPhotoCalibTractCatalog = pipeBase.connectionTypes.Input(
doc=(
"Per-tract, per-visit photometric calibrations. These catalogs use the "
"detector id for the catalog id, sorted on id for fast lookup."
),
name="{externalPhotoCalibName}PhotoCalibCatalog",
storageClass="ExposureCatalog",
dimensions=("instrument", "visit", "tract"),
# TODO: remove on DM-39854.
deprecated="Deprecated in favor of visitSummary; will be removed after v26."
)
externalPhotoCalibGlobalCatalog = pipeBase.connectionTypes.Input(
doc=(
"Per-visit photometric calibrations computed globally (with no tract "
"information). These catalogs use the detector id for the catalog id, "
"sorted on id for fast lookup."
),
name="{externalPhotoCalibName}PhotoCalibCatalog",
storageClass="ExposureCatalog",
dimensions=("instrument", "visit"),
# TODO: remove on DM-39854.
deprecated="Deprecated in favor of visitSummary; will be removed after v26."
)
measurement = pipeBase.connectionTypes.Output(
doc="Per-detector measurement.",
dimensions=("instrument", "visit", "detector", "band"),
storageClass="MetricValue",
name="metricvalue_{package}_{metric}",
)

def __init__(self, *, config=None):
super().__init__(config=config)
# TODO: remove references to deprecates things after DM-39854 (may
# allow the __init__ override to go away entirely).
if config.doApplyExternalSkyWcs:
if config.useGlobalExternalSkyWcs:
self.inputs.remove("externalSkyWcsTractCatalog")
else:
self.inputs.remove("externalSkyWcsGlobalCatalog")
else:
self.inputs.remove("externalSkyWcsTractCatalog")
self.inputs.remove("externalSkyWcsGlobalCatalog")
if config.doApplyExternalPhotoCalib:
if config.useGlobalExternalPhotoCalib:
self.inputs.remove("externalPhotoCalibTractCatalog")
else:
self.inputs.remove("externalPhotoCalibGlobalCatalog")
else:
self.inputs.remove("externalPhotoCalibTractCatalog")
self.inputs.remove("externalPhotoCalibGlobalCatalog")
del self.skyWcs
del self.photoCalib


class DetectorMeasurementConfig(
CatalogMeasurementBaseConfig, pipelineConnections=DetectorMeasurementConnections
):
doApplyExternalSkyWcs = pexConfig.Field(
doc="Whether or not to use the external wcs.", dtype=bool, default=False,
# TODO: remove on DM-39854.
deprecated="Deprecated in favor of the visitSummary connection; will be removed after v26."
)
useGlobalExternalSkyWcs = pexConfig.Field(
doc="Whether or not to use the global external wcs.", dtype=bool, default=False,
# TODO: remove on DM-39854.
deprecated="Deprecated in favor of the visitSummary connection; will be removed after v26."
)
doApplyExternalPhotoCalib = pexConfig.Field(
doc="Whether or not to use the external photoCalib.", dtype=bool, default=False,
# TODO: remove on DM-39854.
deprecated="Deprecated in favor of the visitSummary connection; will be removed after v26."
)
useGlobalExternalPhotoCalib = pexConfig.Field(
doc="Whether or not to use the global external photoCalib.",
dtype=bool,
default=False,
# TODO: remove on DM-39854.
deprecated="Deprecated in favor of the visitSummary connection; will be removed after v26."
)
pass


class DetectorMeasurementTask(CatalogMeasurementBaseTask):
Expand All @@ -192,26 +72,6 @@ def runQuantum(self, butlerQC, inputRefs, outputRefs):
row = visitSummary.find(detector)
inputs["photoCalib"] = row.getPhotoCalib()
inputs["skyWcs"] = row.getSkyWcs()
# TODO: significant simplification should be possible here on DM-39854.
if self.config.doApplyExternalPhotoCalib:
if self.config.useGlobalExternalPhotoCalib:
externalPhotoCalibCatalog = inputs.pop(
"externalPhotoCalibGlobalCatalog"
)
else:
externalPhotoCalibCatalog = inputs.pop("externalPhotoCalibTractCatalog")
row = externalPhotoCalibCatalog.find(detector)
externalPhotoCalib = None if row is None else row.getPhotoCalib()
inputs["photoCalib"] = externalPhotoCalib
if self.config.doApplyExternalSkyWcs:
if self.config.useGlobalExternalSkyWcs:
externalSkyWcsCatalog = inputs.pop("externalSkyWcsGlobalCatalog")
else:
externalSkyWcsCatalog = inputs.pop("externalSkyWcsTractCatalog")
row = externalSkyWcsCatalog.find(detector)
externalSkyWcs = None if row is None else row.getWcs()
inputs["skyWcs"] = externalSkyWcs

outputs = self.run(**inputs)
if outputs.measurement is not None:
butlerQC.put(outputs, outputRefs)
Expand Down

0 comments on commit b9413cc

Please sign in to comment.