From 0f0001f7a3f71c19abe4c8d9fa74ee5045c045ea Mon Sep 17 00:00:00 2001 From: SGCMarkus Date: Mon, 15 Apr 2024 14:41:20 +0200 Subject: [PATCH] flaredetector: make sure we dont run into ranges without data --- main/flaredetector/flaredetector.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/main/flaredetector/flaredetector.py b/main/flaredetector/flaredetector.py index 6e8afc5..2a0a467 100644 --- a/main/flaredetector/flaredetector.py +++ b/main/flaredetector/flaredetector.py @@ -36,6 +36,9 @@ def getFlareRange(flux, peakIndex): if(minInd < 0): minInd = 0 + while(np.isnan(flux[minInd].unmasked)): + minInd += 1 + deltaCount = 0 delta = 100 prevFlux = flux[peakIndex] @@ -54,4 +57,7 @@ def getFlareRange(flux, peakIndex): if(maxInd > len(flux)-1): maxInd = len(flux)-1 + while(np.isnan(flux[maxInd].unmasked)): + maxInd -= 1 + return minInd, maxInd