fix(ngmix): emit true half-light radii in r50 columns; dedupe PSF size columns#743
Merged
Conversation
…e columns The v2.0 size columns were mislabeled: galaxy r50/r50_err were bit-for-bit copies of the area T = 2 sigma^2 (pars[4]), and the PSF r50 columns held bare sigma, missing the sqrt(2 ln 2) = 1.17741 factor. No column in the file was a true half-light radius, and the same name root meant an area on the galaxy side and a length on the PSF side. Now every r50 column is a genuine half-light radius (r50 = 1.17741 sigma = sqrt(ln 2 * T)) with propagated errors, matching the UNIONS-3500 WL I convention (r_h primary, T = 2 sigma^2 the derived DES area): - galaxy: r50 = sqrt(ln 2 * T), r50_err = r50 * T_err / (2 T); NaN when the fitted T is non-positive - PSF: r50psf = sqrt(2 ln 2) * sigma_psf, with the corrected error d sigma / d T = 1 / (4 sigma) (the previous T_err / (2 sigma) was a factor-2 over-estimate) - retire the duplicate columns T_psfo_ngmix (== Tpsf), T_err_psfo_ngmix, r50_psfo_ngmix, r50_err_psfo_ngmix (== r50psf and its error); add the missing Tpsf_err so areas carry their error on both sides - make_cat: read Tpsf instead of the retired T_psfo_ngmix (output column NGMIX_T_PSFo_<key> unchanged, so downstream consumers are unaffected) - fix the get_noise docstring: guess[4] is T, not r50 Tests pin the new semantics: both r50 columns on the same scale (their ratio is sqrt(T/Tpsf)), retired names absent, NaN for non-positive T. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…columns # Conflicts: # src/shapepipe/tests/test_ngmix.py
This was referenced Jun 11, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Stacked on
ngmix_v2.0(#741, CI mirror of #740). Makes everyr50column in the ngmix output a genuine half-light radius, and dedupes the PSF size columns.The v2.0 size columns were mislabeled: galaxy
r50/r50_errwere bit-for-bit copies of the areaT = 2σ²(pars[4]), and the PSFr50columns held bareσ, missing the√(2 ln 2) = 1.17741factor — no column in the file was a true half-light radius, and the same name root meant an area on the galaxy side and a length on the PSF side (see the size discussion on #741).Now, matching the UNIONS-3500 WL I convention (
r_hprimary,T = 2σ²the derived DES area):r50 = √(ln 2 · T),r50_err = r50 · T_err / (2T)(analyticdr50/dT); NaN when the fittedTis non-positiver50psf = √(2 ln 2) σ_psf, with the corrected errordσ/dT = 1/(4σ)— the previousT_err/(2σ)was a factor-2 over-estimateT_psfo_ngmix(==Tpsf),T_err_psfo_ngmix,r50_psfo_ngmix,r50_err_psfo_ngmix; add the missingTpsf_errTpsfinstead of the retiredT_psfo_ngmix; output columnNGMIX_T_PSFo_<key>unchanged, so downstream consumers are unaffected (sp_validation reads onlyNGMIX_T_*/NGMIX_Tpsf_*ratios and none of the r50/retired columns)Galaxy and PSF
r50are now commensurable: their ratio is√(T/Tpsf).The conversion conventions now live in
cs_util.size(CosmoStat/cs_util#65, released as cs_util 0.2.1) — the shared single source of truth this PR's factors agree with.Deferred (intentionally out of scope)
r50/r50psfcolumns are not yet propagated by make_cat to the final catalogue — same as v2.0, where galaxyr50never reached make_cat either. Wiringr_hthrough to the science catalogue is follow-up work.Tpsfpresent incompile_resultsnames, output unchanged) but there is no make_cat test infrastructure to pin it.Tests
test_ngmix.pygainstest_compile_results_size_columns_are_half_light_radiiandtest_compile_results_nonpositive_T_gives_nan_r50; both pass in the dev image (34 passed overall). The one failure,test_metacal_is_reproducible_with_fixed_seed, is a pre-existing environment mismatch (sandbox carries ngmix 1.3.6; v2.0 code needs ngmix 2.xFitter) — untouched by this branch; CI on the v2 image is the arbiter.— Claude on behalf of Cail