Skip to content

feat: size module — Gaussian size-conversion web (T, sigma, r50, FWHM)#65

Merged
cailmdaley merged 2 commits into
developfrom
feat/size-conversions
Jun 10, 2026
Merged

feat: size module — Gaussian size-conversion web (T, sigma, r50, FWHM)#65
cailmdaley merged 2 commits into
developfrom
feat/size-conversions

Conversation

@cailmdaley

Copy link
Copy Markdown
Collaborator

What

A new cs_util.size module: 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:

relation closed form
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/r50 size conventions being re-derived locally in multiple places, with inconsistent results — including a dimensionally wrong T → FWHM conversion in sp_validation that treated the area T as 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_r50 closed form on arrays, direct value pins for each inverse converter, round-trip identities, FWHM = 2·r50 via both paths, the nonpositive-T contract (T = 0 → 0, T < 0 → NaN, loudly), and array-shape preservation. Full cs_util suite passes (26 tests).

— Claude on behalf of Cail

cailmdaley and others added 2 commits June 10, 2026 03:59
…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>
@cailmdaley cailmdaley merged commit 503dc53 into develop 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>
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