Skip to content

Improve Gaia alignment robustness, diagnostics, and fallback behavior in WCS pipeline#78

Merged
charliekilpatrick merged 2 commits into
mainfrom
KerryPaterson-patch-1
Mar 19, 2026
Merged

Improve Gaia alignment robustness, diagnostics, and fallback behavior in WCS pipeline#78
charliekilpatrick merged 2 commits into
mainfrom
KerryPaterson-patch-1

Conversation

@charliekilpatrick

Copy link
Copy Markdown
Collaborator

Summary

  • Fixes a Gaia alignment instability in solve_wcs.align_to_gaia where iterative matching could collapse and produce pathological WCS solutions.
  • Adds structured Gaia-stage diagnostics (in-frame Gaia counts, SExtractor source counts, match summaries, and WCS matrix sanity metrics) to make failure modes clear in logs.
  • Introduces robust fallback behavior: when Gaia refinement fails or produces an invalid WCS, keep coarse astrometry.net WCS and continue processing instead of dropping frames.
  • Adds explicit failure metadata in headers (GAIAFAIL) plus fallback dispersion defaults so downstream selection/stacking remains stable.
  • Adds WCS validation gates (pixel-scale consistency and anisotropy checks) to reject distorted refined solutions before reprojection.
  • Extends unit coverage for Gaia fallback paths in tests/test_wcs.py (no Gaia catalog / no SExtractor detections).

Why

In real reductions with sparse Gaia matches (e.g., 6–7 stars), Gaia refinement could intermittently yield unstable/sheared WCS fits, causing severe reprojection distortion or frame loss. This PR makes the alignment stage resilient and transparent while preserving usable coarse solutions.

Validation

  • pytest tests/test_wcs.py -k "not integration" passes.
  • Full unit suite (pytest tests -m "not integration") passes.
  • Runtime logs now clearly show Gaia failure reasons and fallback decisions.

- Implemented unit tests to verify the behavior of the align_to_gaia function when the Gaia catalog is unavailable or when SExtractor returns no sources.
- Enhanced the solve_wcs module with helper functions for logging and writing fallback headers to FITS files, ensuring clear documentation of fallback reasons in the header.
- Improved the validation of refined WCS by adding checks for pixel scale and anisotropy, enhancing the robustness of the WCS alignment process.
- Added functionality to the align_to_gaia function to handle scenarios where the Gaia catalog is unavailable or SExtractor returns no sources.
- Introduced logging and fallback header writing in the solve_wcs module for better documentation of fallback reasons.
- Enhanced validation checks for refined WCS, including pixel scale and anisotropy, to improve robustness.
@charliekilpatrick
charliekilpatrick merged commit be98eeb into main Mar 19, 2026
3 checks passed
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