From e78db7396678293240b03d957b34dcec3adbdfbd Mon Sep 17 00:00:00 2001 From: "Sergey E. Koposov" Date: Mon, 2 Dec 2024 18:55:43 +0000 Subject: [PATCH] fix previous commit --- py/desispec/fluxcalibration.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/py/desispec/fluxcalibration.py b/py/desispec/fluxcalibration.py index 3c085c8ac..2b5e0f076 100644 --- a/py/desispec/fluxcalibration.py +++ b/py/desispec/fluxcalibration.py @@ -1467,16 +1467,17 @@ def apply_flux_calibration(frame, fluxcalib): """ C = fluxcalib.calib - good = (fluxcalib.ivar>0) & (C>0) & (frame.ivar>0) + good = (fluxcalib.ivar > 0) & (C > 0) & (frame.ivar > 0) for i in range(nfibers) : ok = good[i] - if ok.any() > 0 : - frame.ivar[i,ok] = C[i, ok]**4 * frame.ivar[i,ok] * fluxcalib.ivar[i,ok]/ ( - frame.flux[i,ok]**2 + C[i,ok]**2 ) + if ok.any(): + frame.ivar[i, ok] = (C[i, ok]**4 * frame.ivar[i, ok] * + fluxcalib.ivar[i, ok] / + (frame.flux[i, ok]**2 + C[i, ok]**2)) frame.ivar[i, ~ok] = 0 # It is important we update flux *after* # updating variance - frame.flux = frame.flux * (C>0) / (C+(C==0)) + frame.flux = frame.flux * (C > 0) / (C + (C == 0)) if fluxcalib.fibercorr is not None and frame.fibermap is not None : if "PSF_TO_FIBER_FLUX" in fluxcalib.fibercorr.dtype.names :