feat: size module — Gaussian size-conversion web (T, sigma, r50, FWHM)#65
Merged
Conversation
…FWHM)
Single source of truth for the size conversions used across the
UNIONS / ShapePipe stack, so producers (ShapePipe ngmix writer) and
consumers (sp_validation) stop re-deriving the factors locally:
T = 2 sigma^2 (ngmix / DES area parameter)
r50 = sqrt(2 ln 2) sigma (half-light radius, the primary size in
the UNIONS shape-catalogue papers)
FWHM = 2 sqrt(2 ln 2) sigma
Primitives (T <-> sigma, sigma <-> r50, sigma <-> fwhm) plus the
composites consumers actually call (T_to_r50, r50_to_T, T_to_fwhm).
T_to_fwhm in particular replaces a dimensionally wrong local version in
sp_validation (T / 1.17741 * 2.355, which treats the area T as if it
were already sigma); here the area-to-length conversion carries the
required square root.
Constants are exact (sqrt(2 ln 2), 2 sqrt(2 ln 2)) rather than the
truncated 1.1774 / 2.355 literals. Tests cover closed forms, unit-sigma
values, round trips, FWHM = 2 r50, and array input.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Jun 10, 2026
cailmdaley
added a commit
to CosmoStat/sp_validation
that referenced
this pull request
Jun 11, 2026
The package-level imports in __init__.py are commented out, so CI's 'import sp_validation' smoke test never touches galaxy: a cs_util without cs_util.size passed CI while leaving galaxy un-importable on a fresh install. The new test imports galaxy directly and pins the dimensionally correct conversion (T_to_fwhm(2) = 2.35482, where the old linear form gave 4.0). cs_util.size ships in cs_util 0.2.1 (CosmoStat/cs_util#65); the pin guarantees a fresh install resolves a size-bearing cs_util. NOTE: resolution additionally requires shear_psf_leakage@develop to relax its poetry cap cs-util ^0.1.0 (< 0.2.0) — until then installs of this branch conflict; see PR body. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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
A new
cs_util.sizemodule: the full conversion web between the Gaussian object-size measures used across the UNIONS / ShapePipe stack —T(the ngmix/DES area parameter,T = 2σ²),σ,r50(half-light radius), and FWHM. Eight converters plus the two closed-form constants, all assuming a circular Gaussian:r50 = √(2 ln 2) σ1.17741 σFWHM = 2 √(2 ln 2) σ2.35482 σT = 2 σ²r50 = √(ln 2 · T)Why
During review of ngmix v2.0 in ShapePipe (CosmoStat/shapepipe#741, mirror of CosmoStat/shapepipe#740), we found the
T/r50size conventions being re-derived locally in multiple places, with inconsistent results — including a dimensionally wrongT → FWHMconversion in sp_validation that treated the areaTas if it were a length (linear factor instead of a square root). The fix is structural: one shared, tested home for the conversions, which producers (ShapePipe) and consumers (sp_validation) import instead of re-deriving. Companion PRs in shapepipe and sp_validation adopt it.Tests
cs_util/tests/test_size.py: 8 test methods — constants vs closed forms, unit-σ values for every converter,T_to_r50closed form on arrays, direct value pins for each inverse converter, round-trip identities,FWHM = 2·r50via both paths, the nonpositive-Tcontract (T = 0 → 0,T < 0 → NaN, loudly), and array-shape preservation. Full cs_util suite passes (26 tests).— Claude on behalf of Cail