From 15db866f1a7d10940a46d75223d0d19f9eb6b03d Mon Sep 17 00:00:00 2001 From: Eli Rykoff Date: Wed, 16 Oct 2024 21:34:01 -0700 Subject: [PATCH] Fix fitGains on load when stored incorrectly. --- python/lsst/ip/isr/crosstalk.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/python/lsst/ip/isr/crosstalk.py b/python/lsst/ip/isr/crosstalk.py index 33ce95d7..44d6524d 100644 --- a/python/lsst/ip/isr/crosstalk.py +++ b/python/lsst/ip/isr/crosstalk.py @@ -321,9 +321,16 @@ def fromDict(cls, dictionary): else: calib.ampGainRatios = np.zeros_like(calib.coeffs) if 'fitGains' in dictionary: - calib.fitGains = np.array(dictionary['fitGains']).reshape(calib.nAmp) + # Compatibility for matrices that were stored with fitGains + # of length 1. + fitGains = np.array(dictionary['fitGains']) + if len(fitGains) == 1: + # Expand to the correct number of amps, all zero (unknown). + calib.fitGains = np.zeros(calib.nAmp) + else: + calib.fitGains = np.array(dictionary['fitGains']).reshape(calib.nAmp) else: - calib.fitGains = np.zeros_like(calib.nAmp) + calib.fitGains = np.zeros(calib.nAmp) calib.interChip = dictionary.get('interChip', None) if calib.interChip: