-
-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Fix centroid and gaussian width analysis functions, add distribution-based implementation #1057
Conversation
For backstory, a picture of the derivation for the analytic solution is below. I cross-checked this solution and the implementation in this PR in a notebook here: @rosteen, maybe the thing to do is to update this PR to include tests based on that notebook? That is, a test where you generate a fake spectrum with known uncertainty a bunch of times, compute the centroid, and then compare the stddev of those simulations to the uncertanty derived here? As long as you set a random number generator seed for that and a sufficient tolerance it shouldn't lead to mysterious failures due to bad luck of the draw. |
Oh, and given the growing complexity, maybe we want to change this PR to just the centroid, finish it up, and then do a separate PR for the others? |
I'm going to try to get the gaussian width measures in here too, I'd rather not be inconsistent between those and the centroiding. A nice side effect of this is that I think I figured out the generalization of the centroiding math to multiple dimensions, so we aren't restricted to 1D or 2D like we were in the previous implementation of centroid. |
…nd no uncertainty
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1057 +/- ##
==========================================
+ Coverage 70.35% 70.72% +0.36%
==========================================
Files 64 64
Lines 4406 4485 +79
==========================================
+ Hits 3100 3172 +72
- Misses 1306 1313 +7 ☔ View full report in Codecov by Sentry. |
@eteq this is now ready for review. I ended up leaving the default as the analytic solution, since we're fairly certain it's correct now, and leaving the distribution-based solution as an option - I figured this is less disruptive/doesn't change a default that users might not notice. I noticed and fixed a couple other things along the way while adding/fixing tests, for example the sigma width uncertainty was previously just adding The test failure from the latest run was an unrelated file download error. |
…based implementation (astropy#1057) * Add option back in to use analytic uncertainty for centroid * Remove debugging print statements * Change keyword to be more accurate, updating tests * Generalize centroid uncertainty calculation to multiple dimensisions * Update test * Fix multi-D case for distribution centroid method * Update gaussian width measures to use distribution-based methods * Fix codestyle * Fix mask check and flux_uncert creation * Parameterizing more tests * Almost have all tests passing, now raise error if analyalytic=False and no uncertainty * Cleaning up width after requiring uncertainty for distribution method * Fix sigma width uncertainty calculations, default to analytic * Update docstrings * Add docs
We've had some reports that the uncertainties reported by
centroid
,gaussian_sigma_width
, andgaussian_fwhm
are suspect/wrong. This PR will update to usingastropy.uncertainty
Monte Carlo distributions to estimate the value and uncertainty for these quantities instead of the suspect analytic solutions, and give the option to use an updated analytic solution forcentroid
that @eteq re-derived. Opening this now to get eyes on my implementation, but I still need to update the gaussian measures.