generate plots: fix using wrong dataset for full period histogram

This commit is contained in:
2025-04-27 21:22:04 +02:00
parent 060cae2264
commit 1fc9b82a1a
+19 -13
View File
@@ -51,13 +51,13 @@ if(useTESS):
current = datetime.now() current = datetime.now()
date = f"{current.year}-{current.month}-{current.day}" date = f"{current.year}-{current.month}-{current.day}"
time = f"{current.hour}-{current.minute}-{current.second}" 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}/" #folderPath = f"G:/Meine Ablage/Masterthesis/{date}/"
mkdir_p(folderPath) mkdir_p(folderPath)
# remove any data that has no period # remove any data that has no period
#data = data[(data["FitType"] == "sine") | (data["FitType"] == "poly")] #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 = [] validStarPeriodMap = []
starList = set(list(data["StarName"])) starList = set(list(data["StarName"]))
@@ -183,7 +183,8 @@ def plotFlarePeaks(plotdata, filters, labels, colors, maxY, title, filename):
plt.close() plt.close()
def setupxyDataAndDataList(PDCSAPdataList2dhistPhase, PDCSAPdataList2dhistPeak, def setupxyDataAndDataList(PDCSAPdataList2dhistPhase, PDCSAPdataList2dhistPeak,
PDCSAPdataList=None, dataFilter=None): PDCSAPdataList=None, dataFilter=None,
PeriodModulation=False):
xData = pd.DataFrame() xData = pd.DataFrame()
yData = pd.DataFrame() yData = pd.DataFrame()
for aX, aY in zip(PDCSAPdataList2dhistPhase, PDCSAPdataList2dhistPeak): for aX, aY in zip(PDCSAPdataList2dhistPhase, PDCSAPdataList2dhistPeak):
@@ -194,9 +195,15 @@ def setupxyDataAndDataList(PDCSAPdataList2dhistPhase, PDCSAPdataList2dhistPeak,
yData = np.asarray(yData.values)[:,0] yData = np.asarray(yData.values)[:,0]
if(PDCSAPdataList is not None): if(PDCSAPdataList is not None):
if(dataFilter 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: else:
PDCSAPdataList.append(pdcsapbinningData[:]["PDCSAPNormPhase"]) if(PeriodModulation):
PDCSAPdataList.append(pdcsapbinningDataSpotModDiffPeriod[:]["PDCSAPNormPhasePeriod"])
else:
PDCSAPdataList.append(pdcsapbinningData[:]["PDCSAPNormPhase"])
return xData, yData, PDCSAPdataList return xData, yData, PDCSAPdataList
@@ -270,7 +277,6 @@ for starName in starDB.getAllStars():
PDCSAPcolorList = [] PDCSAPcolorList = []
PDCSAPdataList2dhistPhase = [] PDCSAPdataList2dhistPhase = []
PDCSAPdataList2dhistPeak = [] PDCSAPdataList2dhistPeak = []
if(len(pdcsapbinningData) > 0): if(len(pdcsapbinningData) > 0):
if(pdcsapbinningData["SpType"][0][0] == "M"): if(pdcsapbinningData["SpType"][0][0] == "M"):
color = "red" color = "red"
@@ -297,19 +303,19 @@ for starName in starDB.getAllStars():
foldedFits) foldedFits)
if(pdcsapbinningDataSpotModDiffPeriod is not None): if(pdcsapbinningDataSpotModDiffPeriod is not None):
PDCSAPdataList = [] PDCSAPdataListPeriod = []
PDCSAPlabelList = [] PDCSAPlabelList = []
PDCSAPcolorList = [] PDCSAPcolorList = []
PDCSAPdataList2dhistPhase = [] PDCSAPdataList2dhistPhase = []
PDCSAPdataList2dhistPeak = [] PDCSAPdataList2dhistPeak = []
if(pdcsapbinningData["SpType"][0][0] == "M"): if(pdcsapbinningDataSpotModDiffPeriod["SpType"][0][0] == "M"):
color = "red" color = "red"
elif(pdcsapbinningData["SpType"][0][0] == "K"): elif(pdcsapbinningDataSpotModDiffPeriod["SpType"][0][0] == "K"):
color = "orange" color = "orange"
elif(pdcsapbinningData["SpType"][0][0] == "G"): elif(pdcsapbinningDataSpotModDiffPeriod["SpType"][0][0] == "G"):
color = "yellow" color = "yellow"
elif(pdcsapbinningData["SpType"][0][0] == "F"): elif(pdcsapbinningDataSpotModDiffPeriod["SpType"][0][0] == "F"):
color = "greenyellow" color = "greenyellow"
else: else:
color = "gray" color = "gray"
@@ -317,12 +323,12 @@ for starName in starDB.getAllStars():
PDCSAPdataList2dhistPhase.append(pdcsapbinningDataSpotModDiffPeriod[:]["PDCSAPNormPhasePeriod"]) PDCSAPdataList2dhistPhase.append(pdcsapbinningDataSpotModDiffPeriod[:]["PDCSAPNormPhasePeriod"])
PDCSAPdataList2dhistPeak.append(pdcsapbinningDataSpotModDiffPeriod[:]["PeakPeriod"]) PDCSAPdataList2dhistPeak.append(pdcsapbinningDataSpotModDiffPeriod[:]["PeakPeriod"])
xData, yData, PDCSAPdataList = setupxyDataAndDataList(PDCSAPdataList2dhistPhase, PDCSAPdataList2dhistPeak, PDCSAPdataList) xData, yData, PDCSAPdataListPeriod = setupxyDataAndDataList(PDCSAPdataList2dhistPhase, PDCSAPdataList2dhistPeak, PDCSAPdataListPeriod, PeriodModulation=True)
PDCSAPlabelList.append(f"{starName}") PDCSAPlabelList.append(f"{starName}")
PDCSAPcolorList.append(color) 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", 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", pdcsapbinningDataSpotModDiffPeriod, None, f"{starName}", color, f"Flare peaks per phase of {starName}", f"{locFolder}/{starNameR}-Flarepeaks_maxY-@maxY_Period.png",
foldedPeriodFits) foldedPeriodFits)