feat: Add quality filter for known contaminated observations - #50
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
filter_known_contamination()utility andKNOWN_BAD_PERIODSconstant to remove spectra from documented environmental contamination events (June 4-12, 2021 Arizona wildfire aerosol event, 181 spectra)SkySpecVACviaexclude_known_badparameter (defaultTrue)--no-quality-filteropt-out flag to all training CLI scripts (train_vae,train_ldm,train_broadband)TestQualityFiltersuiteContext
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