Skip to content

feat(weak-lensing): add WeakDataset + SimulatorShearYX (step 1) - #473

Merged
Jammy2211 merged 2 commits into
mainfrom
claude/list-admin-prompts-Mid1U
May 4, 2026
Merged

Jammy2211 merged 2 commits into
mainfrom
claude/list-admin-prompts-Mid1U

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

Step 1 of the weak-lensing series (issue #472, follow-up to PR #366 in PyAutoGalaxy). Adds the data structures and simulator needed to produce noisy weak-lensing shear catalogues from a Tracer. The shear computation itself was already in place (Tracer's deflection field → LensCalc.shear_yx_2d_via_hessian_from); what's added here is (a) a dataset type that holds the noisy shear field plus its noise map, and (b) a simulator that adds shape noise and (optionally) draws random source-galaxy positions.

Subsequent steps in the series will add FitWeak (#3_fit) and AnalysisWeak (#4_modeling) on top of this dataset.

API Changes

Added two new public symbols, both at the top-level al. namespace:

  • al.WeakDataset(shear_yx, noise_map, name="") — holds a ShearYX2DIrregular + per-galaxy noise map.
  • al.SimulatorShearYX(noise_sigma=0.3, seed=None) — exposes via_tracer_from(tracer, grid, name="") and via_tracer_random_positions_from(tracer, n_galaxies, grid_extent=3.0, name="").

No existing symbols were removed, renamed, or changed. See full details below.

Test Plan

  • python -m pytest test_autolens/weak/ -x — runs new unit + integration tests.
  • python -m pytest test_autolens/ -x — confirm nothing else regressed.
  • (author note) sandbox has no numpy installed; tests were written but not executed here. Please run locally before merging.
Full API Changes (for automation & release notes)

Removed

  • None.

Added

  • autolens.weak.dataset.WeakDataset — re-exported as al.WeakDataset.
    • Constructor: WeakDataset(shear_yx: ShearYX2DIrregular, noise_map: float | ArrayIrregular | List[float], name: str = "").
    • Validates shear_yx type and noise_map length matches shear_yx.
    • Properties: positions (the underlying grid), n_galaxies, info.
    • Method: extent_from(buffer=0.1) -> [y_min, y_max, x_min, x_max].
  • autolens.weak.simulator.SimulatorShearYX — re-exported as al.SimulatorShearYX.
    • Constructor: SimulatorShearYX(noise_sigma: float = 0.3, seed: int | None = None).
    • via_tracer_from(tracer, grid, name="") -> WeakDataset — evaluates the tracer's Hessian-derived shear at grid and adds iid Gaussian noise per shear component.
    • via_tracer_random_positions_from(tracer, n_galaxies, grid_extent=3.0, name="") -> WeakDataset — draws uniform-random (y, x) positions inside [-grid_extent, +grid_extent]^2 and delegates to via_tracer_from.
    • Accepts any input exposing shear_yx_2d_via_hessian_from, deflections_between_planes_from (multi-plane Tracer), or deflections_yx_2d_from (single mass profile / galaxy / galaxies).

Renamed / Changed Signature / Changed Behaviour

  • None.

Migration

  • None — purely additive.

Linked Workspace PR

  • PyAutoLabs/autolens_workspace#... (will be cross-referenced once opened)

Closes #472

🤖 Generated with Claude Code


Generated by Claude Code

Copy link
Copy Markdown
Collaborator Author

Workspace PR: PyAutoLabs/autolens_workspace#84


Generated by Claude Code

claude and others added 2 commits May 4, 2026 12:29
Step 1 of the weak-lensing series. Adds the data structures and simulator
needed to produce noisy weak-lensing shear catalogues from a Tracer:

- WeakDataset: holds a ShearYX2DIrregular shear catalogue + per-galaxy
  noise map, mirroring the PointDataset API style.
- SimulatorShearYX: takes a Tracer (or any object exposing
  shear_yx_2d_via_hessian_from / deflections_yx_2d_from), evaluates the
  noise-free shear via LensCalc, and adds iid Gaussian shape noise per
  shear component. Optional uniform-random source-galaxy positions.
- Unit + integration tests in test_autolens/weak/.
The previous `assert dataset.positions is grid` failed because
`VectorYX2DIrregular.__init__` re-wraps any input grid via
`Grid2DIrregular(values=grid)`. The intent of the test (positions are
preserved by the simulator) is satisfied by value equality.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Jammy2211
Jammy2211 force-pushed the claude/list-admin-prompts-Mid1U branch from f6fe203 to f77ff10 Compare May 4, 2026 11:31
@Jammy2211
Jammy2211 merged commit 79bb150 into main May 4, 2026
5 of 9 checks passed
@Jammy2211
Jammy2211 deleted the claude/list-admin-prompts-Mid1U branch May 4, 2026 11:47
@Jammy2211 Jammy2211 removed the pending-release PR queued for the next release build label Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(weak-lensing): add WeakDataset + SimulatorShearYX (step 1)

2 participants