feat: COOLEST-standard profile parameter converters (autogalaxy.interop.coolest)#501
Open
Jammy2211 wants to merge 1 commit into
Open
feat: COOLEST-standard profile parameter converters (autogalaxy.interop.coolest)#501Jammy2211 wants to merge 1 commit into
Jammy2211 wants to merge 1 commit into
Conversation
…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>
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
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):
(e1, e2)↔(q, phi)via the existingautogalaxy.convertfunctions.r = sqrt(a·b); the Sersiceffective_radiusis already intermediate-axis (identity), the power-law Einstein radius converts astheta_cool = sqrt(q) · (2/(1+q))^(1/(gamma−1)) · theta_ag(reduces to2·sqrt(q)/(1+q)for isothermal).rho_crequiressigma_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). COOLESTq = 1imports build the spherical profile classes (the ellipticalIsothermalclips 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.coolestnamespace (lazy-loaded likeag.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.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"}dictautogalaxy.interop.coolest.light_profile_from(profile_type, parameters)— inverseautogalaxy.interop.coolest.coolest_dict_from_mass(profile, sigma_crit=None)— mass profile → COOLEST dict (sigma_critrequired for NFW)autogalaxy.interop.coolest.mass_profile_from(profile_type, parameters, sigma_crit=None)— inverseautogalaxy.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 theautogalaxynamespaceGenerated by the PyAutoLabs agent workflow.