feat: COOLEST template import/export (autolens.interop.coolest)#613
Merged
Conversation
to_coolest(galaxies_or_tracer, file_path) exports the analytic profile parameters of a lens model to a COOLEST JSON template (galaxies as Galaxy entities; ExternalShear/MassSheet as MassField entities); from_coolest(file_path) rebuilds a Tracer. Parameter conversions come from autogalaxy.interop.coolest; NFW sigma_crit is computed from the model cosmology. The `coolest` package is a new optional dependency (autolens[coolest]; also in test/dev/optional extras so CI runs the tests). Einstein-radius definition documented explicitly (profile intermediate-axis parameter, distinct from the DR1 tangential-critical- curve definition). Part of #612. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Collaborator
Author
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
Adds
autolens.interop.coolest— import/export of full lens models (analytic profile parameters only) as COOLEST JSON templates, closing the interop leg of #612 (Euclid DR1 prep). Builds on the converter layer added in the companion PyAutoGalaxy PR on the same branch (feature/coolest-standard-support) — merge that first.to_coolest(galaxies_or_tracer, file_path, cosmology=None, mode="MAP", ...)— writes a COOLEST template via thecoolestpackage: each galaxy becomes aGalaxylensing entity;ExternalShear/MassSheetprofiles are exported asMassFieldentities per the standard; H0/Om0 written from the model cosmology; a metadata block records the generator and unit conventions.from_coolest(file_path, cosmology=None)— reads a template (including ones produced by other codes, e.g. the Sonnenfeld golden-lens models) and rebuilds anal.Tracer; incomplete templates (missing point estimates) raise.rho_c:sigma_critis computed between the galaxy's redshift and the model's highest redshift from the cosmology (solar masses per arcsec²;rho_cper arcsec³) — documented in the module and template metadata.theta_Eis the profile's intermediate-axis COOLEST parameter, distinct from curve-based definitions such as the Euclid DR1 catalogue's tangential-critical-curve radius.coolestis an optional dependency (pip install autolens[coolest], lazy import with an instructive error) and was added to thetest/dev/optionalextras so CI exercises the tests.API Changes
Added only — a new public
al.interop.coolestnamespace (lazy-loaded likeal.plot) and a newcoolestoptional-dependency extra; no existing symbol changed.See full details below.
Test Plan
test_autolens/interop/— 4 new tests: written-template contents in COOLEST conventions (theta_E factor, phi, cosmology), full-model round trip (PowerLaw + shear lens with Sersic light, Sersic source) with tracer deflections/images numerically identical, NFW sigma_crit round trip, incomplete-template error.python -m pytest test_autolens/— 385 passed.PowerLawIntermediatecross-code parity via a shared COOLEST file inautolens_workspace_test.Full API Changes (for automation & release notes)
Added
autolens.interop.coolest.to_coolest(galaxies, file_path, cosmology=, mode=, pixel_size=, metadata=)— export lens model → COOLEST JSON template; returns the written pathautolens.interop.coolest.from_coolest(file_path, cosmology=)— COOLEST JSON template →al.Traceral.interop— lazy module attribute on theautolensnamespacepyproject.toml: newcoolestextra;coolestadded totest,dev,optionalextrasGenerated by the PyAutoLabs agent workflow.