Repository navigation
Description
Overview
Preparation for modeling ~18,000 Euclid DR1 lenses: PyAutoLens results must be exchangeable with lenstronomy/herculens/Glee via the COOLEST standard (https://github.com/aymgal/COOLEST). This task adds a conversion layer at the model I/O boundary covering all profiles COOLEST defines — internals unchanged (sampling stays on (e1,e2); no internal convention flip), per the Slack consensus (Sonnenfeld, Galan). The intermediate-axis question is handled by a follow-up PowerLawIntermediate + herculens-parity task (PyAutoMind/draft/feature/autolens/coolest_powerlaw_herculens_parity.md).
Plan
- PyAutoGalaxy: new
autogalaxy/interop/coolest/package — pure, dependency-free bidirectional parameter converters for every COOLEST-defined light/mass profile (ellipticity, angle, intermediate-axis radius conventions), reusingautogalaxy/convert.py. - PyAutoLens: new
autolens/interop/coolest.py— COOLEST JSON template import/export of full lens models (analytic profile parameters only) via thecoolestpip package as an optional dependency. - Explicit, documented Einstein-radius definition on export (COOLEST intermediate-axis profile parameter; distinguished from the DR1 tangential-critical-curve definition).
- Round-trip + numerical-certification tests for every √q / angle factor in both repos.
- Workspace guide + workspace_test script as a follow-up PR behind the library-first merge gate.
Detailed implementation plan
Affected Repositories
- PyAutoLens (primary)
- PyAutoGalaxy
Branch Survey
| Repository | Current Branch | Dirty? |
|---|---|---|
| ./PyAutoGalaxy | main | clean |
| ./PyAutoLens | main | paper_jax/paper.md modified (pre-existing, unrelated) |
Suggested branch: feature/coolest-standard-support
Work classification: Library (workspace follow-up)
Worktree root: ~/Code/PyAutoLabs-wt/coolest-standard-support/
Convention facts (verified against coolest.readthedocs.io)
| Quantity | COOLEST | PyAutoGalaxy/PyAutoLens |
|---|---|---|
| Coordinates | cartesian (x right, y up), arcsec | (y, x) grids, arcsec |
| Position angle | CCW from +y (East-of-North), (-90°, +90°] | CCW from +x, (-45°, 135°] (autogalaxy/convert.py) → φ_coolest = angle_ag − 90° renormalized |
| Ellipticity | q = b/a + PA | (e1, e2) ell_comps — ell_comps_from / axis_ratio_and_angle_from |
| Radii (r_eff, θ_E) | intermediate axis r = √(a·b) = √q·a | profile-specific; PowerLaw uses the 2/(q^-½+q^½) rescale (profiles/mass/total/power_law.py) — per-profile factors derived and numerically certified |
| Shear | γ_ext, φ_ext | (gamma_1, gamma_2) — shear_magnitude_and_angle_from |
| Template I/O | coolest pip package (coolest.template) |
new optional dependency in PyAutoLens |
Implementation Steps
Phase A — PyAutoGalaxy autogalaxy/interop/coolest/
conventions.py— angle (+x ↔ East-of-North), (e1,e2) ↔ (q, PA), (y,x) ↔ (x,y) centre swap, per-profile radius-factor helpers. Reuseautogalaxy/convert.py; do not duplicate its math.light.py—ag.lp.Sersic↔ COOLESTSersic(effective-radius factor audited against ag's elliptical-radius definition); shapelets if supported by the installedcoolestversion.mass.py—ag.mp.Isothermal↔ SIE,ag.mp.PowerLaw↔ PEMD/EPL (θ_E intermediate-axis conversion),ag.mp.NFW↔ NFW,ag.mp.ExternalShear↔ ExternalShear,ag.mp.MassSheet↔ convergence sheet if defined.- Converters are dict-in/dict-out on plain floats (no
coolestimport in autogalaxy — zero new dependencies). Unsupported profiles raise a clear, named error (no silent skips). - Tests
test_autogalaxy/interop/(numpy-only): per-profile round-trip identity + numerical certification — evaluate the ag profile and the profile reconstructed from its COOLEST parameters, assert equal convergence/deflections; for PowerLaw assert the analytic √q relation between θ_E definitions.
Phase B — PyAutoLens autolens/interop/coolest.py
6. to_coolest(galaxies_or_tracer, file_path) — export analytic profile parameters into a COOLEST JSON template (lensing entities from lens/source galaxies, redshifts from Galaxy.redshift), via the Phase A registry. Lazy coolest import with informative error; pip install autolens[coolest] extra; added to test/dev extras so CI exercises it.
7. from_coolest(file_path) -> Tracer — read a template, build ag/al profiles via the inverse mappings (built to consume Sonnenfeld's golden-lens JSONs).
8. Einstein-radius definition documented in module docstring + template metadata.
9. Tests test_autolens/interop/: full-model round-trip (PowerLaw + Shear lens, Sersic light + Sersic source), template written and re-read with coolest.template, parameters equal to input; end-to-end convergence/deflection equality on a grid.
Phase C — workspace follow-up PR (after library merge)
10. Minimal autolens_workspace/scripts/guides/ COOLEST example + autolens_workspace_test round-trip script.
Key Files
PyAutoGalaxy/autogalaxy/convert.py— existing (e1,e2)/(q,PA)/shear converters to reusePyAutoGalaxy/autogalaxy/profiles/mass/total/power_law.py— the 2/(q^-½+q^½) Einstein-radius rescale to mapPyAutoGalaxy/autogalaxy/interop/coolest/{conventions,light,mass}.py— newPyAutoLens/autolens/interop/coolest.py— newtest_autogalaxy/interop/,test_autolens/interop/— new tests
Original Prompt
Click to expand starting prompt
See PyAutoMind/active/coolest_standard_support.md (filed from the COOLEST Slack thread with Alessandro Sonnenfeld and Aymeric Galan; original request verbatim inside).
Activity
Jammy2211 commentedon Jul 16, 2026
Library PRs Created
autogalaxy.interop.coolestparameter converters (dependency-free, dict-in/dict-out; Sersic/SIE/PEMD/NFW/shear/sheet; sqrt(q) and angle conventions derived + numerically certified). 982 tests passed.autolens.interop.coolest.to_coolest/from_coolestCOOLEST JSON template I/O (coolestoptional extra; NFW sigma_crit from cosmology; Einstein-radius definition documented). 385 tests passed. Merge the PyAutoGalaxy PR first.Heart was RED on 6 pre-existing, unrelated reasons at ship time; shipped through on explicit user acknowledgement (commit/push/PR-open only).
API changes: Added only (new
ag.interop/al.interopnamespaces +coolestextra) — no workspace script is affected (grep confirms nointeropusage).Next:
autolens_workspaceCOOLEST guide +autolens_workspace_testround-trip script as a follow-up PR (Phase C).PowerLawIntermediateprofile + herculens EPL cross-code parity via a shared COOLEST file —PyAutoMind/draft/feature/autolens/coolest_powerlaw_herculens_parity.md.Fix COOLEST interop relative file paths
Jammy2211 commentedon Jul 17, 2026
Phase C Shipped — workspace PRs open
guides/coolest_interop.pyexport/import guide (+ regenerated notebook/catalogue). Runs green end-to-end; round trip agrees to 8.9e-16.scripts/coolest_round_trip.pyvalidation script (all PASS).Also merged this session: the library PRs PyAutoGalaxy#501 + PyAutoLens#613, and the corrective PyAutoLens#615 (the
coolestJSONSerializer rejects relative paths;to_coolest/from_coolestnow absolutize — found by running the guide, regression-tested).Note: the guide is named
coolest_interop.pybecause aguides/coolest.pyshadows thecoolestpackage (script dir is onsys.path).Remaining: merge the two workspace PRs (library-first gate satisfied — upstream MERGED), then issue the follow-up task
draft/feature/autolens/coolest_powerlaw_herculens_parity.md(PowerLawIntermediate + herculens parity).Jammy2211 commentedon Jul 17, 2026
Shipped — 2026-07-17
PRs (all MERGED)
Summary
COOLEST interop is live on all mains:
ag.interop.coolestparameter converters (derived + numerically certified √q/angle factors) andal.interop.coolest.to_coolest/from_coolestJSON template I/O, with a workspace guide and a workspace_test validation script (round trip to 8.9e-16). Conversion sits at the model I/O boundary; internal conventions unchanged.Session Notes
coolest.pyshadows thecoolestpackage — guide iscoolest_interop.py.notebooks/weak/*.ipynbare stale on autolens_workspace main (regeneration diffs them) — worth a separate sweep.from_coolest.draft/feature/autolens/coolest_powerlaw_herculens_parity.md—PowerLawIntermediateprofile + herculens EPL parity via a shared COOLEST file.