Skip to content

feat: COOLEST template import/export (autolens.interop.coolest) - #613

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/coolest-standard-support
Jul 17, 2026
Merged

Jammy2211 merged 1 commit into
mainfrom
feature/coolest-standard-support

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

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 the coolest package: each galaxy becomes a Galaxy lensing entity; ExternalShear/MassSheet profiles are exported as MassField entities 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 an al.Tracer; incomplete templates (missing point estimates) raise.
  • NFW profiles need a physical rho_c: sigma_crit is computed between the galaxy's redshift and the model's highest redshift from the cosmology (solar masses per arcsec²; rho_c per arcsec³) — documented in the module and template metadata.
  • Einstein radius definition is documented explicitly: the exported theta_E is the profile's intermediate-axis COOLEST parameter, distinct from curve-based definitions such as the Euclid DR1 catalogue's tangential-critical-curve radius.
  • coolest is an optional dependency (pip install autolens[coolest], lazy import with an instructive error) and was added to the test/dev/optional extras so CI exercises the tests.

API Changes

Added only — a new public al.interop.coolest namespace (lazy-loaded like al.plot) and a new coolest optional-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.
  • Full suite: python -m pytest test_autolens/ — 385 passed.
  • Follow-up (separate task, filed): herculens EPL ↔ PowerLawIntermediate cross-code parity via a shared COOLEST file in autolens_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 path
  • autolens.interop.coolest.from_coolest(file_path, cosmology=) — COOLEST JSON template → al.Tracer
  • al.interop — lazy module attribute on the autolens namespace
  • pyproject.toml: new coolest extra; coolest added to test, dev, optional extras

Generated by the PyAutoLabs agent workflow.

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>
@Jammy2211

Copy link
Copy Markdown
Collaborator Author

@Jammy2211 Jammy2211 removed the pending-release PR queued for the next release build label Sep 4, 2026
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