From 1b33052c347df40b71d6efa4056a7a3136a7a7b4 Mon Sep 17 00:00:00 2001 From: SGCMarkus Date: Tue, 2 Jul 2024 12:01:40 +0200 Subject: [PATCH] flaredetector: util: add function to plot peak/valley areas --- main/flaredetector/util.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/main/flaredetector/util.py b/main/flaredetector/util.py index 0c6c9ff..e557877 100644 --- a/main/flaredetector/util.py +++ b/main/flaredetector/util.py @@ -139,3 +139,23 @@ def getPhaseRangesNearPeak(maxArgs, phase): maxPhaseBoundsIndices.append([findNearestIndexOfValue(phase, lv) for lv in l]) return minPhaseBoundsIndices, maxPhaseBoundsIndices + +def plotPhaseRangesNearPeak(indices, phase, ax=None): + minPhaseBoundsIndices = indices[0] + maxPhaseBoundsIndices = indices[1] + + if(ax is None): + import matplotlib.pyplot as plt + for pair in minPhaseBoundsIndices: + for l in pair: + plt.axes.axvline(phase[l], color="violet") + for pair in maxPhaseBoundsIndices: + for l in pair: + plt.axes.axvline(phase[l], color="orange") + else: + for pair in minPhaseBoundsIndices: + for l in pair: + ax.axvline(phase[l], color="violet") + for pair in maxPhaseBoundsIndices: + for l in pair: + ax.axvline(phase[l], color="orange") \ No newline at end of file