Skip to content

feat: add stellar + dark + lmp light-and-mass profiles guide #180

Description

@Jammy2211

Overview

Follow-up to #178 (shipped via #179). This task adds
scripts/guides/profiles/light_and_mass_profiles.py to autolens_workspace, the third and
final guide in the profiles/ folder — paired with light.py (#86 / #87) and mass.py
(#179). Where those two cover pure light and parametric lens mass respectively, this
guide covers the stellar + dark + combined light-and-mass profiles that decompose a
lens galaxy into its constituent matter components.

Scope:

  • Stellar mass profiles in al.mp.* (Sersic, Chameleon, Gaussian, GaussianGradient,
    SersicCore, SersicGradient, DevVaucouleurs, Exponential + *Sph variants).
  • Dark-matter mass profiles in al.mp.* — the NFW family (NFW, gNFW, cNFW, NFWTruncated)
    plus their MCR (mass-concentration), virial-mass, and scatter variants.
  • Combined light-and-mass profiles in al.lmp.* — one object emits both
    image_2d_from (light) and convergence_2d_from (mass) through a shared
    mass_to_light_ratio.
  • Linear combined light-and-mass profiles in al.lmp_linear.* — the inversion-aware
    variant of the lmp family.

This completes the three-guide set agreed in #178: pure light, pure lensing mass, and
matter-decomposition.

Plan

  • Add scripts/guides/profiles/light_and_mass_profiles.py to autolens_workspace,
    structured as a single-page tour of every stellar / dark / lmp / lmp_linear profile.
  • Mirror the section flow of light.py and mass.py so the three guides read as a coherent
    set; use the same """__Section__""" docstring-as-prose style.
  • Detailed stellar example uses al.mp.Sersic (stellar mass parameterised by intensity +
    effective_radius + sersic_index + mass_to_light_ratio); show convergence_2d_from and the
    lensed source image through a Tracer.
  • Detailed dark example uses al.mp.NFW; show convergence_2d_from, plot in log10 to
    highlight the cuspy profile, explain kappa_s / scale_radius.
  • Dedicated section for the NFW variant menagerie — MCR (Duffy / Ludlow concentration-mass
    relations), Virial-mass parameterisations, Scatter (Ludlow-with-scatter), and Truncated.
    One-liner construction + a sentence on when to use each.
  • Combined-light-and-mass section uses al.lmp.Sersic and shows that the same object emits
    both image_2d_from (light) and convergence_2d_from (mass) via the shared
    mass_to_light_ratio parameter — this is the headline feature of the lmp namespace.
  • Linear combined-light-and-mass section explains al.lmp_linear.* (intensity-via-inversion
    variant) and notes the linear semantics carry over from lp_linear.* to the joint
    light+mass treatment; points readers to scripts/imaging/features/linear_light_profiles/
    for the workflow.
  • Composing-a-decomposed-bulge+halo-model section builds a realistic af.Model with a
    stellar Sersic mass + NFW halo on the lens galaxy and prints model.info, then realises
    an instance via prior medians and drops it into a Tracer.
  • Remaining Profiles Walkthrough compact-lists every stellar / dark / lmp / lmp_linear
    profile not already shown, with one short convergence_2d_from (or image_2d_from for
    the lmp light side) block per profile.
Detailed implementation plan

Affected Repositories

  • autolens_workspace (primary) — new guide
  • PyAutoLens — read-only reference
  • PyAutoGalaxy — read-only reference

Work Classification

Workspace (autolens_workspace only).

Branch Survey

Repository Current Branch Dirty? Notes
./autolens_workspace main dirty (smoke-run dataset noise) worktree gets a clean copy
./PyAutoLens main clean reference only
./PyAutoGalaxy main clean reference only

Suggested branch: feature/light-mass-profiles-guide
Worktree root: ~/Code/PyAutoLabs-wt/light-mass-profiles-guide/
Routing: workspace-dev/start_workspace.

Section Layout (11 sections)

  1. Overview & Docs URL — explain the three-guide split: light.py (light), mass.py
    (parametric lens mass), this guide (stellar + dark + lmp decomposition). Link to the
    published API reference.
  2. All Profiles (Survey) — catalogue of every stellar / dark / lmp / lmp_linear class
    with one-line construction, no quantity evaluation.
  3. Stellar Mass Detailed Exampleal.mp.Sersic(intensity=..., effective_radius=..., sersic_index=..., mass_to_light_ratio=...). Plot convergence_2d_from and the lensed
    source image via Tracer.
  4. Dark Mass Detailed Exampleal.mp.NFW(centre, ell_comps, kappa_s, scale_radius).
    Plot convergence_2d_from (linear) and convergence_2d_from (log10) to show the cusp.
  5. NFW VariantsgNFW (free inner slope), cNFW (cored NFW), NFWTruncated,
    NFWMCR* (Duffy / Ludlow concentration-mass relations remove one free parameter),
    NFWMCRScatter* (Ludlow with concentration scatter), *VirialMassConc* (parameterised
    by M_200 + concentration). One-line construction per family + a sentence on when each
    is appropriate.
  6. Combined Light + Mass Profiles (al.lmp)al.lmp.Sersic showing the same object
    evaluates image_2d_from (light) AND convergence_2d_from (mass) via shared
    mass_to_light_ratio. Plot both side-by-side. This is the headline feature.
  7. Linear Combined Light + Mass (al.lmp_linear) — one-line API; explain the intensity-
    via-inversion semantics carry over from al.lp_linear. Point to
    imaging/features/linear_light_profiles/ for the fitting workflow.
  8. Composing a Decomposed Bulge+Halo Modelaf.Model(al.Galaxy, redshift=0.5, bulge=af.Model(al.mp.Sersic), dark=af.Model(al.mp.NFW)) for the lens; bog-standard
    Sersic for the source. Print model.info. Note the API is identical to swapping a
    parametric Isothermal.
  9. Model Instance from Decomposed Modelinstance_from_prior_medians() on the
    collection; build a Tracer; plot tracer.image_2d_from.
  10. Remaining Profiles Walkthrough — compact convergence_2d_from block per stellar /
    dark / lmp / lmp_linear profile not yet shown. For al.lmp.* profiles also show
    image_2d_from to drive home the dual-output property.
  11. Back-References — closing pointer to light.py and mass.py as the companion
    guides in the same folder.

Verification Approach

  1. Verify constructor signatures by reading source before adding each profile — light.py
    bit on SersicCore.intensity_break and mass.py bit on dPIEMass(ell_comps=(0,0)) are
    the same gotcha to avoid.
  2. Verify plotting compatibility — same np.hypot / Array2D wrap pattern from
    mass.py for vector quantities. lmp image_2d_from should return Array2D like the
    light side; convergence_2d_from likewise.
  3. Smoke-run the new script under PYAUTO_TEST_MODE=2 + all skip flags before
    /ship_workspace.

Key Files

  • autolens_workspace/scripts/guides/profiles/light_and_mass_profiles.py — new
  • autolens_workspace/.script_sizes.json — refresh
  • autolens_workspace/scripts/guides/profiles/__init__.py — already exists, no change

Style / constraint notes

  • Workspace docstring-as-prose style ("""__Section__""" headers).
  • Science-teaching prose stays on Opus.
  • Mirror the section flow of light.py / mass.py so the three guides read as a triplet.
  • Out of curated smoke_tests.txt (small-subset policy).

Original Prompt

Click to expand starting prompt

Follow-up to mass_profiles.md (issue #178, shipped via #179): add a
scripts/guides/profiles/light_and_mass_profiles.py guide to
autolens_workspace, paired with the existing light.py (#86/#87) and
mass.py (#179) guides in the same folder.

Scope (per user direction):

  • Stellar mass profiles in al.mp.* (Sersic, Chameleon, Gaussian,
    GaussianGradient, SersicCore, SersicGradient, DevVaucouleurs,
    Exponential + *Sph variants).
  • Dark-matter mass profiles in al.mp.* (NFW family: NFW, gNFW, cNFW,
    NFWTruncated, plus their MCR / virial-mass / scatter variants).
  • Combined light-and-mass profiles in al.lmp.* (one object emitting
    both image_2d_from and convergence_2d_from via a shared
    mass_to_light_ratio).
  • Linear combined light-and-mass profiles in al.lmp_linear.*
    include alongside the standard lmp profiles.

Section flow mirrors light.py / mass.py so the three guides read as
a coherent set.

Activity

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