Repository navigation
Description
Overview
Plan how PyAutoReduce reduces Keck adaptive-optics (NIRC2) imaging of strong lenses into modeling-ready datasets for PyAutoLens/PyAutoGalaxy, alongside the existing HST (ACS/WFC3) and JWST (NIRCam) phases. The scientific grounding comes from the SHARP programme (Strong-lensing at High Angular Resolution Programme) papers, which are the reference practice for AO strong-lens imaging. Deliverable is a design/plan document (docs/design/keck_ao.md), not code — implementation phases become follow-up prompts.
This run is --auto at effective level supervised (research cap). Plan below per the autonomy contract; judgment forks will be batched as comments here.
Plan
- Read the SHARP survey papers (Fassnacht, Chen, Vegetti, McKean et al.) plus the standard Keck/NIRC2 reduction references (NIRC2 distortion solutions, the KAI pipeline) and extract what AO imaging demands of a lensing reduction — above all the time-variable, poorly-known AO PSF.
- Survey existing NIRC2 reduction tooling and decide wrap-vs-implement per PyAutoReduce's "default pipelines first" boundary.
- Map the AO reduction onto PyAutoReduce's stage architecture (
acquire/align/drizzle/noise/psf/package+instruments/adapters); identify genuinely new stages (sky subtraction, PSF estimation strategy) vs per-stage deltas. - Choose a validation anchor: a SHARP lens with public Keck Observatory Archive (KOA) NIRC2 data, with defined quality/parity checks.
- Write
docs/design/keck_ao.md(per-stage deltas vs the HST design, followingjwst.md) and updatedocs/design/roadmap.md. - Enumerate implementation phases as follow-up PyAutoMind prompts.
Sequencing note: PyAutoReduce is currently claimed by refactor-post-phase3 (#8, in-place). The research legs are read-only and proceed now, with findings and the draft design content landing on this issue; the repo-write leg (keck_ao.md + roadmap + PR) is parked until that task ships. If the refactor changes the stage/module layout, the design doc adopts the post-refactor names before writing.
Detailed implementation plan
Work Classification
Library (PyAutoReduce) — design doc only, no source changes in this task.
Affected Repositories
- PyAutoReduce (primary)
Branch Survey
| Repository | Current Branch | Dirty? |
|---|---|---|
| ./PyAutoReduce | refactor/post-phase3-consolidation | clean (claimed in-place by refactor-post-phase3) |
Suggested branch: feature/keck-ao-reduction-plan (created only for the write leg, in a task worktree — the main checkout stays with the refactor)
Worktree root: ~/Code/PyAutoLabs-wt/keck-ao-reduction-plan/ (deferred until the write leg unblocks)
Implementation Steps
- Literature pass — SHARP series papers (the AO-imaging lens-modelling and H0 papers carry the most reduction detail, esp. PSF handling); NIRC2 geometric-distortion solutions (Yelda et al. 2010, Service et al. 2016); the KAI (Keck AO Imaging) pipeline as the community reduction baseline. Extract per-stage requirements: calibration (darks/flats/bad-pixel), sky subtraction, distortion correction, frame registration + coaddition, noise-map construction, PSF strategy.
- Requirements → architecture mapping — table of PyAutoReduce stages vs AO needs:
acquire(KOA archive access, e.g. PyKOA/astroquery vs MAST),align/drizzle(dewarp + shift-and-add vs drizzle of dithered frames),noise(read noise + Poisson + sky-dominated regime),psf(the AO-specific problem: field-star PSF, PSF-as-free-model, reconstruction — what the output contractpsf.fits/psf_full.fitsshould mean when the PSF is uncertain),package(unchangedal.Imaging.from_fitscontract). - Wrap-vs-implement per stage — deviation from community-standard tooling must be justified by a lensing requirement (repo boundary rule).
- Validation anchor — pick a SHARP lens with public KOA NIRC2 narrow-camera data; define checks (astrometric parity vs HST imaging of the same lens, photometric sanity, noise-map statistics, PSF sanity/fit quality).
- Write the design doc —
docs/design/keck_ao.mdmirroringjwst.md's "per-stage deltas vs the HST design" pattern + roadmap update. (Parked leg — needs the PyAutoReduce claim.) - Follow-up prompts — phase decomposition for implementation (e.g.
instruments/nirc2adapter, sky stage, PSF stage extension).
Key Files
docs/design/keck_ao.md— the deliverable (new)docs/design/roadmap.md— ground-based/AO section updatedocs/design/hst_acs_pipeline.md— the baseline design the deltas are written againstdocs/design/jwst.md— the per-stage-delta pattern to followautoreduce/instruments/— adapter pattern the plan must respect
Original Prompt
Click to expand starting prompt
Plan the Keck adaptive-optics (NIRC2 AO) data-reduction workflow
Type: research
Target: PyAutoReduce
Difficulty: medium
Autonomy: supervised
Priority: normal
Status: formalised
Original request: "For PyAutoReduce can you plan out how we reduce keck-AO data, read SHARP papers for scientific context."
Plan the Keck adaptive-optics (NIRC2 AO) imaging data-reduction workflow for PyAutoReduce — how raw Keck AO data becomes modeling-ready datasets for PyAutoLens/PyAutoGalaxy, alongside the existing HST (ACS/WFC3) and JWST (NIRCam) phases. Read the SHARP (Strong-lensing High Angular Resolution Programme) papers for scientific context on AO strong-lens imaging — PSF handling (AO PSFs are time-variable and poorly known, unlike HST/JWST), sky subtraction, distortion correction, and coaddition. Deliverable is a design/plan document, not code.
Activity
Jammy2211 commentedon Jul 9, 2026
Research complete — findings + draft
docs/design/keck_ao.mdThe literature and tooling passes are done. Below: (1) what the SHARP papers and the NIRC2 tooling landscape actually say, (2) the full draft design doc (per-stage deltas vs the HST design,
jwst.mdpattern), (3) proposed phasing, and (4) three batched decisions (recommendations stated; defaulting to them unless overridden). The repo write leg stays parked onrefactor-post-phase3(#8).1. Findings
The SHARP series (what each paper contributes to reduction design)
Supporting reduction craft (the Auger-method lineage, e.g. Marshall et al. 2007, SWELLS Treu et al. 2011): dithered exposures; sky from temporally adjacent object-masked frames, masks updated iteratively; B-spline residual background removal; geometric distortion corrected and frames combined with drizzle (Fruchter & Hook 2002).
The AO-specific physics the design must respect: the PSF is time-variable and spatially variable, there is usually no star inside the ~10″ narrow-camera field, and K′ sky varies on minutes timescales — so PSF and sky handling, trivial for HST/JWST, become first-class stages.
Tooling landscape (the wrap-vs-implement input)
Wrap-vs-implement verdict: implement the NIRC2 stages natively (numpy/astropy/photutils/scipy — every operation is a simple array op: dark/flat/sky/dewarp/coadd), justified under the "default pipelines first" rule by the absence of any maintained default; use the
drizzlePyPI package (STScI-maintained — the same resampling engine inside JWSTresample) for the dewarp+combine step, which keeps the drizzled-PSF invariant and the Casertano correlated-noise machinery intact. Cross-check against KAI outputs is optional (py2.7 conda env cost) — the SHARP-paper numbers and internal closures are the primary validation.2. Draft
docs/design/keck_ao.md3. Proposed phasing (follow-up prompts, issued one at a time per queue discipline)
4. Batched decisions (supervised checkpoint — proceeding on the recommendations unless redirected)
drizzlepackage (recommended) vs pure-interpolation dewarp+stack (SHARP's own pipeline style). Drizzle keeps the correlated-noise (R) and drizzled-PSF machinery shared with HST/JWST; the SHARP-parity counterargument is that their products were interpolation-combined, but our acceptance bar is internal consistency + published-number parity, not pixel-level reproduction.keck_ao.md+ roadmap update afterrefactor-post-phase3ships (recommended), adopting post-refactor module names; K1 implementation follows as its own prompt. Alternative: take a parallel docs-only claim now (new file, low collision risk) — declined by default since the refactor is actively consolidating stage layout.Sources beyond those linked above: KAI docs, PyKOA NIRC2 guide.
feat: Keck NIRC2 AO reduction via B1938+666 (phase 4) (#12)
Jammy2211 commentedon Jul 9, 2026
Design delivered:
docs/design/keck_ao.mdmerged to main in #12 (44a8d1a), implementing the K1–K3 plan drafted here with the user-adopted decisions (drizzle backend, B1938+666 anchor). Validated on the SHARP I discovery data — closure 0.883, PSF FWHM 72 mas. Follow-ups (astrometric/Einstein-radius acceptance, wide camera, CR rejection at combine) are tracked as keck_ao.md open items for their own prompts. Closing.