From 87eaad04183c15474675326e0efd18eca6273b43 Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Fri, 2 Sep 2022 10:00:52 -0400 Subject: [PATCH] OptimalExtract: handle variance input with nans * handle similar to zeros: exclude those elements by modifying the mask --- specreduce/extract.py | 4 ++++ 1 file changed, 4 insertions(+) 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