Skip to content

feat: PowerLawIntermediate profile + herculens power-law parity via COOLEST #616

Closed

Description

@Jammy2211

Overview

Follow-up to #612 (COOLEST interop, merged). Adds ag.mp.PowerLawIntermediate — an elliptical power-law whose einstein_radius parameter is the COOLEST intermediate-axis θ_E — making the COOLEST mapping for it an identity (no √q factors), i.e. a direct parameter-level link to herculens/lenstronomy's power-law. A herculens cross-code parity script then proves the link empirically: the same COOLEST template produces numerically matching convergence and deflections in both codes.

Plan

  • PyAutoGalaxy: behavior-preserving einstein_radius_major_from(xp) hook in the power-law implementation, then PowerLawIntermediate(PowerLaw) overriding it with the certified conversion θ_ag = θ_int/√q · ((1+q)/2)^(1/(γ−1)). Exported as ag.mp.PowerLawIntermediate with a priors-config block.
  • COOLEST layer: PowerLawIntermediate → PEMD identity mapping; intermediate=True import option (threaded through al.interop.coolest.from_coolest) to rebuild PEMDs as PowerLawIntermediate.
  • Tests: PowerLawIntermediate ≡ PowerLaw equivalence under the θ rescale (parametrized over q, γ); COOLEST identity + analytic certification; round trip.
  • autolens_workspace_test: scripts/coolest_herculens_parity.py — export a PowerLawIntermediate model to a COOLEST template, load it into herculens, assert matching convergence/deflections on a shared grid (herculens installed in the env only, never a library dependency).
Detailed implementation plan

Affected Repositories

  • PyAutoGalaxy (primary implementation)
  • PyAutoLens (from_coolest intermediate kwarg)
  • autolens_workspace_test (parity script)

Branch

feature/coolest-powerlaw-herculens, worktree ~/Code/PyAutoLabs-wt/coolest-powerlaw-herculens/

Implementation Steps

  1. autogalaxy/profiles/mass/total/power_law_core.py: add PowerLawCore.einstein_radius_major_from(self, xp) returning self.einstein_radius; use it in einstein_radius_rescaled and in PowerLaw.deflections_yx_2d_from's Einstein-radius line. Numerically unchanged for all existing profiles (full suite is the regression net).
  2. power_law.py: PowerLawIntermediate(PowerLaw) — same constructor; overrides the hook with the xp-threaded conversion (JAX-safe via self.axis_ratio(xp)); docstring documents the convention and factor.
  3. Namespace exports (profiles/mass/total/__init__.py, profiles/mass/__init__.py) + PowerLawIntermediate: block in config/priors/mass/total/power_law.yaml.
  4. autogalaxy/interop/coolest/mass.py: register PowerLawIntermediate → PEMD (identity θ_E); mass_profile_from(..., intermediate=True) builds PowerLawIntermediate; thread intermediate through autolens/interop/coolest.py::from_coolest.
  5. Tests in test_autogalaxy/profiles/mass/total/ + test_autogalaxy/interop/ + test_autolens/interop/ (numpy-only).
  6. Workspace leg: pip install herculens (dry-run first; --no-deps fallback if it moves the pinned jax 0.10.2), scripts/coolest_herculens_parity.py comparing convergence + deflections from the same COOLEST template; settles empirically whether herculens EPL θ_E is lenstronomy-convention (identity) or carries the SPEMD √((1+q²)/(2q)) factor.

Key Files

  • PyAutoGalaxy/autogalaxy/profiles/mass/total/{power_law,power_law_core}.py
  • PyAutoGalaxy/autogalaxy/interop/coolest/mass.py, PyAutoGalaxy/autogalaxy/config/priors/mass/total/power_law.yaml
  • PyAutoLens/autolens/interop/coolest.py
  • autolens_workspace_test/scripts/coolest_herculens_parity.py (new)

Original Prompt

Click to expand starting prompt

See PyAutoMind/active/coolest_powerlaw_herculens_parity.md.

Activity

  1. Jammy2211 commented on Jul 17, 2026

    @Jammy2211
    CollaboratorAuthor

    All three PRs open — parity PROVEN

    Key empirical result: herculens 0.3.0's EPL theta_E is exactly the COOLEST intermediate-axis convention (probe ratio 1.0 to machine precision — the SPEMD sqrt((1+q²)/(2q)) factor does not apply to EPL). The direct link therefore holds with identity parameters: the same COOLEST template produces matching convergence AND deflection angles in herculens and PyAutoLens (rtol 1e-8 / 1e-6), including the spherical limit.

    Shipped through Heart RED (5 pre-existing unrelated reasons) on user ack. Merge order: PyAutoGalaxy#503 → PyAutoLens#617 → awst#175.

  2. Jammy2211 commented on Jul 17, 2026

    @Jammy2211
    CollaboratorAuthor

    Shipped — 2026-07-17

    PRs (all MERGED, in order)

    Summary

    ag.mp.PowerLawIntermediate is live: a power-law whose einstein_radius is the COOLEST intermediate-axis θ_E, with an identity PEMD mapping and from_coolest(intermediate=True). The parity script proves the direct link to herculens's EPL — same COOLEST template, matching convergence and deflections in both codes, identity parameters throughout (herculens EPL θ_E confirmed to be the COOLEST convention exactly).

    This completes the COOLEST arc from the original Slack thread (#612 + #616).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions