-
-
Notifications
You must be signed in to change notification settings - Fork 41
Background subtraction error propagation #297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ts for uncertainty in background estimation, subtraction, and propagation methods.
…rovided. Enhanced tests to validate variance computation and propagation.
… `Background` methods. Improved uncertainty type preservation and propagation logic.
…crossdisp_axis` instead of `disp_axis`.
…ariance computation to incorporate clipping mask, and implemented new tests for sigma clipping.
…nd` and extraction modules.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #297 +/- ##
==========================================
+ Coverage 89.90% 90.19% +0.29%
==========================================
Files 17 17
Lines 1822 1877 +55
==========================================
+ Hits 1638 1693 +55
Misses 184 184 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
the RTD is failing due to some warnings that are being cast as errors. some of the warnings are related to |
…ngs in the background module.
…xing Sphinx issues.
…ex` for complex type annotations in Sphinx.
This is fixed now, but it took some time to identify the issue. Apparently, complex type annotations in data classes can cause problems, but I'm not sure why this became an issue only now. I added some I also added some missing packages to the specreduce-dev conda environment. |
tepickering
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great work! this is pretty key functionality to have in place to properly handle spectra and their uncertainties.
| nitpick_ignore = [ | ||
| ("py:class", "ArrayLike"), | ||
| ("py:class", "numpy._typing.ArrayLike"), | ||
| ("py:class", "specutils.spectra.spectrum1d.Spectrum1D"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this because we're still referencing Spectrum1D or is it on the specutils end? either way, i think ignoring is the right approach for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes an issue I ran into while testing with specutils < 2. Then again, I believe we can finally pin specutils >= 2 for the next release. I'll clean up this and the remaining compatibility workarounds in a separate PR.
This PR adds uncertainty propagation to the
Backgroundclass and introduces sigma clipping for outlier rejection in background estimation. It also adds tests for the functionality and updates the documentation.New Features
Uncertainty Propagation
The
Backgroundclass now computes and propagates uncertainties through all background operations:bkg_image()- Returns background image with uncertaintybkg_spectrum()- Returns 1D background spectrum with uncertaintysub_image()- Returns background-subtracted image with propagated uncertaintysub_spectrum()- Returns background-subtracted 1D spectrum with propagated uncertaintyVariance Calculation
For the
averagestatistic:For the
medianstatistic:Automatic Variance Estimation
When input image has no uncertainty provided, variance is automatically estimated from the sample variance of flux values in the background region.
Uncertainty Type Preservation
The output uncertainty type matches the input:
VarianceUncertainty→VarianceUncertaintyStdDevUncertainty→StdDevUncertaintyInverseVariance→InverseVarianceSigma Clipping for Outlier Rejection
Added optional
sigmaparameter for sigma clipping to reject cosmic rays and other outliers in the background region:The outlier mask is stored separately in
_outlier_maskand does not modify the original image mask.Bug Fixes
crossdisp_axisinstead ofdisp_axiswhen computing default trace position.Documentation
docs/background.rstwith new sections on outlier rejection and uncertainty propagationdocs/extraction.rstwith uncertainty propagation documentationCHANGES.rstchangelog