Skip to content

feat: Add quality filter for known contaminated observations - #50

Merged
MatthewDowicz merged 3 commits into
mainfrom
investigate-outlier-spectra
Apr 9, 2026
Merged

feat: Add quality filter for known contaminated observations#50
MatthewDowicz merged 3 commits into
mainfrom
investigate-outlier-spectra

Conversation

@MatthewDowicz

@MatthewDowicz MatthewDowicz commented Apr 8, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add filter_known_contamination() utility and KNOWN_BAD_PERIODS constant to remove spectra from documented environmental contamination events (June 4-12, 2021 Arizona wildfire aerosol event, 181 spectra)
  • Integrate into SkySpecVAC via exclude_known_bad parameter (default True)
  • Add --no-quality-filter opt-out flag to all training CLI scripts (train_vae, train_ldm, train_broadband)
  • Update tests: relax hardcoded row counts, add 6-test TestQualityFilter suite

Context

Outlier analysis of DESI sky spectra identified a 9-day window (June 4-12, 2021) where Arizona wildfires caused anomalous spectral shapes (2x blue/red excess, 58% GFA transparency measurements were normal during the event, indicating the spectral distortion is not caused by atmospheric extinction (e.g., thick smoke or clouds reducing throughput). The filter is applied by default everywhere. SkySpecVAC users get it automatically, custom data users can call the utility function directly.

Test plan

  • All 382 tests pass (376 existing + 6 new)
  • Verify notebooks still run with filtered data (row counts are dynamic, no changes needed)

Add _quality.py module with KNOWN_BAD_PERIODS constant and filter_known_contamination() utility that removes spectra from documented environmental contamination events. Currently filters the June 4-12, 2021 Arizone wildfire aerosol event (181 spectra), which caused anomalous blue excess and spectral shape distortion across all sky categories.

Integrated into SkySpecVAC via exclude_known_bad parameter (default True). The filter works with NIGHT or MJD columns and can be called standalone on user-provided DataFrames.
Auto-filters known contaminated observations by default in all three training scripts (VAE, LDM, broadband). For custom .fits/.csv data paths, the filter is applied directly. For .npz paths without metadata, a warning is emitted. Users can opt out with --no-quality-filter.
Relax hardcoded row count assertions in test_enrichment.py to account for filtered observations. Add TestQualityFilter suite with 6 tests covering NIGHT filtering, MJD fallback, missing column warning, and SkySpecVAC exclude_known_bad parameter. Update __all__ count in test_data_download.py.
@MatthewDowicz
MatthewDowicz merged commit d6ef27e into main Apr 9, 2026
4 of 6 checks passed
@MatthewDowicz
MatthewDowicz deleted the investigate-outlier-spectra branch April 9, 2026 00:34
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