diff --git a/scripts/calibration/calibrate_comprehensive_cat.py b/scripts/calibration/calibrate_comprehensive_cat.py index 4b15ed89..fb3ef3ca 100644 --- a/scripts/calibration/calibrate_comprehensive_cat.py +++ b/scripts/calibration/calibrate_comprehensive_cat.py @@ -191,16 +191,6 @@ for key in add_cols: add_cols_data[key] = cat.get_col(dat, key, mask_combined._mask, mask_metacal) -# Keep original NOSHEAR column, override with 1P PSF values (FHP/MK hack) -print( - "FHP/MK hack: explicit copying of the metacal no-shear (updated from 1p)" - + " PSF size" -) -add_cols_data["NGMIX_T_PSF_RECONV_NOSHEAR_orig"] = add_cols_data[ - "NGMIX_T_PSF_RECONV_NOSHEAR" -] -add_cols_data["NGMIX_T_PSF_RECONV_NOSHEAR"] = gal_metacal.ns["Tpsf"][mask_metacal] - # %% # Additional post-processing columns to write to output cat add_cols_post = [ diff --git a/src/sp_validation/calibration.py b/src/sp_validation/calibration.py index 9032bc63..720650e1 100644 --- a/src/sp_validation/calibration.py +++ b/src/sp_validation/calibration.py @@ -789,13 +789,17 @@ def _read_data(self, data, mask): f"Unsupported shape prefix '{self._prefix}'; only 'NGMIX' is supported" ) - print("FHP/MK hack using p1 PSF for ns in cuts") - indices = np.where(mask)[0] - col_1p = f"{self._prefix}_T_PSF_RECONV_1P" - new_psf = data[col_1p][indices] - - # Overwriting incorrect no-shear PSF size to the one from 1p - ns["Tpsf"] = new_psf + # The reconvolution-PSF size is identical across all metacal types by + # construction: ngmix builds one magnitude-dilated reconv PSF and reuses + # it for noshear/1p/1m/2p/2m, and ShapePipe fits it once per object and + # broadcasts the same scalar into every per-type column. A historical + # workaround overwrote the no-shear value with the 1P value for an older + # catalogue whose no-shear PSF was wrong; that is now a guaranteed no-op. + # Assert the invariant so any future producer-side divergence fails + # loudly instead of being silently patched (see issue #257). + np.testing.assert_array_equal( + ns["Tpsf"], masked_data[f"{self._prefix}_T_PSF_RECONV_1P"] + ) self.m1 = m1 self.p1 = p1 diff --git a/src/sp_validation/tests/test_calibration.py b/src/sp_validation/tests/test_calibration.py index 40621c19..0a66aed5 100644 --- a/src/sp_validation/tests/test_calibration.py +++ b/src/sp_validation/tests/test_calibration.py @@ -296,8 +296,8 @@ def test_metacal_R_matrix_recovers_injected_response(): re-runs with slope 5.0 and confirms R11 tracks it (5.0 != 2.0), so a change that decouples R from the input numbers fails. - NOTE: the estimator prints an 'FHP/MK hack' line and an unweighted / - weighted response line; these are expected stdout, not errors. + NOTE: the estimator prints an unweighted / weighted response line; this + is expected stdout, not an error. """ data, n = _build_ngmix_catalog(slope_11=2.0, slope_22=3.0, step=0.01) mask = np.ones(n, dtype=bool)