Compare commits
4 Commits
ecf480c2de
...
7d0401d31d
| Author | SHA1 | Date | |
|---|---|---|---|
| 7d0401d31d | |||
| 95ce7917d9 | |||
| 6514a6d125 | |||
| b6c194cb6e |
+115
-103
@@ -85,7 +85,7 @@ def plotBinsHistogram(PDCSAPdataList, PDCSAPlabelList, PDCSAPcolorList, bins, ti
|
|||||||
axHisto.set_title(title, wrap=True)
|
axHisto.set_title(title, wrap=True)
|
||||||
axHisto.xaxis.set_major_formatter(tck.FormatStrFormatter('%g $\pi$'))
|
axHisto.xaxis.set_major_formatter(tck.FormatStrFormatter('%g $\pi$'))
|
||||||
axHisto.xaxis.set_major_locator(MaxNLocator(5))
|
axHisto.xaxis.set_major_locator(MaxNLocator(5))
|
||||||
axHisto.legend()
|
axHisto.legend(loc="lower right")
|
||||||
|
|
||||||
axHistoPhase = axHisto.twinx()
|
axHistoPhase = axHisto.twinx()
|
||||||
if(foldedFits is None):
|
if(foldedFits is None):
|
||||||
@@ -149,7 +149,7 @@ def plotFlarePeaks(plotdata, filters, labels, colors, maxY, title, filename):
|
|||||||
axFlarePeaks.set_title(title, wrap=True)
|
axFlarePeaks.set_title(title, wrap=True)
|
||||||
axFlarePeaks.xaxis.set_major_formatter(tck.FormatStrFormatter('%g $\pi$'))
|
axFlarePeaks.xaxis.set_major_formatter(tck.FormatStrFormatter('%g $\pi$'))
|
||||||
axFlarePeaks.xaxis.set_major_locator(MaxNLocator(5))
|
axFlarePeaks.xaxis.set_major_locator(MaxNLocator(5))
|
||||||
axFlarePeaks.legend()
|
axFlarePeaks.legend(loc="lower right")
|
||||||
plt.savefig(filename, bbox_inches="tight")
|
plt.savefig(filename, bbox_inches="tight")
|
||||||
plt.close()
|
plt.close()
|
||||||
|
|
||||||
@@ -322,6 +322,101 @@ def plotStarPeriod(data, showSourceFilter, folderPath, starName):
|
|||||||
|
|
||||||
|
|
||||||
def plotCombo(data, showSourceFilter, folderPath, combo):
|
def plotCombo(data, showSourceFilter, folderPath, combo):
|
||||||
|
# all flare peaks
|
||||||
|
finalDataAllFlarePeaks = pd.DataFrame()
|
||||||
|
if("M" in combo):
|
||||||
|
Mfilter = data["SpType"].str.startswith("M")
|
||||||
|
Mfilter &= showSourceFilter
|
||||||
|
finalDataAllFlarePeaks = pd.concat([finalDataAllFlarePeaks, data[Mfilter]], ignore_index=True)
|
||||||
|
if("K" in combo):
|
||||||
|
Kfilter = data["SpType"].str.startswith("K")
|
||||||
|
Kfilter &= showSourceFilter
|
||||||
|
finalDataAllFlarePeaks = pd.concat([finalDataAllFlarePeaks, data[Kfilter]], ignore_index=True)
|
||||||
|
if("G" in combo):
|
||||||
|
Gfilter = data["SpType"].str.startswith("G")
|
||||||
|
Gfilter &= showSourceFilter
|
||||||
|
finalDataAllFlarePeaks = pd.concat([finalDataAllFlarePeaks, data[Gfilter]], ignore_index=True)
|
||||||
|
if("F" in combo):
|
||||||
|
Ffilter = data["SpType"].str.startswith("F")
|
||||||
|
Ffilter &= showSourceFilter
|
||||||
|
finalDataAllFlarePeaks = pd.concat([finalDataAllFlarePeaks, data[Ffilter]], ignore_index=True)
|
||||||
|
|
||||||
|
pdcsapbinningDataAllFlarePeaks = []
|
||||||
|
locFolder = f"{folderPath}/{''.join(combo)}/"
|
||||||
|
mkdir_p(f"{locFolder}/")
|
||||||
|
csvFile = open(f"{locFolder}/{''.join(combo)}.csv", "a")
|
||||||
|
csvFile.write("Star Name,Spectral Type,Source,File,Flare Time,Flare Peak,Period,Normalized Phase of Peak,Peak in Period")
|
||||||
|
csvFile.write("\n")
|
||||||
|
for ind, row in finalDataAllFlarePeaks.reset_index().iterrows():
|
||||||
|
PDCSAPminOrigPhase = row["pdcsapFoldedFitPhaseStarEnd"][0]
|
||||||
|
PDCSAPmaxOrigPhase = row["pdcsapFoldedFitPhaseStarEnd"][1]
|
||||||
|
if(len(row["pdcsapFoldedPeaksPhasePair"]) > 0):
|
||||||
|
pdcsapVals = pd.DataFrame(row["pdcsapFoldedPeaksPhasePair"])
|
||||||
|
for td, peak, pv in zip(pdcsapVals["Phase"], pdcsapVals["Peak"], row["pdcsapPeaks"]):
|
||||||
|
normPhase = normalizePhase(td.value, np.abs(PDCSAPminOrigPhase), np.abs(PDCSAPmaxOrigPhase))
|
||||||
|
csvFile.write(f"{row['StarName']},{row['SpType']},{row['Source']},{row['FilePath']},{pv['FlarePeakTime']},{pv['FlarePeak']},{row['pdcsapPeriod']},{normPhase},{peak['FlarePeak']}")
|
||||||
|
csvFile.write("\n")
|
||||||
|
pdcsapbinningDataAllFlarePeaks.append({"SpType": row["SpType"][0],
|
||||||
|
"PDCSAPNormPhase": normPhase,
|
||||||
|
"Peak": peak["FlarePeak"],
|
||||||
|
"StarName": row['StarName']})
|
||||||
|
if(peak["FlarePeak"] > 100):
|
||||||
|
print(row["StarName"], "has over 100 peak")
|
||||||
|
|
||||||
|
csvFile.close()
|
||||||
|
if(len(pdcsapbinningDataAllFlarePeaks) > 0):
|
||||||
|
pdcsapbinningDataAllFlarePeaks = pd.DataFrame(pdcsapbinningDataAllFlarePeaks)
|
||||||
|
numStarsAllFLarePeaks = len(set(pdcsapbinningDataAllFlarePeaks["StarName"]))
|
||||||
|
pd.DataFrame(set(pdcsapbinningDataAllFlarePeaks["StarName"])).to_csv(f"{locFolder}/{''.join(combo)}_starlist.csv")
|
||||||
|
PDCSAPdataListDataAllFlarePeaks = []
|
||||||
|
PDCSAPlabelListDataAllFlarePeaks = []
|
||||||
|
PDCSAPcolorListDataAllFlarePeaks = []
|
||||||
|
PDCSAPdataList2dhistPhaseDataAllFlarePeaks = []
|
||||||
|
PDCSAPdataList2dhistPeakDataAllFlarePeaks = []
|
||||||
|
PDCSAPlabelList2dhistDataAllFlarePeaks = []
|
||||||
|
PDCSAPcolorList2dhistDataAllFlarePeaks = []
|
||||||
|
plotFiltersDataAllFlarePeaks = []
|
||||||
|
if("M" in combo):
|
||||||
|
MfilterDataAllFlarePeaks = pdcsapbinningDataAllFlarePeaks["SpType"] == "M"
|
||||||
|
PDCSAPdataList2dhistPhaseDataAllFlarePeaks.append(pdcsapbinningDataAllFlarePeaks[MfilterDataAllFlarePeaks]["PDCSAPNormPhase"])
|
||||||
|
PDCSAPdataList2dhistPeakDataAllFlarePeaks.append(pdcsapbinningDataAllFlarePeaks[MfilterDataAllFlarePeaks]["Peak"])
|
||||||
|
PDCSAPdataListDataAllFlarePeaks.append(pdcsapbinningDataAllFlarePeaks[MfilterDataAllFlarePeaks]["PDCSAPNormPhase"])
|
||||||
|
PDCSAPlabelListDataAllFlarePeaks.append("M Stars")
|
||||||
|
PDCSAPcolorListDataAllFlarePeaks.append("red")
|
||||||
|
plotFiltersDataAllFlarePeaks.append(MfilterDataAllFlarePeaks)
|
||||||
|
if("K" in combo):
|
||||||
|
KfilterDataAllFlarePeaks = pdcsapbinningDataAllFlarePeaks["SpType"] == "K"
|
||||||
|
PDCSAPdataList2dhistPhaseDataAllFlarePeaks.append(pdcsapbinningDataAllFlarePeaks[KfilterDataAllFlarePeaks]["PDCSAPNormPhase"])
|
||||||
|
PDCSAPdataList2dhistPeakDataAllFlarePeaks.append(pdcsapbinningDataAllFlarePeaks[KfilterDataAllFlarePeaks]["Peak"])
|
||||||
|
PDCSAPdataListDataAllFlarePeaks.append(pdcsapbinningDataAllFlarePeaks[KfilterDataAllFlarePeaks]["PDCSAPNormPhase"])
|
||||||
|
PDCSAPlabelListDataAllFlarePeaks.append("K Stars")
|
||||||
|
PDCSAPcolorListDataAllFlarePeaks.append("orange")
|
||||||
|
plotFiltersDataAllFlarePeaks.append(KfilterDataAllFlarePeaks)
|
||||||
|
if("G" in combo):
|
||||||
|
GfilterDataAllFlarePeaks = pdcsapbinningDataAllFlarePeaks["SpType"] == "G"
|
||||||
|
PDCSAPdataList2dhistPhaseDataAllFlarePeaks.append(pdcsapbinningDataAllFlarePeaks[GfilterDataAllFlarePeaks]["PDCSAPNormPhase"])
|
||||||
|
PDCSAPdataList2dhistPeakDataAllFlarePeaks.append(pdcsapbinningDataAllFlarePeaks[GfilterDataAllFlarePeaks]["Peak"])
|
||||||
|
PDCSAPdataListDataAllFlarePeaks.append(pdcsapbinningDataAllFlarePeaks[GfilterDataAllFlarePeaks]["PDCSAPNormPhase"])
|
||||||
|
PDCSAPlabelListDataAllFlarePeaks.append("G Stars")
|
||||||
|
PDCSAPcolorListDataAllFlarePeaks.append("yellow")
|
||||||
|
plotFiltersDataAllFlarePeaks.append(GfilterDataAllFlarePeaks)
|
||||||
|
if("F" in combo):
|
||||||
|
FfilterDataAllFlarePeaks = pdcsapbinningDataAllFlarePeaks["SpType"] == "F"
|
||||||
|
PDCSAPdataList2dhistPhaseDataAllFlarePeaks.append(pdcsapbinningDataAllFlarePeaks[FfilterDataAllFlarePeaks]["PDCSAPNormPhase"])
|
||||||
|
PDCSAPdataList2dhistPeakDataAllFlarePeaks.append(pdcsapbinningDataAllFlarePeaks[FfilterDataAllFlarePeaks]["Peak"])
|
||||||
|
PDCSAPdataListDataAllFlarePeaks.append(pdcsapbinningDataAllFlarePeaks[FfilterDataAllFlarePeaks]["PDCSAPNormPhase"])
|
||||||
|
PDCSAPlabelListDataAllFlarePeaks.append("F Stars")
|
||||||
|
PDCSAPcolorListDataAllFlarePeaks.append("greenyellow")
|
||||||
|
plotFiltersDataAllFlarePeaks.append(FfilterDataAllFlarePeaks)
|
||||||
|
|
||||||
|
xDataDataAllFlarePeaks, yDataDataAllFlarePeaks, _ = setupxyDataAndDataList(PDCSAPdataList2dhistPhaseDataAllFlarePeaks, PDCSAPdataList2dhistPeakDataAllFlarePeaks,
|
||||||
|
pdcsapbinningDataAllFlarePeaks, "PDCSAPNormPhase")
|
||||||
|
|
||||||
|
generatePlots(PDCSAPdataListDataAllFlarePeaks, PDCSAPlabelListDataAllFlarePeaks, PDCSAPcolorListDataAllFlarePeaks, f"Flare count per phase of {', '.join(combo)} type stars with @bins bins ({numStarsAllFLarePeaks} stars)", f"{locFolder}/{''.join(combo)}-Flarecount-@bins_Bins.png",
|
||||||
|
xDataDataAllFlarePeaks, yDataDataAllFlarePeaks, f"Flare peak per phase histogram of {', '.join(combo)} type stars with @bins bins ({numStarsAllFLarePeaks} stars)", f"{locFolder}/{''.join(combo)}-Flarepeaks-@bins_Bins_maxY-@maxY.png",
|
||||||
|
pdcsapbinningDataAllFlarePeaks, plotFiltersDataAllFlarePeaks, PDCSAPlabelListDataAllFlarePeaks, PDCSAPcolorListDataAllFlarePeaks, f"Flare peaks per phase of {', '.join(combo)} type stars ({numStarsAllFLarePeaks} stars)", f"{locFolder}/{''.join(combo)}-Flarepeaks_maxY-@maxY.png")
|
||||||
|
|
||||||
|
|
||||||
for maxFlarePeak in [1.01, 1.05, 1.1, 1.25, 1.5]:
|
for maxFlarePeak in [1.01, 1.05, 1.1, 1.25, 1.5]:
|
||||||
# max Flare Peak cut
|
# max Flare Peak cut
|
||||||
finalDataMaxFlarePeak = pd.DataFrame()
|
finalDataMaxFlarePeak = pd.DataFrame()
|
||||||
@@ -366,7 +461,8 @@ def plotCombo(data, showSourceFilter, folderPath, combo):
|
|||||||
csvFileU.write("\n")
|
csvFileU.write("\n")
|
||||||
pdcsapbinningDataU.append({"SpType": row["SpType"][0],
|
pdcsapbinningDataU.append({"SpType": row["SpType"][0],
|
||||||
"PDCSAPNormPhase": normPhase,
|
"PDCSAPNormPhase": normPhase,
|
||||||
"Peak": peak["FlarePeak"]})
|
"Peak": peak["FlarePeak"],
|
||||||
|
"StarName": row['StarName']})
|
||||||
if(peak["FlarePeak"] > 100):
|
if(peak["FlarePeak"] > 100):
|
||||||
print(row["StarName"], "has over 100 peak")
|
print(row["StarName"], "has over 100 peak")
|
||||||
else:
|
else:
|
||||||
@@ -375,7 +471,8 @@ def plotCombo(data, showSourceFilter, folderPath, combo):
|
|||||||
csvFileO.write("\n")
|
csvFileO.write("\n")
|
||||||
pdcsapbinningDataO.append({"SpType": row["SpType"][0],
|
pdcsapbinningDataO.append({"SpType": row["SpType"][0],
|
||||||
"PDCSAPNormPhase": normPhase,
|
"PDCSAPNormPhase": normPhase,
|
||||||
"Peak": peak["FlarePeak"]})
|
"Peak": peak["FlarePeak"],
|
||||||
|
"StarName": row['StarName']})
|
||||||
if(peak["FlarePeak"] > 100):
|
if(peak["FlarePeak"] > 100):
|
||||||
print(row["StarName"], "has over 100 peak")
|
print(row["StarName"], "has over 100 peak")
|
||||||
|
|
||||||
@@ -384,6 +481,7 @@ def plotCombo(data, showSourceFilter, folderPath, combo):
|
|||||||
if(len(pdcsapbinningDataU) > 0):
|
if(len(pdcsapbinningDataU) > 0):
|
||||||
pdcsapbinningDataU = pd.DataFrame(pdcsapbinningDataU)
|
pdcsapbinningDataU = pd.DataFrame(pdcsapbinningDataU)
|
||||||
numStarsFlarePeakU = len(set(pdcsapbinningDataU["StarName"]))
|
numStarsFlarePeakU = len(set(pdcsapbinningDataU["StarName"]))
|
||||||
|
pd.DataFrame(set(pdcsapbinningDataU["StarName"])).to_csv(f"{locFolderU}/{''.join(combo)}_starlist.csv")
|
||||||
PDCSAPdataListU = []
|
PDCSAPdataListU = []
|
||||||
PDCSAPlabelListU = []
|
PDCSAPlabelListU = []
|
||||||
PDCSAPcolorListU = []
|
PDCSAPcolorListU = []
|
||||||
@@ -432,6 +530,7 @@ def plotCombo(data, showSourceFilter, folderPath, combo):
|
|||||||
if(len(pdcsapbinningDataO) > 0):
|
if(len(pdcsapbinningDataO) > 0):
|
||||||
pdcsapbinningDataO = pd.DataFrame(pdcsapbinningDataO)
|
pdcsapbinningDataO = pd.DataFrame(pdcsapbinningDataO)
|
||||||
numStarsFlarePeakO = len(set(pdcsapbinningDataO["StarName"]))
|
numStarsFlarePeakO = len(set(pdcsapbinningDataO["StarName"]))
|
||||||
|
pd.DataFrame(set(pdcsapbinningDataO["StarName"])).to_csv(f"{locFolderO}/{''.join(combo)}_starlist.csv")
|
||||||
PDCSAPdataListO = []
|
PDCSAPdataListO = []
|
||||||
PDCSAPlabelListO = []
|
PDCSAPlabelListO = []
|
||||||
PDCSAPcolorListO = []
|
PDCSAPcolorListO = []
|
||||||
@@ -476,98 +575,6 @@ def plotCombo(data, showSourceFilter, folderPath, combo):
|
|||||||
generatePlots(PDCSAPdataListO, PDCSAPlabelListO, PDCSAPcolorListO, f"Flare count per phase of {', '.join(combo)} type stars with @bins bins ({numStarsFlarePeakO} stars)", f"{locFolderO}/{''.join(combo)}_minFlarePeak_{maxFlarePeak}-Flarecount-@bins_Bins.png",
|
generatePlots(PDCSAPdataListO, PDCSAPlabelListO, PDCSAPcolorListO, f"Flare count per phase of {', '.join(combo)} type stars with @bins bins ({numStarsFlarePeakO} stars)", f"{locFolderO}/{''.join(combo)}_minFlarePeak_{maxFlarePeak}-Flarecount-@bins_Bins.png",
|
||||||
xData, yData, f"Flare peak per phase histogram of {', '.join(combo)} type stars with @bins bins ({numStarsFlarePeakO} stars)", f"{locFolderO}/{''.join(combo)}_minFlarePeak_{maxFlarePeak}-Flarepeaks-@bins_Bins_maxY-@maxY.png",
|
xData, yData, f"Flare peak per phase histogram of {', '.join(combo)} type stars with @bins bins ({numStarsFlarePeakO} stars)", f"{locFolderO}/{''.join(combo)}_minFlarePeak_{maxFlarePeak}-Flarepeaks-@bins_Bins_maxY-@maxY.png",
|
||||||
pdcsapbinningDataO, plotFiltersO, PDCSAPlabelListO, PDCSAPcolorListO, f"Flare peaks per phase of {', '.join(combo)} type stars ({numStarsFlarePeakO} stars)", f"{locFolderO}/{''.join(combo)}_minFlarePeak_{maxFlarePeak}-Flarepeaks_maxY-@maxY.png")
|
pdcsapbinningDataO, plotFiltersO, PDCSAPlabelListO, PDCSAPcolorListO, f"Flare peaks per phase of {', '.join(combo)} type stars ({numStarsFlarePeakO} stars)", f"{locFolderO}/{''.join(combo)}_minFlarePeak_{maxFlarePeak}-Flarepeaks_maxY-@maxY.png")
|
||||||
# all flare peaks
|
|
||||||
finalDataAllFlarePeaks = pd.DataFrame()
|
|
||||||
if("M" in combo):
|
|
||||||
Mfilter = data["SpType"].str.startswith("M")
|
|
||||||
Mfilter &= showSourceFilter
|
|
||||||
finalDataAllFlarePeaks = pd.concat([finalDataAllFlarePeaks, data[Mfilter]], ignore_index=True)
|
|
||||||
if("K" in combo):
|
|
||||||
Kfilter = data["SpType"].str.startswith("K")
|
|
||||||
Kfilter &= showSourceFilter
|
|
||||||
finalDataAllFlarePeaks = pd.concat([finalDataAllFlarePeaks, data[Kfilter]], ignore_index=True)
|
|
||||||
if("G" in combo):
|
|
||||||
Gfilter = data["SpType"].str.startswith("G")
|
|
||||||
Gfilter &= showSourceFilter
|
|
||||||
finalDataAllFlarePeaks = pd.concat([finalDataAllFlarePeaks, data[Gfilter]], ignore_index=True)
|
|
||||||
if("F" in combo):
|
|
||||||
Ffilter = data["SpType"].str.startswith("F")
|
|
||||||
Ffilter &= showSourceFilter
|
|
||||||
finalDataAllFlarePeaks = pd.concat([finalDataAllFlarePeaks, data[Ffilter]], ignore_index=True)
|
|
||||||
|
|
||||||
pdcsapbinningData = []
|
|
||||||
locFolder = f"{folderPath}/{''.join(combo)}/"
|
|
||||||
mkdir_p(f"{locFolder}/")
|
|
||||||
csvFile = open(f"{locFolder}/{''.join(combo)}.csv", "a")
|
|
||||||
csvFile.write("Star Name,Spectral Type,Source,File,Flare Time,Flare Peak,Period,Normalized Phase of Peak,Peak in Period")
|
|
||||||
csvFile.write("\n")
|
|
||||||
for ind, row in finalDataAllFlarePeaks.reset_index().iterrows():
|
|
||||||
PDCSAPminOrigPhase = row["pdcsapFoldedFitPhaseStarEnd"][0]
|
|
||||||
PDCSAPmaxOrigPhase = row["pdcsapFoldedFitPhaseStarEnd"][1]
|
|
||||||
if(len(row["pdcsapFoldedPeaksPhasePair"]) > 0):
|
|
||||||
pdcsapVals = pd.DataFrame(row["pdcsapFoldedPeaksPhasePair"])
|
|
||||||
for td, peak, pv in zip(pdcsapVals["Phase"], pdcsapVals["Peak"], row["pdcsapPeaks"]):
|
|
||||||
normPhase = normalizePhase(td.value, np.abs(PDCSAPminOrigPhase), np.abs(PDCSAPmaxOrigPhase))
|
|
||||||
csvFile.write(f"{row['StarName']},{row['SpType']},{row['Source']},{row['FilePath']},{pv['FlarePeakTime']},{pv['FlarePeak']},{row['pdcsapPeriod']},{normPhase},{peak['FlarePeak']}")
|
|
||||||
csvFile.write("\n")
|
|
||||||
pdcsapbinningData.append({"SpType": row["SpType"][0],
|
|
||||||
"PDCSAPNormPhase": normPhase,
|
|
||||||
"Peak": peak["FlarePeak"]})
|
|
||||||
if(peak["FlarePeak"] > 100):
|
|
||||||
print(row["StarName"], "has over 100 peak")
|
|
||||||
|
|
||||||
csvFile.close()
|
|
||||||
if(len(pdcsapbinningData) > 0):
|
|
||||||
pdcsapbinningData = pd.DataFrame(pdcsapbinningData)
|
|
||||||
numStarsAllFLarePeaks = len(set(pdcsapbinningData["StarName"]))
|
|
||||||
PDCSAPdataList = []
|
|
||||||
PDCSAPlabelList = []
|
|
||||||
PDCSAPcolorList = []
|
|
||||||
PDCSAPdataList2dhistPhase = []
|
|
||||||
PDCSAPdataList2dhistPeak = []
|
|
||||||
PDCSAPlabelList2dhist = []
|
|
||||||
PDCSAPcolorList2dhist = []
|
|
||||||
plotFilters = []
|
|
||||||
if("M" in combo):
|
|
||||||
Mfilter = pdcsapbinningData["SpType"] == "M"
|
|
||||||
PDCSAPdataList2dhistPhase.append(pdcsapbinningData[Mfilter]["PDCSAPNormPhase"])
|
|
||||||
PDCSAPdataList2dhistPeak.append(pdcsapbinningData[Mfilter]["Peak"])
|
|
||||||
PDCSAPdataList.append(pdcsapbinningData[Mfilter]["PDCSAPNormPhase"])
|
|
||||||
PDCSAPlabelList.append("M Stars")
|
|
||||||
PDCSAPcolorList.append("red")
|
|
||||||
plotFilters.append(Mfilter)
|
|
||||||
if("K" in combo):
|
|
||||||
Kfilter = pdcsapbinningData["SpType"] == "K"
|
|
||||||
PDCSAPdataList2dhistPhase.append(pdcsapbinningData[Kfilter]["PDCSAPNormPhase"])
|
|
||||||
PDCSAPdataList2dhistPeak.append(pdcsapbinningData[Kfilter]["Peak"])
|
|
||||||
PDCSAPdataList.append(pdcsapbinningData[Kfilter]["PDCSAPNormPhase"])
|
|
||||||
PDCSAPlabelList.append("K Stars")
|
|
||||||
PDCSAPcolorList.append("orange")
|
|
||||||
plotFilters.append(Kfilter)
|
|
||||||
if("G" in combo):
|
|
||||||
Gfilter = pdcsapbinningData["SpType"] == "G"
|
|
||||||
PDCSAPdataList2dhistPhase.append(pdcsapbinningData[Gfilter]["PDCSAPNormPhase"])
|
|
||||||
PDCSAPdataList2dhistPeak.append(pdcsapbinningData[Gfilter]["Peak"])
|
|
||||||
PDCSAPdataList.append(pdcsapbinningData[Gfilter]["PDCSAPNormPhase"])
|
|
||||||
PDCSAPlabelList.append("G Stars")
|
|
||||||
PDCSAPcolorList.append("yellow")
|
|
||||||
plotFilters.append(Gfilter)
|
|
||||||
if("F" in combo):
|
|
||||||
Ffilter = pdcsapbinningData["SpType"] == "F"
|
|
||||||
PDCSAPdataList2dhistPhase.append(pdcsapbinningData[Ffilter]["PDCSAPNormPhase"])
|
|
||||||
PDCSAPdataList2dhistPeak.append(pdcsapbinningData[Ffilter]["Peak"])
|
|
||||||
PDCSAPdataList.append(pdcsapbinningData[Ffilter]["PDCSAPNormPhase"])
|
|
||||||
PDCSAPlabelList.append("F Stars")
|
|
||||||
PDCSAPcolorList.append("greenyellow")
|
|
||||||
plotFilters.append(Ffilter)
|
|
||||||
|
|
||||||
xData, yData, _ = setupxyDataAndDataList(PDCSAPdataList2dhistPhase, PDCSAPdataList2dhistPeak,
|
|
||||||
pdcsapbinningData, "PDCSAPNormPhase",)
|
|
||||||
plotdata = pdcsapbinningData
|
|
||||||
filters = plotFilters
|
|
||||||
generatePlots(PDCSAPdataList, PDCSAPlabelList, PDCSAPcolorList, f"Flare count per phase of {', '.join(combo)} type stars with @bins bins ({numStarsAllFLarePeaks} 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 ({numStarsAllFLarePeaks} 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 ({numStarsAllFLarePeaks} stars)", f"{locFolder}/{''.join(combo)}-Flarepeaks_maxY-@maxY.png")
|
|
||||||
|
|
||||||
if(len(combo) == 1):
|
if(len(combo) == 1):
|
||||||
mainSpType = combo[0]
|
mainSpType = combo[0]
|
||||||
@@ -606,13 +613,15 @@ def plotCombo(data, showSourceFilter, folderPath, combo):
|
|||||||
csvFile.write("\n")
|
csvFile.write("\n")
|
||||||
pdcsapbinningData.append({"SpType": f'{row["SpType"][0]}{row["SpType"][1]}',
|
pdcsapbinningData.append({"SpType": f'{row["SpType"][0]}{row["SpType"][1]}',
|
||||||
"PDCSAPNormPhase": normPhase,
|
"PDCSAPNormPhase": normPhase,
|
||||||
"Peak": peak["FlarePeak"]})
|
"Peak": peak["FlarePeak"],
|
||||||
|
"StarName": row['StarName']})
|
||||||
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()
|
||||||
if(len(pdcsapbinningData) > 0):
|
if(len(pdcsapbinningData) > 0):
|
||||||
pdcsapbinningData = pd.DataFrame(pdcsapbinningData)
|
pdcsapbinningData = pd.DataFrame(pdcsapbinningData)
|
||||||
numStarsAccSpType = len(set(pdcsapbinningData[typeFilter]["StarName"]))
|
numStarsAccSpType = len(set(pdcsapbinningData["StarName"]))
|
||||||
|
pd.DataFrame(set(pdcsapbinningData["StarName"])).to_csv(f"{locFolder}/{spTyp}_starlist.csv")
|
||||||
PDCSAPdataList = []
|
PDCSAPdataList = []
|
||||||
PDCSAPlabelList = []
|
PDCSAPlabelList = []
|
||||||
PDCSAPcolorList = []
|
PDCSAPcolorList = []
|
||||||
@@ -685,13 +694,15 @@ def plotCombo(data, showSourceFilter, folderPath, combo):
|
|||||||
csvFileU.write("\n")
|
csvFileU.write("\n")
|
||||||
pdcsapbinningDataU.append({"SpType": f'{row["SpType"][0]}',
|
pdcsapbinningDataU.append({"SpType": f'{row["SpType"][0]}',
|
||||||
"PDCSAPNormPhase": normPhase,
|
"PDCSAPNormPhase": normPhase,
|
||||||
"Peak": peak["FlarePeak"]})
|
"Peak": peak["FlarePeak"],
|
||||||
|
"StarName": row['StarName']})
|
||||||
else:
|
else:
|
||||||
csvFileO.write(f"{row['StarName']},{row['SpType']},{row['Source']},{row['FilePath']},{pv['FlarePeakTime']},{pv['FlarePeak']},{row['pdcsapPeriod']},{row['MeanPeriod']},{normPhase},{peak['FlarePeak']}")
|
csvFileO.write(f"{row['StarName']},{row['SpType']},{row['Source']},{row['FilePath']},{pv['FlarePeakTime']},{pv['FlarePeak']},{row['pdcsapPeriod']},{row['MeanPeriod']},{normPhase},{peak['FlarePeak']}")
|
||||||
csvFileO.write("\n")
|
csvFileO.write("\n")
|
||||||
pdcsapbinningDataO.append({"SpType": f'{row["SpType"][0]}',
|
pdcsapbinningDataO.append({"SpType": f'{row["SpType"][0]}',
|
||||||
"PDCSAPNormPhase": normPhase,
|
"PDCSAPNormPhase": normPhase,
|
||||||
"Peak": peak["FlarePeak"]})
|
"Peak": peak["FlarePeak"],
|
||||||
|
"StarName": row['StarName']})
|
||||||
if(peak["FlarePeak"] > 100):
|
if(peak["FlarePeak"] > 100):
|
||||||
print(row["StarName"], "has over 100 peak")
|
print(row["StarName"], "has over 100 peak")
|
||||||
csvFileU.close()
|
csvFileU.close()
|
||||||
@@ -705,9 +716,6 @@ def plotCombo(data, showSourceFilter, folderPath, combo):
|
|||||||
PDCSAPdataList2dhistPhaseO = []; PDCSAPdataList2dhistPeakO = []
|
PDCSAPdataList2dhistPhaseO = []; PDCSAPdataList2dhistPeakO = []
|
||||||
plotFiltersU = []; plotFiltersO = [];
|
plotFiltersU = []; plotFiltersO = [];
|
||||||
|
|
||||||
numStarsPeriodU = len(set(pdcsapbinningDataU[typeFilter]["StarName"]))
|
|
||||||
numStarsPeriodO = len(set(pdcsapbinningDataO[typeFilter]["StarName"]))
|
|
||||||
|
|
||||||
if("M" in combo):
|
if("M" in combo):
|
||||||
PDCSAPlabelList.append("M Stars")
|
PDCSAPlabelList.append("M Stars")
|
||||||
PDCSAPcolorList.append("red")
|
PDCSAPcolorList.append("red")
|
||||||
@@ -722,6 +730,8 @@ def plotCombo(data, showSourceFilter, folderPath, combo):
|
|||||||
PDCSAPcolorList.append("greenyellow")
|
PDCSAPcolorList.append("greenyellow")
|
||||||
|
|
||||||
if(len(pdcsapbinningDataU) > 0):
|
if(len(pdcsapbinningDataU) > 0):
|
||||||
|
numStarsPeriodU = len(set(pdcsapbinningDataU["StarName"]))
|
||||||
|
pd.DataFrame(set(pdcsapbinningDataU["StarName"])).to_csv(f"{locFolder}/under_{periodCut}_starlist.csv")
|
||||||
if("M" in combo):
|
if("M" in combo):
|
||||||
MfilterU = pdcsapbinningDataU["SpType"] == "M"
|
MfilterU = pdcsapbinningDataU["SpType"] == "M"
|
||||||
PDCSAPdataList2dhistPhaseU.append(pdcsapbinningDataU[MfilterU]["PDCSAPNormPhase"])
|
PDCSAPdataList2dhistPhaseU.append(pdcsapbinningDataU[MfilterU]["PDCSAPNormPhase"])
|
||||||
@@ -748,6 +758,8 @@ def plotCombo(data, showSourceFilter, folderPath, combo):
|
|||||||
plotFiltersU.append(FfilterU)
|
plotFiltersU.append(FfilterU)
|
||||||
|
|
||||||
if(len(pdcsapbinningDataO) > 0):
|
if(len(pdcsapbinningDataO) > 0):
|
||||||
|
numStarsPeriodO = len(set(pdcsapbinningDataO["StarName"]))
|
||||||
|
pd.DataFrame(set(pdcsapbinningDataO["StarName"])).to_csv(f"{locFolder}/over_{periodCut}_starlist.csv")
|
||||||
if("M" in combo):
|
if("M" in combo):
|
||||||
MfilterO = pdcsapbinningDataO["SpType"] == "M"
|
MfilterO = pdcsapbinningDataO["SpType"] == "M"
|
||||||
PDCSAPdataList2dhistPhaseO.append(pdcsapbinningDataO[MfilterO]["PDCSAPNormPhase"])
|
PDCSAPdataList2dhistPhaseO.append(pdcsapbinningDataO[MfilterO]["PDCSAPNormPhase"])
|
||||||
|
|||||||
@@ -15,6 +15,18 @@ from errno import EEXIST
|
|||||||
from os import makedirs, path
|
from os import makedirs, path
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
SMALL_SIZE = 16
|
||||||
|
MEDIUM_SIZE = 18
|
||||||
|
BIGGER_SIZE = 20
|
||||||
|
|
||||||
|
plt.rc('font', size=SMALL_SIZE) # controls default text sizes
|
||||||
|
plt.rc('axes', titlesize=MEDIUM_SIZE) # fontsize of the axes title
|
||||||
|
plt.rc('axes', labelsize=MEDIUM_SIZE) # fontsize of the x and y labels
|
||||||
|
plt.rc('xtick', labelsize=SMALL_SIZE) # fontsize of the tick labels
|
||||||
|
plt.rc('ytick', labelsize=SMALL_SIZE) # fontsize of the tick labels
|
||||||
|
plt.rc('legend', fontsize=SMALL_SIZE) # legend fontsize
|
||||||
|
plt.rc('figure', titlesize=BIGGER_SIZE) # fontsize of the figure title
|
||||||
|
|
||||||
def mkdir_p(mypath):
|
def mkdir_p(mypath):
|
||||||
'''Creates a directory. equivalent to using mkdir -p on the command line'''
|
'''Creates a directory. equivalent to using mkdir -p on the command line'''
|
||||||
|
|
||||||
@@ -48,13 +60,13 @@ def getFlareCount(filesDict):
|
|||||||
|
|
||||||
lc.plot()
|
lc.plot()
|
||||||
plt.title(f"{starName} - normalized lightcurve")
|
plt.title(f"{starName} - normalized lightcurve")
|
||||||
plt.savefig(f"{starFolder}/{starNameR}_{source}-{sequence}-lc.png")
|
plt.savefig(f"{starFolder}/{starNameR}_{source}-{sequence}-lc.png", bbox_inches="tight")
|
||||||
plt.close()
|
plt.close()
|
||||||
|
|
||||||
flattenedLc = lc.flatten()
|
flattenedLc = lc.flatten()
|
||||||
flattenedLc.plot()
|
flattenedLc.plot()
|
||||||
plt.title(f"{starName} - flattened lightcurve")
|
plt.title(f"{starName} - flattened lightcurve")
|
||||||
plt.savefig(f"{starFolder}/{starNameR}_{source}-{sequence}-flattened_lc.png")
|
plt.savefig(f"{starFolder}/{starNameR}_{source}-{sequence}-flattened_lc.png", bbox_inches="tight")
|
||||||
plt.close()
|
plt.close()
|
||||||
|
|
||||||
pdcsapPeaks, pdcsapFits = calculateFlareFitsForLightcurve(flattenedLc, normalizedLC=lc)
|
pdcsapPeaks, pdcsapFits = calculateFlareFitsForLightcurve(flattenedLc, normalizedLC=lc)
|
||||||
@@ -64,7 +76,7 @@ def getFlareCount(filesDict):
|
|||||||
plt.plot(p["FlarePeakTime"].value, lc.flux[p["StandardIndex"]], "x", color="red")
|
plt.plot(p["FlarePeakTime"].value, lc.flux[p["StandardIndex"]], "x", color="red")
|
||||||
plt.plot([], [], "x", color="red", label="Flare peaks")
|
plt.plot([], [], "x", color="red", label="Flare peaks")
|
||||||
plt.legend()
|
plt.legend()
|
||||||
plt.savefig(f"{starFolder}/{starNameR}_{source}-{sequence}-lc-marked_flares.png")
|
plt.savefig(f"{starFolder}/{starNameR}_{source}-{sequence}-lc-marked_flares.png", bbox_inches="tight")
|
||||||
plt.close()
|
plt.close()
|
||||||
|
|
||||||
flattenedLc.plot()
|
flattenedLc.plot()
|
||||||
@@ -76,7 +88,7 @@ def getFlareCount(filesDict):
|
|||||||
plt.plot(p["FlarePeakTime"].value, p["FlarePeak"], "x", color="red")
|
plt.plot(p["FlarePeakTime"].value, p["FlarePeak"], "x", color="red")
|
||||||
plt.plot([], [], "x", color="red", label="Flare peaks")
|
plt.plot([], [], "x", color="red", label="Flare peaks")
|
||||||
plt.legend()
|
plt.legend()
|
||||||
plt.savefig(f"{starFolder}/{starNameR}_{source}-{sequence}-flattened_lc-marked_flares.png")
|
plt.savefig(f"{starFolder}/{starNameR}_{source}-{sequence}-flattened_lc-marked_flares.png", bbox_inches="tight")
|
||||||
plt.close()
|
plt.close()
|
||||||
|
|
||||||
pdcsapValSec, pdcsapTds = getTotalValidDataInSeconds(lc, "pdcsap_flux")
|
pdcsapValSec, pdcsapTds = getTotalValidDataInSeconds(lc, "pdcsap_flux")
|
||||||
@@ -86,7 +98,7 @@ def getFlareCount(filesDict):
|
|||||||
|
|
||||||
pdcsapPeriodogram.plot(view="period")
|
pdcsapPeriodogram.plot(view="period")
|
||||||
plt.plot(pdcsapPeakPeriod, pdcsapPeriodogram.power[maxPeriodIndex], "x", color="red")
|
plt.plot(pdcsapPeakPeriod, pdcsapPeriodogram.power[maxPeriodIndex], "x", color="red")
|
||||||
plt.savefig(f"{starFolder}/{starNameR}_{source}-{sequence}-periodogram-marked_max.png")
|
plt.savefig(f"{starFolder}/{starNameR}_{source}-{sequence}-periodogram-marked_max.png", bbox_inches="tight")
|
||||||
plt.close()
|
plt.close()
|
||||||
|
|
||||||
#pdcsapEpochTime = getEpochTime(lc)
|
#pdcsapEpochTime = getEpochTime(lc)
|
||||||
@@ -108,7 +120,7 @@ def getFlareCount(filesDict):
|
|||||||
optimizedFit["foldedLC"].flux[optimizedFit["foldedLC"].cycle == cycle][foldedIndex], "x", color="red")
|
optimizedFit["foldedLC"].flux[optimizedFit["foldedLC"].cycle == cycle][foldedIndex], "x", color="red")
|
||||||
plt.plot([], [], "x", color="red", label="Flare peaks")
|
plt.plot([], [], "x", color="red", label="Flare peaks")
|
||||||
plt.legend()
|
plt.legend()
|
||||||
plt.savefig(f"{starFolder}/{starNameR}_{source}-{sequence}-foldedLC-marked_fit_flares.png")
|
plt.savefig(f"{starFolder}/{starNameR}_{source}-{sequence}-foldedLC-marked_fit_flares.png", bbox_inches="tight")
|
||||||
plt.close()
|
plt.close()
|
||||||
|
|
||||||
if(optimizedFit["periodFoldedLC"] is not None):
|
if(optimizedFit["periodFoldedLC"] is not None):
|
||||||
@@ -123,7 +135,7 @@ def getFlareCount(filesDict):
|
|||||||
optimizedFit["periodFoldedLC"].flux[optimizedFit["periodFoldedLC"].cycle == cycle][foldedIndex], "x", color="red")
|
optimizedFit["periodFoldedLC"].flux[optimizedFit["periodFoldedLC"].cycle == cycle][foldedIndex], "x", color="red")
|
||||||
plt.plot([], [], "x", color="red", label="Flare peaks")
|
plt.plot([], [], "x", color="red", label="Flare peaks")
|
||||||
plt.legend()
|
plt.legend()
|
||||||
plt.savefig(f"{starFolder}/{starNameR}_{source}-{sequence}-periodFoldedLC-marked_fit_flares.png")
|
plt.savefig(f"{starFolder}/{starNameR}_{source}-{sequence}-periodFoldedLC-marked_fit_flares.png", bbox_inches="tight")
|
||||||
plt.close()
|
plt.close()
|
||||||
|
|
||||||
filesDict["pdcsapPeaks"] = pdcsapPeaks
|
filesDict["pdcsapPeaks"] = pdcsapPeaks
|
||||||
|
|||||||
@@ -301,8 +301,8 @@ class FlaredetectorWidget(QtWidgets.QWidget):
|
|||||||
phase, sineFit, _ = getFoldedBestFit(lc, fitType=self.foldedFitType)
|
phase, sineFit, _ = getFoldedBestFit(lc, fitType=self.foldedFitType)
|
||||||
self.figureAxis.plot(phase, sineFit, color="red")
|
self.figureAxis.plot(phase, sineFit, color="red")
|
||||||
print(phase, sineFit)
|
print(phase, sineFit)
|
||||||
minPhasesBoundsIndices, maxPhasesBoundsIndices = getPhaseRangesNearPeak(getFoldedFitPeakValley(sineFit), phase)
|
#minPhasesBoundsIndices, maxPhasesBoundsIndices = getPhaseRangesNearPeak(getFoldedFitPeakValley(sineFit), phase)
|
||||||
plotPhaseRangesNearPeak((minPhasesBoundsIndices, maxPhasesBoundsIndices), phase, ax=self.figureAxis)
|
#plotPhaseRangesNearPeak((minPhasesBoundsIndices, maxPhasesBoundsIndices), phase, ax=self.figureAxis)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("Failed to get fit")
|
print("Failed to get fit")
|
||||||
print(e)
|
print(e)
|
||||||
|
|||||||
Reference in New Issue
Block a user