Skip to content

Conversation

@hpparvi
Copy link
Contributor

@hpparvi hpparvi commented Jan 11, 2026

This PR adds uncertainty propagation to HorneExtract so that uncertainties from 2D input images are properly propagated to the extracted 1D spectrum. Turns out this was very straightforward since we're already calculating the uncertainty for the Horne extraction itself (it's 1/den without the normalisation). So, aside from handling uncertainty types and such, we actually needed to add one extra line of code... I also renamed img to flux so that the variable is not mixed with image, and so that the variable naming is more understandable at the end of the method.

@codecov
Copy link

codecov bot commented Jan 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.90%. Comparing base (e2baedb) to head (1ab2f37).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #296      +/-   ##
==========================================
+ Coverage   89.76%   89.90%   +0.13%     
==========================================
  Files          17       17              
  Lines        1817     1822       +5     
==========================================
+ Hits         1631     1638       +7     
+ Misses        186      184       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@tepickering tepickering left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for adding this! looks good except for one case that isn't covered by the new tests according to codecov. i would add that and then feel free to merge.

output_uncertainty = InverseVariance(1.0 / extracted_variance / unit**2)
else:
# Fallback to VarianceUncertainty for unknown types
output_uncertainty = VarianceUncertainty(extracted_variance * unit**2)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks like coverage for this case is missing from the tests you added.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed! The whole uncertainty type conversion could be simplified to three lines.

@tepickering
Copy link
Contributor

well that's exciting. the devdeps test caught an upcoming numpy deprecation. maybe worth fixing here if it's easy...

@hpparvi hpparvi force-pushed the horne_extraction_errors branch from 56623a0 to 1ab2f37 Compare January 13, 2026 19:43
@hpparvi hpparvi merged commit 1d6491e into astropy:main Jan 13, 2026
12 of 13 checks passed
@hpparvi hpparvi deleted the horne_extraction_errors branch January 13, 2026 19:47
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.

2 participants