From a4c3bac2c7e0731008222ce19a7bdcf51b8e48cf Mon Sep 17 00:00:00 2001 From: Rongpu Zhou Date: Thu, 13 Mar 2025 10:16:19 -0700 Subject: [PATCH] Exclude sky fibers from fiber aperture correction --- py/desispec/fiberfluxcorr.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/py/desispec/fiberfluxcorr.py b/py/desispec/fiberfluxcorr.py index 4787ed5c1..9db65d01c 100644 --- a/py/desispec/fiberfluxcorr.py +++ b/py/desispec/fiberfluxcorr.py @@ -70,11 +70,16 @@ def flat_to_psf_flux_correction(fibermap,exposure_seeing_fwhm=1.1) : # fiber flat correction is larger # have to divide by isotropic_platescale^2 ok = (fiber_frac>0.01) + skyfibers = fibermap["OBJTYPE"]=="SKY" + ok &= (~skyfibers) # also exclude sky fibers from the point_source_correction calculation point_source_correction = np.zeros(x_mm.shape) point_source_correction[ok] = 1./fiber_frac[ok]/isotropic_platescale[ok]**2 - # normalize to one because this is a relative correction here - point_source_correction[ok] /= np.mean(point_source_correction[ok]) + # normalize to one because this is a relative correction here; use median to be robust against outliers + point_source_correction[ok] /= np.median(point_source_correction[ok]) + + # set the correction factor to 1 for sky fibers; other low-fiber_frac fibers have value 0. + point_source_correction[skyfibers] = 1. return point_source_correction