Skip to content

feat(DatasetModel): add grid_rotation_angle for multi-band rotation#312

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/dataset-model-grid-rotation
May 15, 2026
Merged

feat(DatasetModel): add grid_rotation_angle for multi-band rotation#312
Jammy2211 merged 1 commit into
mainfrom
feature/dataset-model-grid-rotation

Conversation

@Jammy2211
Copy link
Copy Markdown
Collaborator

Summary

  • Adds grid_rotation_angle: float = 0.0 to aa.DatasetModel, in degrees, default 0.0.
  • Adds Grid2D.subtracted_and_rotated_from(offset, angle, xp) and Grid2DIrregular.subtracted_and_rotated_from(...) — shift-then-rotate (CCW about the offset point).
  • FitDataset.grids now applies both transforms to lp / pixelization / blurring grids when building per-iteration grids.
  • Also adds a thin Grid2DIrregular.subtracted_from for API parity with Grid2D.subtracted_from.

Mirrors the existing grid_offset pattern. Default behaviour (no rotation, no offset) is exactly backwards-compatible.

Why

For multi-band fits (e.g. JWST NIRCam at slightly different roll angles), each band's image-plane grid needs to be rotated as well as shifted relative to a reference band before model evaluation. Prototype by @qiuhan06 on dev_Q; this PR is the cleaned-up forward-port. See PyAutoLens#511 for the full diagnosis.

API Changes

  • aa.DatasetModel(..., grid_rotation_angle: float = 0.0) — new optional kwarg.
  • Grid2D.subtracted_and_rotated_from(offset, angle, xp=np) — new method.
  • Grid2DIrregular.subtracted_from(offset, xp=np) — new method (parity).
  • Grid2DIrregular.subtracted_and_rotated_from(offset, angle, xp=np) — new method.

Test plan

  • python -m pytest test_autoarray/ — 767 tests pass on this branch
  • 4 new unit tests for subtracted_and_rotated_from on Grid2D (zero-angle, 90deg, 180deg, shift-first-then-rotate)
  • 4 new unit tests for the same on Grid2DIrregular
  • 3 new tests in test_fit_dataset.py covering FitDataset.grids with rotation, combined offset+rotation, and rotation=0 identity

Refs PyAutoLens#511.

Mirrors the existing grid_offset pattern so each band in a multi-band fit
can be rotated as well as shifted relative to a reference dataset. Adds
Grid2D / Grid2DIrregular.subtracted_and_rotated_from helpers (shift then
rotate CCW about the offset point) and wires FitDataset.grids through
them so lp / pixelization / blurring grids all carry the transform into
the fit.

Refs PyAutoLens#511, prototype by @qiuhan06 on dev_Q.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Jammy2211 Jammy2211 merged commit eeb161a into main May 15, 2026
6 checks passed
@Jammy2211 Jammy2211 deleted the feature/dataset-model-grid-rotation branch May 15, 2026 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant