Repository navigation
Description
Overview
Make the Lenstool-native parameterization the default dPIE mass profile, so al.mp.dPIEMass / dPIEMassSph expose exactly the parameters readers of Lenstool cluster papers expect (ellipticity, angle_pos, sigma = fiducial v_disp, r_core, r_cut), with the internal ra/rs/b0 parameterization demoted to a clearly-non-standard variant. Re-verify every convention against the Lenstool source/papers, then sweep the downstream workspace (cluster/group examples and the SLaM pipelines, absorbing the deferred lenstool-scaling-slam PR3 from autolens_workspace#265) so the whole stack presents one consistent, standard prescription. End goal: our dPIE perfectly matches the standard Lenstool prescription, so readers of those papers know exactly what our model is doing.
Motivated by the referee comment on the scaling-relation parameterization (Eq. 5) and the follow-up Slack discussion (2026-07): the community convention is reference-anchored Faber–Jackson (σ ∝ L^¼, r_cut ∝ L^½, exponents fixed; normalization the only free parameter), and the dPIE with Lenstool-native parameters is the profile family those papers use.
Plan
- Verify the parameterization conventions against Limousin et al. 2005, Elíasdóttir et al. 2007 (App. A), Bergamini et al. 2019 (Eq. 5) and the Lenstool C source; record the audit in the PR.
- Swap the class hierarchy in PyAutoGalaxy:
dPIEMass/dPIEMassSphtake the Lenstool-native constructor; internalra/rs/b0variant becomesdPIEMassB0/dPIEMassB0Sphplus adPIEMass.from_b0(...)classmethod. - Update priors config, exports, unit tests, docstrings.
- Workspace sweep: cluster suite, group scaling_relation, guides, weak a2744 onto the new default with the reference-anchored scaling convention; apply the same convention consistently through the group/cluster SLaM pipelines (absorbs the deferred
lenstool-scaling-slamtask). - Re-validate the Lenstool parity scripts in autolens_workspace_test.
Detailed implementation plan
Affected Repositories
- PyAutoGalaxy (primary — library phase)
- autolens_workspace (workspace phase)
- autolens_workspace_test (parity re-validation)
Branch Survey
| Repository | Current Branch | Dirty? | Claim |
|---|---|---|---|
| ./PyAutoGalaxy | main | clean | claimed by potential-correction-port (PR#505 in flight) — this task queues behind it |
| ./autolens_workspace | main | clean | free |
| ./autolens_workspace_test | main | clean | free |
Suggested branch: feature/dpie-lenstool-default
Worktree root: ~/Code/PyAutoLabs-wt/dpie-lenstool-default/ (created by /start_library)
Work classification: Both (library first, workspace follow-up)
Phase 1 — PyAutoGalaxy (library)
All in autogalaxy/profiles/mass/total/dual_pseudo_isothermal_mass.py:
- Paper/source audit (before code): confirm against Lenstool C source and the papers:
sigmais the fiducial v_disp σ_LT, not central σ₀ (σ₀ = √(3/2)·σ_LT — Elíasdóttir 2007 App. A; Bergamini 2019 Eq. 5).b0 = 6·648000·(σ_LT/c)²·(D_LS/D_S)arcsec, distance ratio folded in (Lenstool applies it at deflection time; ours is fully normalized).ellipticityis Lenstool's emass = (a²−b²)/(a²+b²), converted internally to epot = (1−q)/(1+q) = |ell_comps|.r_core/r_cutmap 1:1 ontora/rs(arcsec; kpc variants pre-converted by caller).- Scaling-relation form: σ = σ*·(L/L*)^¼, r_cut = r_cut*·(L/L*)^½ anchored to a reference luminosity (BCG/BGG or L*), exponents fixed (Faber–Jackson), only normalization free ⇒ θ_E ∝ L^½.
- Class swap:
- Rename current
dPIEMass→dPIEMassB0,dPIEMassSph→dPIEMassB0Sph(all math —_ci05f,_mdci05,_pi05, deflections/convergence/potential/hessian — stays here unchanged). - Rename
dPIEMassLenstool→dPIEMass,dPIEMassLenstoolSph→dPIEMassSph(subclassing the B0 classes; constructor signaturecentre, ellipticity, angle_pos, sigma, r_core, r_cut, redshift_object, redshift_source, H0, Om0— H0/Om0 remain flat-float model constants). - Move
from_lenstoolsemantics into the default constructor; adddPIEMass.from_b0(centre, ell_comps, ra, rs, b0)/dPIEMassSph.from_b0(...)classmethods returning the B0 variant (the non-standard construction path, per the approved design). - Docstrings: default class documents the Lenstool prescription + paper refs; B0 variant explicitly labelled non-standard/internal.
- Rename current
- Config/exports: update
autogalaxy/profiles/mass/total/__init__.py,mass/__init__.py; updateautogalaxy/config/priors/mass/total/dual_pseudo_isothermal_mass.yaml(priors keyed per class — sensible Lenstool-style priors on sigma/r_core/r_cut for the default; keep B0 entries). - Tests:
test_autogalaxy/profiles/mass/total/— rename/extend so both parameterizations are covered; equivalence testdPIEMass(...) ≡ dPIEMassB0(from converted params); NumPy-only (no JAX in unit tests). - Serialization note: any saved results referencing old
dPIEMass(ra/rs/b0 signature) will not load into the new class — acceptable (profile shipped 2026-07, no release users yet); call out in PR body.
Phase 2 — autolens_workspace (workspace)
scripts/cluster/{modeling,simulator,csv_api,likelihood_function,start_here}.py+scripts/cluster/lenstool/{modeling,data}.py: swap to new default names; express the scaling tier in Lenstool form (reference-anchored: free normalization on the reference member, exponent fixed 0.5, r_cut ∝ L^0.5 truncation scaling).scripts/group/features/scaling_relation/modeling.py: same convention (per the Slack-settled design:einstein_radius_refon the brightest scaling member, luminosity ratios only).- SLaM pipelines (absorbs
lenstool-scaling-slam, planned.md): apply the reference-magnitude convention consistently throughscripts/group/slam.py+ group/cluster-relevantfeatures/*/slam.pyvariants — the previously-deferred PR3 of autolens_workspace#265. - Guides:
scripts/guides/profiles/mass.py,light_and_mass_profiles.py;scripts/weak/features/strong_lensing/a2744.py. - CSV API: cluster
mass.csvprofile-name mapping updated in lockstep with the library rename. - Notebook regen gotcha (from Feature/gaussian mass #265):
generate.py autolenssurfaces pre-existing catalogue drift — stage only task-scoped files.
Phase 3 — autolens_workspace_test
scripts/cluster/{lenstool_parity,likelihood_sanity,csv_api,simulator}.py,scripts/mass/total.py: update names, re-run parity — deflections/convergence/potential must still match Lenstool like-with-like.
Key Files
PyAutoGalaxy/autogalaxy/profiles/mass/total/dual_pseudo_isothermal_mass.py— the whole profile family (PIEMass, dPIE variants,_b0_from_lenstool_sigma).PyAutoGalaxy/autogalaxy/config/priors/mass/total/dual_pseudo_isothermal_mass.yaml— priors per class name.autolens_workspace/scripts/cluster/modeling.py— cluster scaling tier (b0 = scaling_factor·L^exp today).autolens_workspace_test/scripts/cluster/lenstool_parity.py— the like-with-like Lenstool match.
Notes
- Feature Agent scored this too-large / 4 phases; overridden to the standard 2-stage library→workspace routing under one task — design already settled by the existing
dPIEMassLenstoolwrapper (PyAutoGalaxy@0a8c6bb4) and the Slack-converged convention. dPIEPotential/dPIEPotentialSph(O'Donnell port) are out of scope.- PyAutoLens needs no source change (re-exports
ag.mp).
Original Prompt
Click to expand starting prompt
The final step now is to make our default dPIE the LensTool one, whereas before
I think we made it a classmethod of it, so swap them (e.g. the classmethod can
be the current one which is non standard). Also, compare again to some lens
tool papers to make sure we have the same parameterization, especially given
that SLACK chat, and note that we had some issues making sure our slam.py
pipelines are updated throughout in a consistent fashion. The end goal is for
our dPIE to perfectly match the standard LensTool prescription, so readers of
those papers know exactly what our model is doing.
Full prompt: PyAutoMind/active/dpie_lenstool_default_parameterization.md (context: referee comment on Eq. 5 scaling-relation parameterization + 2026-07 Slack discussion converging on the reference-anchored Faber–Jackson convention).
Activity
Jammy2211 commentedon Jul 17, 2026
Paper/convention audit (pre-implementation, read-only)
Verified the current implementation (
dual_pseudo_isothermal_mass.py@ main, incl._b0_from_lenstool_sigmaand thedPIEMassLenstool*wrappers) against Elíasdóttir et al. 2007 (arXiv:0710.5636, App. A), Bergamini et al. 2019 (A&A 631, A130), and the existing 6-leg parity script (autolens_workspace_test/scripts/cluster/lenstool_parity.py, which pins the Lenstool C source numerically). All conventions check out; no code-level convention changes are needed for the swap — it is purely a re-parameterization of which class is default.b0 = 6·648000·(σ_LT/c)²·(D_LS/D_S)arcsec, distance ratio folded inb0 = 6·pia_c2·σ²(set_potfile.c) and applies D_LS/D_S at deflection time (e_grad.c)b0·rs/(rs−ra)with b0 = E₀·(rs²−ra²)/rs²sigma= fiducial σ_LT (v_dispin.par), never central σ₀v_dispoverestimates mass by 50%ellipticity= emass = (a²−b²)/(a²+b²); internal epot = (1−q)/(1+q) = |ell_comps|.parfiles and paper tables quote; potential substitution R̃² = X²/(1+ε)² + Y²/(1−ε)² (A21) is exactly ourr_emwith ε = epot; conversions identical: (1−√(1−ε̂²))/ε̂ ≡ (1−q)/(1+q)r_core/r_cut(arcsec) ↔ra/rs1:1; kpc variants pre-converted by callercore_radius/cut_radiusangle_posCCW in the tangent plane; WCS flips handled at ingestion (cluster/lenstool/data.py, verified to mas against galcat↔best.par)Notes for implementation:
dPIEMassshould put sensible ranges onsigma(km/s),r_core,r_cut(arcsec) mirroring published tables, and the workspace scaling tier expresses everything through the two reference normalizations.sis not strictly a truncation radius (ρ ∝ r⁻⁴ beyond, not a hard cut) — keep the docstring language "scale/truncation radius" as-is with the caveat..par-style σ_LT directly; docstrings already warn against feeding measured stellar dispersions.Audit basis: Elíasdóttir et al. 2007 App. A (A1–A32), Bergamini et al. 2019 (A&A version), Lenstool C source conventions as pinned by the parity script, SMACS J0723 end-to-end reconstruction (
cluster/lenstool/, Mahler et al. 2023 model).Task is queued behind
potential-correction-port(PyAutoGalaxy claim, PR #505); library phase starts when that frees.Jammy2211 commentedon Jul 17, 2026
Library PR Created
PR: #509 (
pending-release; full suite 1003 passed; shipped under human-acked pre-existing Heart RED reasons — see session log)API changes (breaking rename-swap, no numerical changes):
dPIEMass/dPIEMassSph= Lenstool-native parameterization (formerlydPIEMassLenstool*); internal(ra, rs, b0)variant →dPIEMassB0/dPIEMassB0Sph+from_b0classmethods; priors yaml re-keyed;from_lenstoolnow on the B0 classes.Workspace impact — option (ii), migration required. Affected downstream scripts (grep-verified):
autolens_workspace:cluster/{modeling,simulator,csv_api,likelihood_function,start_here}.py,cluster/lenstool/{modeling,data}.py+ README,group/features/scaling_relation/modeling.py,guides/profiles/{mass,light_and_mass_profiles}.py,weak/features/strong_lensing/a2744.py(+ generated notebooks)autolens_workspace_test:cluster/{lenstool_parity,likelihood_sanity,csv_api,simulator}.py,mass/total.pyautolens_workspace_developer:visualization_profiling/imaging/cluster.py,scaling_relation_agg/error_make.py,jax_profiling/simulators/cluster.pylenstool-scaling-slam, PR3 of autolens_workspace#265)Next:
/start_workspace— migrate the scripts onto the new default, express the scaling tier in the reference-anchored Lenstool convention throughout (incl. slam.py pipelines), re-run the 6-leglenstool_parity.py.Jammy2211 commentedon Jul 17, 2026
Workspace phase shipped
pending-release)pending-release)Highlights: cluster suite now modeled in σ_LT-space (Lenstool
.parparameters; scaling tier's single free parameter issigma_refin km/s — the referee's interpretable normalization); simple + a2744 datasets converted/regenerated (multiple-image collapse re-verified at ~1e-4"); group SLaM pipelines migrated to the reference-anchoredeinstein_radius_ref · (L/L_BGG)^0.5convention (absorbs the deferredlenstool-scaling-slam, PR3 of autolens_workspace#265); 6-leg Lenstool parity + new default-class leg all pass; FD sweeps pass for both parameterizations.Validation: check_sizes clean; csv_api/guides run clean; modeling + likelihood_function end-to-end in TEST_MODE (N=12); notebooks regenerated (pre-existing potential-correction catalogue drift excluded). Pre-existing, out-of-scope:
dPIEPotentialgrad(ψ)=α FD failure inmass/total.py(O'Donnell profile, untouched);database/scrape/scaling_relation.pyintentionally keeps its two-free-parameter compound-prior form (that's what it tests).Merge order: PyAutoGalaxy#509 → autolens_workspace#287 + autolens_workspace_test#179. Follow-up (unclaimed repo, not in this task): 3
autolens_workspace_developerscripts still reference the old parameterization.Jammy2211 commentedon Jul 17, 2026
Merged — task complete
All three PRs merged 2026-07-17:
potential_correction/subhalo_recovery.py(statistical dkappa-correlation assertion, already red on main from the potential-correction regression work — not introduced by this task).Close-out note (bug caught during merge): a2744
start_herecomposed N=26 instead of N=22 — the defaultdPIEMassconfig carriesH0/Om0priors, so a main lens built from a CSV lacking those columns floated the two cosmology constants as free parameters. Fixed by pinningH0/Om0in the cluster composition loops + adding the columns to the a2744 mass.csv/prep.py (commit on #287). Simulator-written CSVs (simple) already carried them.The dPIE now matches the standard Lenstool prescription end to end: default
dPIEMass/dPIEMassSphtake the.parparameters (ellipticity, angle_pos, sigma=v_disp, r_core, r_cut); scaling tiers are reference-anchored (fixed Faber-Jackson exponents, single free normalization); the internal ra/rs/b0 form isdPIEMassB0/dPIEMassB0Sph+from_b0. Closing.Follow-ups (separate, unclaimed here): pre-existing
subhalo_recovery.pysmoke failure on main; 3autolens_workspace_developerscripts still on the old parameterization.