Skip to content

Migrate batch_pipeline.py coadd from mosaic_day to canonical implementation #77

Description

@jakobtfaber

What to build

Execute ADR 0001 from #76: make the package the canonical home for the production hourly-epoch coadd by absorbing production mosaic_day behavior into dsa110_continuum.mosaic, then make scripts/batch_pipeline.py call that package entry point instead of importing scripts/mosaic_day.py for coadd construction.

Current production call site:

  • scripts/batch_pipeline.py imports mosaic_day as _md and calls _md.build_common_wcs(...) + _md.coadd_tiles(...) around the epoch mosaic build.
  • scripts/mosaic_day.py currently owns PB_CUTOFF = 0.2, group_tiles_by_ra(...), build_common_wcs(...), and coadd_tiles(...).
  • dsa110_continuum.mosaic.builder.build_mosaic is the package Quicklook builder and owns the existing RA-wrap regression behavior, but it must not be promoted as-is because it does not implement the production beam-map blanking / strip-grouping semantics.

Concrete ADR-derived behavior to implement:

  • Canonical entry point: create or designate a package entry under dsa110_continuum.mosaic for production hourly-epoch coadds. It may wrap/refactor existing builder.build_mosaic, but it must be callable by scripts/batch_pipeline.py without importing scripts/mosaic_day.py.
  • Primary-beam blanking: preserve production blanking at PB_CUTOFF = 0.2 before coadd when WSClean *-beam-0.fits companions exist. This is not the package builder's compute_pb_correction_map(pb_cutoff=0.1) floor; keep those concepts separate.
  • Primary-beam model source: production batch coadds must use WSClean's per-tile beam model from disk when available. The analytic Airy-disk model can remain a fallback/Quicklook/simulation path, but it is not the production beam source.
  • Strip grouping: preserve 10-degree RA gap strip grouping for day-batch and UTC-hour batch inputs so disjoint tile sets do not produce oversized mosaics. Sliding-window streaming inputs may bypass this only when the trigger has already selected a single contiguous Dec strip window.
  • RA wrap: preserve the circular-mean WCS behavior from the package builder / existing regression. Tile sets crossing 0 deg RA must produce a compact output centre, not an arithmetic-mean centre.

Acceptance criteria

  • scripts/batch_pipeline.py no longer imports or calls scripts/mosaic_day.py for epoch coadd construction (build_common_wcs, coadd_tiles, or group_tiles_by_ra).
  • The canonical package entry implements or delegates the ADR 0001 behavior: 20% WSClean beam-map blanking, WSClean beam-map source for production, 10-degree RA strip grouping where applicable, and circular-mean RA-wrap handling.
  • Add a regression test that exercises the production path (call into the same code batch_pipeline.py calls) on synthetic tiles and asserts it goes through the canonical package entry rather than mosaic_day.coadd_tiles.
  • Add or update tests for the ADR axes: PB blanking threshold/source, strip grouping, and RA-wrap compact centre.
  • tests/test_mosaic_ra_wrap.py still passes.
  • scripts/batch_pipeline.py --dry-run --date 2026-01-25 --start-hour 22 --end-hour 23 --quarantine-after-failures 3 succeeds on H17 with the casa6 env.
  • Reduce scripts/mosaic_day.py to a thin compatibility wrapper around the package entry, or keep it only as a legacy standalone CLI after verifying callers with rg "mosaic_day|coadd_tiles|group_tiles_by_ra".
  • CONTEXT.md Strip grouping (legacy day-batch) entry is updated if scripts/mosaic_day.py no longer owns that behavior after migration.

Blocked by

Pointers for a fresh agent

  • ADR: docs/adr/0001-canonical-hourly-epoch-coadd.md.
  • Current production call site: scripts/batch_pipeline.py epoch mosaic build around the _md.build_common_wcs(...) / _md.coadd_tiles(...) calls.
  • Legacy behavior to absorb: scripts/mosaic_day.py::PB_CUTOFF, group_tiles_by_ra, build_common_wcs, coadd_tiles.
  • Package builder and RA-wrap baseline: dsa110_continuum/mosaic/builder.py::build_mosaic, compute_optimal_wcs, tests/test_mosaic_ra_wrap.py.
  • Use the casa6 env on H17: PYTHONPATH=/data/dsa110-continuum /opt/miniforge/envs/casa6/bin/python -m pytest ....

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triageA maintainer needs to evaluate the issue.refactorRestructuring code without changing external behavior

    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