feat: make the minimum MGE Gaussian sigma configurable (sigma_min) - #549
Conversation
`mge_model_from` hard-coded the lower end of the log-spaced sigma list at 10**-4 arcsec, so the basis always spent components on scales far below the resolution of any real dataset (and the comment claimed 0.01 arcsec, which it never was). Add a `sigma_min` argument (default `1e-4`, preserving existing behaviour) setting the smallest Gaussian width in arcseconds, validated to be positive and no larger than `mask_radius`. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…model_from Follow-up to the `sigma_min` argument, covering three things: - Regression tests asserting the DEFAULT sigma ladders of both `mge_model_from` (sigma_min=1e-4) and `mge_point_model_from` (sigma_min=0.01) reproduce the previously hardcoded `-4` / `-2` linspace values EXACTLY. Every fixed sigma feeds the PyAutoFit run identifier, so drift would orphan the output directories of existing fits. The assertions use `==` rather than `pytest.approx`, which only fails once the ladder has moved past the point the identifier changes. - `mge_point_model_from` gains the same `sigma_min` argument (default 0.01, reproducing the hardcoded `min_log10_sigma = -2.0` exactly), since it had the identical hardcoded floor and is the function that already receives `pixel_scales`. - `sigma_min` docstring entry moved to match its position in the signature. Verified bit-identical: `np.log10(1e-4)` is exactly -4.0 and `np.log10(0.01)` exactly -2.0, so both linspace calls receive unchanged endpoints. Diffed model-by-model against main across 1440 configurations of mask_radius x total_gaussians x gaussian_per_basis x use_spherical x centre prior modes: zero sigma differences, zero identifier differences. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Thanks @NiekWielders — good catch. The docstring promised One thing I checked before merging, because it's the risk that would bite hardest here: existing runs must not get a new It's safe. I've pushed three follow-up commits to your branch rather than sending you round again: 1. Regression tests locking both default ladders. The invariant above is worth having in CI, so a future edit to this line can't quietly re-space the Gaussians of every archived run. The assertions use exact 2. 3. The Full suite green: 1016 passed. Merging. On our side the default stays |
Summary
mge_model_fromhard-coded the lower end of the log-spaced sigma list:So sigmas actually ran from
1e-4"(not the0.01"the comment claimed) up to the mask radius, meaning the basis always spent Gaussians on scales far below the resolution of any real dataset.This PR adds a
sigma_minargument so the smallest Gaussian width can be set by the user, e.g. to the pixel scale or half the PSF FWHM:Details
sigma_min: float = 1e-4(arcsec), appended to the end of the signature so existing positional calls are unaffected. The default reproduces the previous-4behaviour exactly.ValueErrorifsigma_min <= 0(log10would blow up) or ifsigma_min > mask_radius(the list would run backwards).Testing
python -m pytest test_autogalaxy/analysis— 44 passed. New tests cover the default span, a user-setsigma_min(checked against the expected log-spaced values) and both validation errors.🤖 Generated with Claude Code