From 5aa57cb2d4618c028b52ab2a75cb08e8c1538f09 Mon Sep 17 00:00:00 2001 From: Eli Rykoff Date: Mon, 11 Sep 2023 16:00:07 -0700 Subject: [PATCH] Add ability to forward fields while reading exposure summary stats. This specifically lets "decl" be forwarded to "dec". --- python/lsst/afw/image/_exposureSummaryStats.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/python/lsst/afw/image/_exposureSummaryStats.py b/python/lsst/afw/image/_exposureSummaryStats.py index a3fef6787..a6693b055 100644 --- a/python/lsst/afw/image/_exposureSummaryStats.py +++ b/python/lsst/afw/image/_exposureSummaryStats.py @@ -145,12 +145,19 @@ def _write(self): @staticmethod def _read(bytes): yamlDict = yaml.load(bytes, Loader=yaml.SafeLoader) + + # Special list of fields to forward to new names. + forwardFieldDict = {"decl": "dec"} + # For forwards compatibility, filter out any fields that are # not defined in the dataclass. droppedFields = [] for _field in list(yamlDict.keys()): if _field not in ExposureSummaryStats.__dataclass_fields__: - droppedFields.append(_field) + if _field in forwardFieldDict and forwardFieldDict[_field] not in yamlDict: + yamlDict[forwardFieldDict[_field]] = yamlDict[_field] + else: + droppedFields.append(_field) yamlDict.pop(_field) if len(droppedFields) > 0: droppedFieldString = ", ".join([str(f) for f in droppedFields])