fix: raw-flux latent + soft-fail magzero-required µJy#463
Merged
Conversation
`total_galaxy_0_flux_mujy` used to raise ValueError when its consumer enabled the latent without passing magzero to AnalysisImaging. The raise fired post-fit inside SearchUpdater._compute_latent_samples, killing the metric write of a converged search.
This commit:
- adds total_galaxy_0_flux (raw image-unit sum, no instrument inputs)
default-on in autogalaxy/config/latent.yaml
- replaces the magzero raise with _maybe_magzero_warn, returning NaN +
one warning per process per latent name
- keeps total_galaxy_0_flux_mujy default-off (workspaces that pass
magzero opt in via their own latent.yaml override)
Refs PyAutoLabs/PyAutoLens#556
This was referenced May 28, 2026
Collaborator
Author
|
Workspace PR: PyAutoLabs/autolens_workspace#214 |
Collaborator
Author
|
Workspace PR: PyAutoLabs/autogalaxy_workspace#108 |
Collaborator
Author
|
Workspace PR: PyAutoLabs/autolens_workspace_test#133 |
Collaborator
Author
|
Workspace PR: PyAutoLabs/euclid_strong_lens_modeling_pipeline#19 |
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.
Summary
total_galaxy_0_flux_mujyused to raiseValueErrorwhen its consumer enabled thelatent without passing
magzerotoAnalysisImaging. The raise fired post-fitinside
SearchUpdater._compute_latent_samples, killing the metric write of aconverged multi-hour search.
This PR adds a new raw-flux latent (
total_galaxy_0_flux) that needs noinstrument inputs and ships default-on, and converts the existing
_mujylatent's raise into a
NaN+ once-per-process warning. The sibling changefor the lensing latents lives in PyAutoLabs/PyAutoLens#557 (linked once that PR is open).
API Changes
total_galaxy_0_flux(fit, magzero=None, xp=np)— raw integratedflux of galaxy 0 in the fit's image units; no instrument inputs required.
Default-on in
autogalaxy/config/latent.yaml._maybe_magzero_warn(magzero, name) -> boolto dedupe the new soft-fail warning across the many fit evaluations in a
search.
total_galaxy_0_flux_mujy(fit, magzero=None, xp=np):no longer raises
ValueErrorwhenmagzero is None— returnsxp.nanandemits a single
logging.WARNINGper latent name per process.autogalaxy/config/latent.yaml:total_galaxy_0_flux: trueadded;total_galaxy_0_flux_mujystaysfalse.See full details below.
Test Plan
python -m pytest test_autogalaxy/imaging/model/test_latent.py -v— 13/13 passtest_autogalaxy/suite (subagent runs in CI commit)autogalaxy_workspace— verified there are no callers of the removed raise in workspace scripts (separate workspace PR will demo the new latent inguides/units/flux.py)Refs PyAutoLabs/PyAutoLens#556
Full API Changes (for automation & release notes)
Added
autogalaxy.imaging.model.latent.total_galaxy_0_flux(fit, magzero=None, xp=np)— raw image-unit sum offit.galaxy_image_dict[fit.galaxies[0]].array.magzeroaccepted but ignored (uniform dispatcher context).autogalaxy.imaging.model.latent._maybe_magzero_warn(magzero, name)— module-private helper. ReturnsTrue(and logs one WARNING) whenmagzero is None;Falseotherwise.autogalaxy.imaging.model.latent._MAGZERO_WARNED— module-level set tracking which latent names have already warned in this process.Removed
autogalaxy.imaging.model.latent.total_galaxy_0_flux_mujyno longer raisesValueError("magzero must be passed ...")onmagzero=None. Callers that previously caught thisValueErrorwill instead seexp.nan+ alogging.WARNINGrecord.Changed Behaviour
total_galaxy_0_flux_mujy(fit, magzero=None, xp=np): same signature, butmagzero=Nonenow →(xp.nan, logger.warning(...))instead of raise.LATENT_FUNCTIONSregistry now has 2 keys:total_galaxy_0_flux,total_galaxy_0_flux_mujy.Default Config
autogalaxy/config/latent.yamlgainstotal_galaxy_0_flux: true.total_galaxy_0_flux_mujy: falseis preserved.Migration
magzero(Euclid pipeline pattern unchanged).ValueError: drop the catch; the value is nowNaN.total_galaxy_0_flux_mujy: truein theirconfig/latent.yamloverride AND constructAnalysisImaging(..., magzero=<value>).🤖 Generated with Claude Code