Skip to content

feat: Keck NIRC2 AO reduction (phases K1-K3, SHARP-grounded) #11

Description

@Jammy2211

Overview

Implement the Keck NIRC2 AO reduction designed in #9, on the post-phase-3 consolidated layout (#10, merged 371721f). This makes PyAutoReduce's fourth instrument family — and its first ground-based one — live: raw KOA level-0 NIRC2 frames → modeling-ready al.Imaging.from_fits datasets. Run under --auto at effective level supervised (feature @ large); ship sign-off will park with a batched question per the contract.

Decisions adopted from #9's batched set (user-resolved 2026-07-09): drizzle-package combine backend, B1938+666 (SHARP I) validation anchor, and sequencing resolved by the #10 merge.

Plan

  • Ship docs/design/keck_ao.md (the parked research: plan the Keck NIRC2 AO reduction workflow (SHARP context) #9 write leg, adopting post-refactor module names) + roadmap update.
  • K1 — acquire + calibrate + sky: KOA/PyKOA acquire backend behind an archive seam; new ground-based calibrate stage (DN→e⁻, dark, flat, bad-pixel) and sky stage (temporally adjacent object-masked running sky).
  • K2 — dewarp + combine + noise: Yelda 2010 / Service 2016 distortion solutions as the pixel mapping through the STScI drizzle package; cross-correlation registration; first-principles noise map (sky + dark + read/√coadds + Poisson, coverage-propagated, × Casertano R).
  • K3 — PSF tiers + package + validation: provisional-PSF contract (PSF-star candidate products, psf_provisional provenance, AO-conditions block); unchanged output contract; B1938+666 validation per the four acceptance checks on research: plan the Keck NIRC2 AO reduction workflow (SHARP context) #9.
Detailed implementation plan

Work Classification

Library (PyAutoReduce).

Affected Repositories

  • PyAutoReduce (primary)

Branch Survey

Repository Current Branch Dirty?
./PyAutoReduce main @ 371721f clean (claim released by refactor-post-phase3)

Suggested branch: feature/keck-ao-reduction
Worktree root: ~/Code/PyAutoLabs-wt/keck-ao-reduction/

Implementation Steps

  1. docs/design/keck_ao.md from the draft on research: plan the Keck NIRC2 AO reduction workflow (SHARP context) #9 + docs/design/roadmap.md ground-based section.
  2. autoreduce/instruments/nirc2.py adapter (camera plate scales 9.942/39.686 mas, gain, read noise per coadd, distortion-solution selection by date: Yelda 2010 pre-2015-04-13 / Service 2016 after) + acquire-backend seam (koa | mast) with PyKOA TAP queries for science + night calibrations + PSF-star frames.
  3. autoreduce/calibrate/ (new stage): DN→e⁻, dark subtraction, flat-field, bad-pixel mask. numpy/astropy only.
  4. autoreduce/sky/ (new stage): running median sky from N temporally adjacent object-masked frames, iterative mask update, per-frame sky level recorded for the noise stage.
  5. K2 in autoreduce/drizzle/ (post-refactor _common.py seams): dewarp-as-drizzle-mapping, cross-correlation registration, combine at 10 mas (narrow) / 40 mas (wide) with optional 2×2 binning dial; noise construction + Casertano R; blank-sky closure check.
  6. K3 in autoreduce/psf/ + package: PSF-star pipeline-identical reduction → candidate products, provenance extensions (psf_provisional, FWHM/epoch/tip-tilt distance, AO-conditions block).
  7. Unit tests in test_autoreduce/ (numpy/astropy-only, synthetic frames). Prototype/validation script prototypes/b1938_keck_spike.py + scripts/reduce_b1938.py for the real-data leg (network; results reported on this issue, FITS never committed).
  8. Four-leg ship gate → park at sign-off (supervised).

Key Files

  • docs/design/keck_ao.md, docs/design/roadmap.md
  • autoreduce/instruments/, autoreduce/acquire/, autoreduce/drizzle/_common.py, autoreduce/noise/, autoreduce/psf/, autoreduce/pipeline.py
  • autoreduce/calibrate/, autoreduce/sky/ (new)
  • test_autoreduce/, prototypes/, pyproject.toml (new deps: pykoa, drizzle)

Original Prompt

Click to expand starting prompt

Original request: "A large refactor of PyAutoReduce just merge in, so combine that with this research to get keck-ao data reduction live --auto"

(Full prompt: PyAutoMind feature/pyautoreduce/keck_ao_reduction.md; design + research context: #9.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions