Skip to content

find_arc_lines uncertainty handling fix - #321

Open
hpparvi wants to merge 2 commits into
astropy:mainfrom
hpparvi:v110_find_lines_uncertainty_fix
Open

hpparvi wants to merge 2 commits into
astropy:mainfrom
hpparvi:v110_find_lines_uncertainty_fix

Conversation

@hpparvi

@hpparvi hpparvi commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

This PR fixes two issues in how the find_arc_lines handles uncertainties:

  1. the find_arc_lines function now allows uncertainties to be any of Astropy's uncertainty types (it allowed previously only StdDevUncertainty)

  2. If the spectrum doesn't include uncertainties, the uncertainties are estimated using a robust approach based on the DER_SNR algorithm by Stoerh et al. (2008). (with a small difference that we're using Astropy's sigma-clipped median instead of plain median).

I've also added the noise estimation function as specreduce.utils.utils.measure_noise.

AI/LLM Disclaimer: The same as in #319. I've used Claude Code with Fable 5.1 to co-develop the PR, but I understand what the code does and how it works, and can explain it when needed.

… estimate noise in a 2D spectrum. This is for now used only in `specreduce.line_matching.find_arc_lines` as a fallback noise estimate if the spectrum doesn't contain uncertainties, but may be useful elsewhere as well.
@hpparvi
hpparvi requested review from cshanahan1, kbwestfall, kecnry and tepickering and removed request for cshanahan1 September 7, 2026 14:11
@codecov

codecov Bot commented Sep 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.42857% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 92.56%. Comparing base (742264f) to head (fa7adef).

Files with missing lines Patch % Lines
specreduce/utils/utils.py 95.45% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #321      +/-   ##
==========================================
+ Coverage   92.52%   92.56%   +0.03%     
==========================================
  Files          18       18              
  Lines        2341     2367      +26     
==========================================
+ Hits         2166     2191      +25     
- Misses        175      176       +1     

☔ View full report in Codecov by Harness.
📢 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.

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