Skip to content

fix(ngmix): emit true half-light radii in r50 columns; dedupe PSF size columns#743

Merged
cailmdaley merged 2 commits into
ngmix_v2.0from
fix/ngmix-size-columns
Jun 11, 2026
Merged

fix(ngmix): emit true half-light radii in r50 columns; dedupe PSF size columns#743
cailmdaley merged 2 commits into
ngmix_v2.0from
fix/ngmix-size-columns

Conversation

@cailmdaley

Copy link
Copy Markdown
Contributor

What

Stacked on ngmix_v2.0 (#741, CI mirror of #740). Makes every r50 column 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_err were bit-for-bit copies of the area T = 2σ² (pars[4]), and the PSF r50 columns held bare σ, missing the √(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 (see the size discussion on #741).

Now, matching the UNIONS-3500 WL I convention (r_h primary, T = 2σ² the derived DES area):

  • galaxy: r50 = √(ln 2 · T), r50_err = r50 · T_err / (2T) (analytic dr50/dT); NaN when the fitted T is non-positive
  • PSF: r50psf = √(2 ln 2) σ_psf, with the corrected error dσ/dT = 1/(4σ) — the previous T_err/(2σ) was a factor-2 over-estimate
  • dedupe: retire T_psfo_ngmix (== Tpsf), T_err_psfo_ngmix, r50_psfo_ngmix, r50_err_psfo_ngmix; add the missing Tpsf_err
  • make_cat: reads Tpsf instead of the retired T_psfo_ngmix; output column NGMIX_T_PSFo_<key> unchanged, so downstream consumers are unaffected (sp_validation reads only NGMIX_T_*/NGMIX_Tpsf_* ratios and none of the r50/retired columns)

Galaxy and PSF r50 are 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)

  • The honest r50/r50psf columns are not yet propagated by make_cat to the final catalogue — same as v2.0, where galaxy r50 never reached make_cat either. Wiring r_h through to the science catalogue is follow-up work.
  • The one-line make_cat change is value-preserving (verified: Tpsf present in compile_results names, output unchanged) but there is no make_cat test infrastructure to pin it.

Tests

test_ngmix.py gains test_compile_results_size_columns_are_half_light_radii and test_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.x Fitter) — untouched by this branch; CI on the v2 image is the arbiter.

— Claude on behalf of Cail

cailmdaley and others added 2 commits June 10, 2026 03:56
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant