Skip to content

fix: dimensionally wrong T_to_fwhm distorted the PSF-leakage size axis#198

Merged
cailmdaley merged 3 commits into
developfrom
fix/psf-leakage-fwhm
Jun 11, 2026
Merged

fix: dimensionally wrong T_to_fwhm distorted the PSF-leakage size axis#198
cailmdaley merged 3 commits into
developfrom
fix/psf-leakage-fwhm

Conversation

@cailmdaley

Copy link
Copy Markdown
Collaborator

What

galaxy.py's local T_to_fwhm was dimensionally wrong: T / 1.17741 * 2.355 treats the area T = 2σ² as if it were σ. The correct conversion carries a square root: FWHM = 2.35482 √(T/2). The two coincide only near σ = 0.5 (T = 0.5 → 1.0008 vs 1.0) and diverge sharply elsewhere (T = 2 → old 4.0 vs correct 2.355) — a monotonic but nonlinear distortion of the PSF-leakage size axis (per-bin α(size) trends). Results produced through the old function should be regenerated.

The local converters are deleted and re-exported from cs_util.size (CosmoStat/cs_util#65, released as cs_util 0.2.1) — the shared single source of truth for the T/σ/r50/FWHM web, also adopted on the ShapePipe side (CosmoStat/shapepipe#743). The pin moves to cs_util>=0.2.1 so a fresh install resolves a size-bearing cs_util (PyPI 0.2 predates the module).

A new tests/test_galaxy.py closes the hole that let this hide: the package-level imports in __init__.py are commented out, so CI's import sp_validation smoke test never touched galaxy — a broken cs_util.size import would have passed CI. The test imports galaxy directly and pins T_to_fwhm(2.0) = 2.35482.

Note: sigma_to_fwhm loses its unused pixel_size kwarg (never passed anywhere in src/ or notebooks; it was only ever used single-argument via the size_to_fwhm dispatch table).

Merge discipline — do not merge yet

shear_psf_leakage@develop's poetry cap cs-util = "^0.1.0" (→ <0.2.0) conflicts with the cs_util>=0.2.1 pin, so dependency resolution of this branch currently fails. Merge after CosmoStat/shear_psf_leakage relaxes the cap on develop (one line, cs-util = ">=0.1.0,<0.3"; its cs_util usage — args, calc, cat, cosmo, logging, plots — is signature-compatible with 0.2.x). With that cap relaxed, the full install + test suite passes from scratch: verified here with a fresh uv env (override simulating the relaxation) — cs_util 0.2.1 resolved from PyPI, galaxy imports, 35 passed / 6 deselected (-m 'not slow').

— Claude on behalf of Cail

cailmdaley and others added 2 commits June 10, 2026 04:04
galaxy.py's local T_to_fwhm was T / 1.17741 * 2.355, which treats the
ngmix area parameter T = 2 sigma^2 as if it were already the Gaussian
scale sigma (the factor 2.355 / 1.17741 = 2.000 makes the mistake
visible; the function's own MKDEBUG comment doubted it). The correct
area-to-length conversion needs a square root:

    FWHM = 2.35482 sigma = 2.35482 sqrt(T / 2)

This function builds the fwhm_PSF column (extract_info.py, from
NGMIX_T_PSFo_NOSHEAR) that serves as the size_PSF_col regressor in the
scale-dependent PSF-leakage fit (run_object.py / calibration.py). The
bug is a monotonic but nonlinear distortion of the PSF-size axis, so
any alpha(PSF size) trend and per-bin leakage coefficients computed
with it are biased; spatially-constant leakage is unaffected. Results
produced with the old function should be regenerated.

Both T_to_fwhm and sigma_to_fwhm now come from cs_util.size (the
shared, tested size-conversion web; requires cs_util with the size
module, branch feat/size-conversions) and are re-exported from
sp_validation.galaxy, so star-import consumers (extract_info.py,
main_set_up.ipynb's size_to_fwhm dispatch) keep working unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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>
The 6.0.3 release on PyPI ships dist-info only — no python module — so
'import sphinxawesome_theme' fails after a clean-looking install and the
docs build dies with an ExtensionError. Pin !=6.0.3 so resolution falls
back to a working release (and heals itself when 6.0.4 lands).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@cailmdaley cailmdaley merged commit 438bf6f into develop Jun 11, 2026
2 checks passed
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