Skip to content

Commit c7344e7

Browse files
committed
Handled missing uncertainty in spectrum processing by initializing StdDevUncertainty when absent.
1 parent fd59b83 commit c7344e7

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

specreduce/line_matching.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import warnings
2+
from copy import deepcopy
23
from typing import Sequence
34

45
import astropy.units as u
56
import numpy as np
7+
from astropy.nddata import StdDevUncertainty
68
from astropy.stats import gaussian_fwhm_to_sigma, gaussian_sigma_to_fwhm
79
from astropy.modeling import models
810
from astropy.table import QTable
@@ -53,6 +55,10 @@ def find_arc_lines(
5355
if fwhm.unit != spectrum.spectral_axis.unit:
5456
raise ValueError("fwhm must have the same units as spectrum.spectral_axis.")
5557

58+
if spectrum.uncertainty is None:
59+
spectrum = deepcopy(spectrum)
60+
spectrum.uncertainty = StdDevUncertainty(np.sqrt(np.abs(spectrum.flux.value)))
61+
5662
detected_lines = find_lines_threshold(spectrum, noise_factor=noise_factor)
5763
detected_lines = detected_lines[detected_lines['line_type'] == 'emission']
5864

0 commit comments

Comments
 (0)