From 1fc9b82a1a7d945f82b8c8f0e35a2a04bb29af3e Mon Sep 17 00:00:00 2001 From: SGCMarkus Date: Sun, 27 Apr 2025 21:22:04 +0200 Subject: [PATCH] generate plots: fix using wrong dataset for full period histogram --- generate_plots.py | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/generate_plots.py b/generate_plots.py index 759506a..00c462b 100644 --- a/generate_plots.py +++ b/generate_plots.py @@ -51,13 +51,13 @@ if(useTESS): current = datetime.now() date = f"{current.year}-{current.month}-{current.day}" time = f"{current.hour}-{current.minute}-{current.second}" -folderPath = f"../{date}-sine-poly/" +folderPath = f"../{date}-poly-only/" #folderPath = f"G:/Meine Ablage/Masterthesis/{date}/" mkdir_p(folderPath) # remove any data that has no period #data = data[(data["FitType"] == "sine") | (data["FitType"] == "poly")] -data = data[((data["FitType"] == "sine") | (data["FitType"] == "poly")) & (data["isValidFold"])] +data = data[((data["FitType"] == "poly")) & (data["isValidFold"])] validStarPeriodMap = [] starList = set(list(data["StarName"])) @@ -183,7 +183,8 @@ def plotFlarePeaks(plotdata, filters, labels, colors, maxY, title, filename): plt.close() def setupxyDataAndDataList(PDCSAPdataList2dhistPhase, PDCSAPdataList2dhistPeak, - PDCSAPdataList=None, dataFilter=None): + PDCSAPdataList=None, dataFilter=None, + PeriodModulation=False): xData = pd.DataFrame() yData = pd.DataFrame() for aX, aY in zip(PDCSAPdataList2dhistPhase, PDCSAPdataList2dhistPeak): @@ -194,9 +195,15 @@ def setupxyDataAndDataList(PDCSAPdataList2dhistPhase, PDCSAPdataList2dhistPeak, yData = np.asarray(yData.values)[:,0] if(PDCSAPdataList is not None): if(dataFilter is not None): - PDCSAPdataList.append(pdcsapbinningData[dataFilter]["PDCSAPNormPhase"]) + if(PeriodModulation): + PDCSAPdataList.append(pdcsapbinningDataSpotModDiffPeriod[dataFilter]["PDCSAPNormPhasePeriod"]) + else: + PDCSAPdataList.append(pdcsapbinningData[dataFilter]["PDCSAPNormPhase"]) else: - PDCSAPdataList.append(pdcsapbinningData[:]["PDCSAPNormPhase"]) + if(PeriodModulation): + PDCSAPdataList.append(pdcsapbinningDataSpotModDiffPeriod[:]["PDCSAPNormPhasePeriod"]) + else: + PDCSAPdataList.append(pdcsapbinningData[:]["PDCSAPNormPhase"]) return xData, yData, PDCSAPdataList @@ -270,7 +277,6 @@ for starName in starDB.getAllStars(): PDCSAPcolorList = [] PDCSAPdataList2dhistPhase = [] PDCSAPdataList2dhistPeak = [] - if(len(pdcsapbinningData) > 0): if(pdcsapbinningData["SpType"][0][0] == "M"): color = "red" @@ -297,19 +303,19 @@ for starName in starDB.getAllStars(): foldedFits) if(pdcsapbinningDataSpotModDiffPeriod is not None): - PDCSAPdataList = [] + PDCSAPdataListPeriod = [] PDCSAPlabelList = [] PDCSAPcolorList = [] PDCSAPdataList2dhistPhase = [] PDCSAPdataList2dhistPeak = [] - if(pdcsapbinningData["SpType"][0][0] == "M"): + if(pdcsapbinningDataSpotModDiffPeriod["SpType"][0][0] == "M"): color = "red" - elif(pdcsapbinningData["SpType"][0][0] == "K"): + elif(pdcsapbinningDataSpotModDiffPeriod["SpType"][0][0] == "K"): color = "orange" - elif(pdcsapbinningData["SpType"][0][0] == "G"): + elif(pdcsapbinningDataSpotModDiffPeriod["SpType"][0][0] == "G"): color = "yellow" - elif(pdcsapbinningData["SpType"][0][0] == "F"): + elif(pdcsapbinningDataSpotModDiffPeriod["SpType"][0][0] == "F"): color = "greenyellow" else: color = "gray" @@ -317,12 +323,12 @@ for starName in starDB.getAllStars(): PDCSAPdataList2dhistPhase.append(pdcsapbinningDataSpotModDiffPeriod[:]["PDCSAPNormPhasePeriod"]) PDCSAPdataList2dhistPeak.append(pdcsapbinningDataSpotModDiffPeriod[:]["PeakPeriod"]) - xData, yData, PDCSAPdataList = setupxyDataAndDataList(PDCSAPdataList2dhistPhase, PDCSAPdataList2dhistPeak, PDCSAPdataList) + xData, yData, PDCSAPdataListPeriod = setupxyDataAndDataList(PDCSAPdataList2dhistPhase, PDCSAPdataList2dhistPeak, PDCSAPdataListPeriod, PeriodModulation=True) PDCSAPlabelList.append(f"{starName}") PDCSAPcolorList.append(color) - generatePlots(PDCSAPdataList, PDCSAPlabelList, PDCSAPcolorList, f"Flare count in phase of {starName} with @bins bins", f"{locFolder}/{starNameR}-Flarecount-@bins_Bins_Period.png", + generatePlots(PDCSAPdataListPeriod, PDCSAPlabelList, PDCSAPcolorList, f"Flare count in phase of {starName} with @bins bins", f"{locFolder}/{starNameR}-Flarecount-@bins_Bins_Period.png", xData, yData, f"Flare peak per phase histogram of {starName} with @bins bins", f"{locFolder}/{starNameR}-Flarepeaks-@bins_Bins_maxY-@maxY_Period.png", pdcsapbinningDataSpotModDiffPeriod, None, f"{starName}", color, f"Flare peaks per phase of {starName}", f"{locFolder}/{starNameR}-Flarepeaks_maxY-@maxY_Period.png", foldedPeriodFits)