diff --git a/specreduce/extract.py b/specreduce/extract.py index 62d28bd5..e1a07684 100644 --- a/specreduce/extract.py +++ b/specreduce/extract.py @@ -353,6 +353,10 @@ def __call__(self, image=None, trace_object=None, if np.any(variance < 0): raise ValueError("variance must be fully positive") + if np.any(np.isnan(variance)): + # exclude these elements by editing the input mask + img.mask[np.isnan(variance)] = True + if np.any(variance == 0): # exclude these elements by editing the input mask img.mask[variance == 0] = True