Skip to content

feat: COOLEST-standard profile parameter converters (autogalaxy.interop.coolest)#501

Open
Jammy2211 wants to merge 1 commit into
mainfrom
feature/coolest-standard-support
Open

feat: COOLEST-standard profile parameter converters (autogalaxy.interop.coolest)#501
Jammy2211 wants to merge 1 commit into
mainfrom
feature/coolest-standard-support

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

Adds autogalaxy.interop.coolest, a bidirectional parameter-conversion layer between PyAutoGalaxy profiles and the COOLEST standard, so lens models can be exchanged with lenstronomy/herculens/Glee (PyAutoLabs/PyAutoLens#612, Euclid DR1 prep). Conversion happens at the model I/O boundary only — internal conventions (sampling on (e1, e2), existing radius definitions) are unchanged, per the COOLEST Slack-thread consensus.

Conventions handled (each derived in the module docstrings and certified numerically in tests against the analytic COOLEST-convention formulas):

  • Position angle: PyAutoGalaxy counter-clockwise-from-+x → COOLEST East-of-North (−90°, +90°].
  • Ellipticity: (e1, e2)(q, phi) via the existing autogalaxy.convert functions.
  • Radii: COOLEST intermediate-axis r = sqrt(a·b); the Sersic effective_radius is already intermediate-axis (identity), the power-law Einstein radius converts as theta_cool = sqrt(q) · (2/(1+q))^(1/(gamma−1)) · theta_ag (reduces to 2·sqrt(q)/(1+q) for isothermal).
  • NFW: COOLEST's physical rho_c requires sigma_crit, taken as an explicit argument (PyAutoLens computes it from redshifts + cosmology).

Everything is dict-in/dict-out on plain floats — PyAutoGalaxy gains no new dependency. Profiles without a COOLEST counterpart raise ProfileException (no silent skips). COOLEST q = 1 imports build the spherical profile classes (the elliptical Isothermal clips its axis ratio at 0.99999, so q=1 is only exact spherically).

Supported: Sersic/SersicSph, Isothermal/IsothermalSph (SIE), PowerLaw/PowerLawSph (PEMD), NFW/NFWSph, ExternalShear, MassSheet (ConvergenceSheet).

API Changes

Added only — a new public ag.interop.coolest namespace (lazy-loaded like ag.plot); no existing symbol changed.
See full details below.

Test Plan

  • test_autogalaxy/interop/ — 20 new tests: per-profile round-trip numerical identity (convergence/deflections/images) plus analytic certification of every sqrt(q)/angle factor against the COOLEST-convention PEMD/SIE/Sersic formulas evaluated independently.
  • Full suite: python -m pytest test_autogalaxy/ — 982 passed.
Full API Changes (for automation & release notes)

Added

  • autogalaxy.interop.coolest.coolest_dict_from_light(profile) — light profile → COOLEST {"type", "parameters"} dict
  • autogalaxy.interop.coolest.light_profile_from(profile_type, parameters) — inverse
  • autogalaxy.interop.coolest.coolest_dict_from_mass(profile, sigma_crit=None) — mass profile → COOLEST dict (sigma_crit required for NFW)
  • autogalaxy.interop.coolest.mass_profile_from(profile_type, parameters, sigma_crit=None) — inverse
  • autogalaxy.interop.coolest.conventions — angle/ellipticity/centre/radius convention helpers (phi_coolest_from, q_phi_from_ell_comps, ell_comps_from_q_phi, center_from_centre, radius_intermediate_from, inverses)
  • ag.interop — lazy module attribute on the autogalaxy namespace

Generated by the PyAutoLabs agent workflow.

…nverters

Bidirectional, dependency-free (dict-in/dict-out) conversion between
PyAutoGalaxy light/mass profiles and COOLEST conventions: ellipticity
(e1,e2) <-> (q, phi East-of-North), (y,x) <-> (x,y) centres,
intermediate-axis radii, and the power-law Einstein-radius rescaling
theta_cool = sqrt(q) (2/(1+q))^(1/(gamma-1)) theta_ag. Covers
Sersic(+Sph), Isothermal(+Sph)->SIE, PowerLaw(+Sph)->PEMD, NFW(+Sph),
ExternalShear and MassSheet->ConvergenceSheet; unsupported profiles
raise ProfileException. Exposed as lazy ag.interop.

Part of PyAutoLabs/PyAutoLens#612.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pending-release PR queued for the next release build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant