From b5479b5dc1b0a374f0dcca72045710d57dc22fc1 Mon Sep 17 00:00:00 2001 From: SGCMarkus Date: Thu, 13 Jun 2024 14:48:36 +0200 Subject: [PATCH] flaredetector: util: add function to convert normal index to folded index/cycle pair --- main/flaredetector/util.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/main/flaredetector/util.py b/main/flaredetector/util.py index 95367d5..d10da27 100644 --- a/main/flaredetector/util.py +++ b/main/flaredetector/util.py @@ -68,4 +68,15 @@ def plotFlareFits(ax, fits): def markFlare(ax, fits, flux): for fit in fits: - ax.plot(fit["FlareFitTime"], flux[fit["StandardIndex"]], color="red") \ No newline at end of file + ax.plot(fit["FlareFitTime"], flux[fit["StandardIndex"]], color="red") + +def convertStarndardIndexToFoldedIndex(foldedLc, standardIndex): + foldedIndex = standardIndex; cycle = 0 + for i in range(max(foldedLc.cycle)+1): + if(foldedIndex - len(foldedLc.phase[foldedLc.cycle == i]) >= 0): + foldedIndex = foldedIndex - len(foldedLc.phase[foldedLc.cycle == i]) + else: + cycle = i + break + + return cycle, foldedIndex \ No newline at end of file