generate_plots: bring uptodate for changes, add max flare peak plots
This commit is contained in:
+86
-83
@@ -27,7 +27,7 @@ def mkdir_p(mypath):
|
|||||||
pass
|
pass
|
||||||
else: raise
|
else: raise
|
||||||
|
|
||||||
fileName = "datav5.cff"
|
fileName = "datav5.1.cff"
|
||||||
data = pd.read_pickle(fileName)
|
data = pd.read_pickle(fileName)
|
||||||
|
|
||||||
binList = [10, 20, 30]
|
binList = [10, 20, 30]
|
||||||
@@ -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}/"
|
folderPath = f"../{date}-sine-poly/"
|
||||||
#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 = data[((data["FitType"] == "sine") | (data["FitType"] == "poly")) & (data["isValidFold"])]
|
||||||
|
|
||||||
validStarPeriodMap = []
|
validStarPeriodMap = []
|
||||||
starList = set(list(data["StarName"]))
|
starList = set(list(data["StarName"]))
|
||||||
@@ -155,19 +155,20 @@ def plotFlarePeaks(plotdata, filters, labels, colors, maxY, title, filename):
|
|||||||
if(isinstance(labels, list) and isinstance(colors, list)):
|
if(isinstance(labels, list) and isinstance(colors, list)):
|
||||||
_, ((axFlarePeaks)) = plt.subplots(nrows=1, ncols=1)
|
_, ((axFlarePeaks)) = plt.subplots(nrows=1, ncols=1)
|
||||||
for f, l, c in zip(filters, labels, colors):
|
for f, l, c in zip(filters, labels, colors):
|
||||||
axFlarePeaks.scatter(plotdata[f]["PDCSAPNormPhase"],
|
axFlarePeaks.scatter(plotdata[f]["PDCSAPNormPhase"] if "PDCSAPNormPhase" in plotdata[f].columns else plotdata[f]["PDCSAPNormPhasePeriod"],
|
||||||
plotdata[f]["Peak"],
|
plotdata[f]["Peak"] if "Peak" in plotdata[f].columns else plotdata[f]["PeakPeriod"],
|
||||||
label=l, color=c)
|
label=l, color=c)
|
||||||
elif(isinstance(labels, str) and isinstance(colors, str)):
|
elif(isinstance(labels, str) and isinstance(colors, str)):
|
||||||
_, ((axFlarePeaks)) = plt.subplots(nrows=1, ncols=1)
|
_, ((axFlarePeaks)) = plt.subplots(nrows=1, ncols=1)
|
||||||
if(filters is None):
|
if(filters is None):
|
||||||
axFlarePeaks.scatter(plotdata[:]["PDCSAPNormPhase"],
|
axFlarePeaks.scatter(plotdata[:]["PDCSAPNormPhase"] if "PDCSAPNormPhase" in plotdata[:].columns else plotdata[:]["PDCSAPNormPhasePeriod"],
|
||||||
plotdata[:]["Peak"],
|
|
||||||
|
plotdata[:]["Peak"] if "Peak" in plotdata[:].columns else plotdata[:]["PeakPeriod"],
|
||||||
label=labels, color=colors)
|
label=labels, color=colors)
|
||||||
else:
|
else:
|
||||||
axFlarePeaks.scatter(plotdata[filters]["PDCSAPNormPhase"],
|
axFlarePeaks.scatter(plotdata[filters]["PDCSAPNormPhase"] if "PDCSAPNormPhase" in plotdata[filters].columns else plotdata[filters]["PDCSAPNormPhasePeriod"],
|
||||||
plotdata[filters]["Peak"],
|
plotdata[filters]["Peak"] if "Peak" in plotdata[filters].columns else plotdata[filters]["PeakPeriod"],
|
||||||
label=labels, color=colors)
|
label=labels, color=colors)
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
axFlarePeaks.set_xlim(0, 2)
|
axFlarePeaks.set_xlim(0, 2)
|
||||||
@@ -313,8 +314,8 @@ for starName in starDB.getAllStars():
|
|||||||
else:
|
else:
|
||||||
color = "gray"
|
color = "gray"
|
||||||
|
|
||||||
PDCSAPdataList2dhistPhase.append(pdcsapbinningDataSpotModDiffPeriod[:]["PDCSAPNormPhase"])
|
PDCSAPdataList2dhistPhase.append(pdcsapbinningDataSpotModDiffPeriod[:]["PDCSAPNormPhasePeriod"])
|
||||||
PDCSAPdataList2dhistPeak.append(pdcsapbinningDataSpotModDiffPeriod[:]["Peak"])
|
PDCSAPdataList2dhistPeak.append(pdcsapbinningDataSpotModDiffPeriod[:]["PeakPeriod"])
|
||||||
|
|
||||||
xData, yData, PDCSAPdataList = setupxyDataAndDataList(PDCSAPdataList2dhistPhase, PDCSAPdataList2dhistPeak, PDCSAPdataList)
|
xData, yData, PDCSAPdataList = setupxyDataAndDataList(PDCSAPdataList2dhistPhase, PDCSAPdataList2dhistPeak, PDCSAPdataList)
|
||||||
|
|
||||||
@@ -525,58 +526,59 @@ for comboLength in range(1, len(spType) + 1):
|
|||||||
print(row["StarName"], "has over 100 peak")
|
print(row["StarName"], "has over 100 peak")
|
||||||
|
|
||||||
csvFile.close()
|
csvFile.close()
|
||||||
pdcsapbinningData = pd.DataFrame(pdcsapbinningData)
|
if(len(pdcsapbinningData) > 0):
|
||||||
PDCSAPdataList = []
|
pdcsapbinningData = pd.DataFrame(pdcsapbinningData)
|
||||||
PDCSAPlabelList = []
|
PDCSAPdataList = []
|
||||||
PDCSAPcolorList = []
|
PDCSAPlabelList = []
|
||||||
PDCSAPdataList2dhistPhase = []
|
PDCSAPcolorList = []
|
||||||
PDCSAPdataList2dhistPeak = []
|
PDCSAPdataList2dhistPhase = []
|
||||||
PDCSAPlabelList2dhist = []
|
PDCSAPdataList2dhistPeak = []
|
||||||
PDCSAPcolorList2dhist = []
|
PDCSAPlabelList2dhist = []
|
||||||
plotFilters = []
|
PDCSAPcolorList2dhist = []
|
||||||
if("M" in combo):
|
plotFilters = []
|
||||||
Mfilter = pdcsapbinningData["SpType"] == "M"
|
if("M" in combo):
|
||||||
PDCSAPdataList2dhistPhase.append(pdcsapbinningData[Mfilter]["PDCSAPNormPhase"])
|
Mfilter = pdcsapbinningData["SpType"] == "M"
|
||||||
PDCSAPdataList2dhistPeak.append(pdcsapbinningData[Mfilter]["Peak"])
|
PDCSAPdataList2dhistPhase.append(pdcsapbinningData[Mfilter]["PDCSAPNormPhase"])
|
||||||
PDCSAPdataList.append(pdcsapbinningData[Mfilter]["PDCSAPNormPhase"])
|
PDCSAPdataList2dhistPeak.append(pdcsapbinningData[Mfilter]["Peak"])
|
||||||
PDCSAPlabelList.append("M Stars")
|
PDCSAPdataList.append(pdcsapbinningData[Mfilter]["PDCSAPNormPhase"])
|
||||||
PDCSAPcolorList.append("red")
|
PDCSAPlabelList.append("M Stars")
|
||||||
plotFilters.append(Mfilter)
|
PDCSAPcolorList.append("red")
|
||||||
if("K" in combo):
|
plotFilters.append(Mfilter)
|
||||||
Kfilter = pdcsapbinningData["SpType"] == "K"
|
if("K" in combo):
|
||||||
PDCSAPdataList2dhistPhase.append(pdcsapbinningData[Kfilter]["PDCSAPNormPhase"])
|
Kfilter = pdcsapbinningData["SpType"] == "K"
|
||||||
PDCSAPdataList2dhistPeak.append(pdcsapbinningData[Kfilter]["Peak"])
|
PDCSAPdataList2dhistPhase.append(pdcsapbinningData[Kfilter]["PDCSAPNormPhase"])
|
||||||
PDCSAPdataList.append(pdcsapbinningData[Kfilter]["PDCSAPNormPhase"])
|
PDCSAPdataList2dhistPeak.append(pdcsapbinningData[Kfilter]["Peak"])
|
||||||
PDCSAPlabelList.append("K Stars")
|
PDCSAPdataList.append(pdcsapbinningData[Kfilter]["PDCSAPNormPhase"])
|
||||||
PDCSAPcolorList.append("orange")
|
PDCSAPlabelList.append("K Stars")
|
||||||
plotFilters.append(Kfilter)
|
PDCSAPcolorList.append("orange")
|
||||||
if("G" in combo):
|
plotFilters.append(Kfilter)
|
||||||
Gfilter = pdcsapbinningData["SpType"] == "G"
|
if("G" in combo):
|
||||||
PDCSAPdataList2dhistPhase.append(pdcsapbinningData[Gfilter]["PDCSAPNormPhase"])
|
Gfilter = pdcsapbinningData["SpType"] == "G"
|
||||||
PDCSAPdataList2dhistPeak.append(pdcsapbinningData[Gfilter]["Peak"])
|
PDCSAPdataList2dhistPhase.append(pdcsapbinningData[Gfilter]["PDCSAPNormPhase"])
|
||||||
PDCSAPdataList.append(pdcsapbinningData[Gfilter]["PDCSAPNormPhase"])
|
PDCSAPdataList2dhistPeak.append(pdcsapbinningData[Gfilter]["Peak"])
|
||||||
PDCSAPlabelList.append("G Stars")
|
PDCSAPdataList.append(pdcsapbinningData[Gfilter]["PDCSAPNormPhase"])
|
||||||
PDCSAPcolorList.append("yellow")
|
PDCSAPlabelList.append("G Stars")
|
||||||
plotFilters.append(Gfilter)
|
PDCSAPcolorList.append("yellow")
|
||||||
if("F" in combo):
|
plotFilters.append(Gfilter)
|
||||||
Ffilter = pdcsapbinningData["SpType"] == "F"
|
if("F" in combo):
|
||||||
PDCSAPdataList2dhistPhase.append(pdcsapbinningData[Ffilter]["PDCSAPNormPhase"])
|
Ffilter = pdcsapbinningData["SpType"] == "F"
|
||||||
PDCSAPdataList2dhistPeak.append(pdcsapbinningData[Ffilter]["Peak"])
|
PDCSAPdataList2dhistPhase.append(pdcsapbinningData[Ffilter]["PDCSAPNormPhase"])
|
||||||
PDCSAPdataList.append(pdcsapbinningData[Ffilter]["PDCSAPNormPhase"])
|
PDCSAPdataList2dhistPeak.append(pdcsapbinningData[Ffilter]["Peak"])
|
||||||
PDCSAPlabelList.append("F Stars")
|
PDCSAPdataList.append(pdcsapbinningData[Ffilter]["PDCSAPNormPhase"])
|
||||||
PDCSAPcolorList.append("greenyellow")
|
PDCSAPlabelList.append("F Stars")
|
||||||
plotFilters.append(Ffilter)
|
PDCSAPcolorList.append("greenyellow")
|
||||||
|
plotFilters.append(Ffilter)
|
||||||
|
|
||||||
xData, yData, _ = setupxyDataAndDataList(PDCSAPdataList2dhistPhase, PDCSAPdataList2dhistPeak)
|
xData, yData, _ = setupxyDataAndDataList(PDCSAPdataList2dhistPhase, PDCSAPdataList2dhistPeak)
|
||||||
plotdata = pdcsapbinningData
|
plotdata = pdcsapbinningData
|
||||||
filters = plotFilters
|
filters = plotFilters
|
||||||
generatePlots(PDCSAPdataList, PDCSAPlabelList, PDCSAPcolorList, f"Flare count per phase of {', '.join(combo)} type stars with @bins bins ({numStars} stars)", f"{locFolder}/{''.join(combo)}-Flarecount-@bins_Bins.png",
|
generatePlots(PDCSAPdataList, PDCSAPlabelList, PDCSAPcolorList, f"Flare count per phase of {', '.join(combo)} type stars with @bins bins ({numStars} stars)", f"{locFolder}/{''.join(combo)}-Flarecount-@bins_Bins.png",
|
||||||
xData, yData, f"Flare peak per phase histogram of {', '.join(combo)} type stars with @bins bins ({numStars} stars)", f"{locFolder}/{''.join(combo)}-Flarepeaks-@bins_Bins_maxY-@maxY.png",
|
xData, yData, f"Flare peak per phase histogram of {', '.join(combo)} type stars with @bins bins ({numStars} stars)", f"{locFolder}/{''.join(combo)}-Flarepeaks-@bins_Bins_maxY-@maxY.png",
|
||||||
plotdata, filters, PDCSAPlabelList, PDCSAPcolorList, f"Flare peaks per phase of {', '.join(combo)} type stars ({numStars} stars)", f"{locFolder}/{''.join(combo)}-Flarepeaks_maxY-@maxY.png")
|
plotdata, filters, PDCSAPlabelList, PDCSAPcolorList, f"Flare peaks per phase of {', '.join(combo)} type stars ({numStars} stars)", f"{locFolder}/{''.join(combo)}-Flarepeaks_maxY-@maxY.png")
|
||||||
|
|
||||||
if(comboLength == 1):
|
if(comboLength == 1):
|
||||||
mainSpType = combo[0]
|
mainSpType = combo[0]
|
||||||
spTypes = [f"{mainSpType}0", f"{mainSpType}1", f"{mainSpType}2", f"{mainSpType}3", f"{mainSpType}4", f"{mainSpType}5", f"{mainSpType}6", f"{mainSpType}7", f"{mainSpType}8" f"{mainSpType}9"]
|
spTypes = [f"{mainSpType}0", f"{mainSpType}1", f"{mainSpType}2", f"{mainSpType}3", f"{mainSpType}4", f"{mainSpType}5", f"{mainSpType}6", f"{mainSpType}7", f"{mainSpType}8", f"{mainSpType}9"]
|
||||||
match mainSpType:
|
match mainSpType:
|
||||||
case "M":
|
case "M":
|
||||||
color = "red"
|
color = "red"
|
||||||
@@ -616,30 +618,31 @@ for comboLength in range(1, len(spType) + 1):
|
|||||||
if(peak["FlarePeak"] > 100):
|
if(peak["FlarePeak"] > 100):
|
||||||
print(row["StarName"], "has over 100 peak")
|
print(row["StarName"], "has over 100 peak")
|
||||||
csvFile.close()
|
csvFile.close()
|
||||||
pdcsapbinningData = pd.DataFrame(pdcsapbinningData)
|
if(len(pdcsapbinningData) > 0):
|
||||||
PDCSAPdataList = []
|
pdcsapbinningData = pd.DataFrame(pdcsapbinningData)
|
||||||
PDCSAPlabelList = []
|
PDCSAPdataList = []
|
||||||
PDCSAPcolorList = []
|
PDCSAPlabelList = []
|
||||||
PDCSAPdataList2dhistPhase = []
|
PDCSAPcolorList = []
|
||||||
PDCSAPdataList2dhistPeak = []
|
PDCSAPdataList2dhistPhase = []
|
||||||
PDCSAPlabelList2dhist = []
|
PDCSAPdataList2dhistPeak = []
|
||||||
PDCSAPcolorList2dhist = []
|
PDCSAPlabelList2dhist = []
|
||||||
try:
|
PDCSAPcolorList2dhist = []
|
||||||
SpTypefilter = pdcsapbinningData["SpType"] == spTyp
|
try:
|
||||||
except:
|
SpTypefilter = pdcsapbinningData["SpType"] == spTyp
|
||||||
shutil.rmtree(locFolder)
|
except:
|
||||||
continue
|
shutil.rmtree(locFolder)
|
||||||
PDCSAPdataList2dhistPhase.append(pdcsapbinningData[SpTypefilter]["PDCSAPNormPhase"])
|
continue
|
||||||
PDCSAPdataList2dhistPeak.append(pdcsapbinningData[SpTypefilter]["Peak"])
|
PDCSAPdataList2dhistPhase.append(pdcsapbinningData[SpTypefilter]["PDCSAPNormPhase"])
|
||||||
PDCSAPlabelList.append(f"{spTyp} Stars")
|
PDCSAPdataList2dhistPeak.append(pdcsapbinningData[SpTypefilter]["Peak"])
|
||||||
PDCSAPcolorList.append(color)
|
PDCSAPlabelList.append(f"{spTyp} Stars")
|
||||||
xData, yData, PDCSAPdataList = setupxyDataAndDataList(PDCSAPdataList2dhistPhase, PDCSAPdataList2dhistPeak, PDCSAPdataList, SpTypefilter)
|
PDCSAPcolorList.append(color)
|
||||||
|
xData, yData, PDCSAPdataList = setupxyDataAndDataList(PDCSAPdataList2dhistPhase, PDCSAPdataList2dhistPeak, PDCSAPdataList, SpTypefilter)
|
||||||
|
|
||||||
plotdata = pdcsapbinningData
|
plotdata = pdcsapbinningData
|
||||||
filters = SpTypefilter
|
filters = SpTypefilter
|
||||||
generatePlots(PDCSAPdataList, PDCSAPlabelList, PDCSAPcolorList, f"Flare count in phase of {spTyp} type stars with @bins bins ({numStars} stars)", f"{locFolder}/{''.join(spTyp)}-Flarecount-@bins_Bins.png",
|
generatePlots(PDCSAPdataList, PDCSAPlabelList, PDCSAPcolorList, f"Flare count in phase of {spTyp} type stars with @bins bins ({numStars} stars)", f"{locFolder}/{''.join(spTyp)}-Flarecount-@bins_Bins.png",
|
||||||
xData, yData, f"Flare peak per phase histogram of {spTyp} type stars with @bins bins ({numStars} stars)", f"{locFolder}/{''.join(spTyp)}-Flarepeaks-@bins_Bins_maxY-@maxY.png",
|
xData, yData, f"Flare peak per phase histogram of {spTyp} type stars with @bins bins ({numStars} stars)", f"{locFolder}/{''.join(spTyp)}-Flarepeaks-@bins_Bins_maxY-@maxY.png",
|
||||||
plotdata, filters, PDCSAPlabelList[0], PDCSAPcolorList[0], f"Flare peaks per phase of {spTyp} type stars ({numStars} stars)", f"{locFolder}/{''.join(spTyp)}-Flarepeaks_maxY-@maxY.png")
|
plotdata, filters, PDCSAPlabelList[0], PDCSAPcolorList[0], f"Flare peaks per phase of {spTyp} type stars ({numStars} stars)", f"{locFolder}/{''.join(spTyp)}-Flarepeaks_maxY-@maxY.png")
|
||||||
|
|
||||||
# per Period
|
# per Period
|
||||||
for periodCut in periodsCutList:
|
for periodCut in periodsCutList:
|
||||||
|
|||||||
Reference in New Issue
Block a user