Compare commits

18 Commits

Author SHA1 Message Date
SGCMarkus 7d0401d31d generate_plots: fix formatting and star count 2025-06-08 15:39:30 +02:00
SGCMarkus 95ce7917d9 Merge branch 'main' of https://gitea.markus.stammgruppe.eu/SGCMarkus/flaredetector 2025-06-08 15:38:40 +02:00
SGCMarkus ecf480c2de generate_latex_table: update printed tables 2025-06-08 15:37:40 +02:00
SGCMarkus 6514a6d125 Merge branch 'main' of https://gitea.markus.stammgruppe.eu/SGCMarkus/flaredetector 2025-05-31 16:54:33 +02:00
SGCMarkus b6c194cb6e CalcAllFlaresThread: set proper plot description sizes 2025-05-31 16:54:26 +02:00
SGCMarkus 9afe0993f6 generate_plots: fix flare number 2025-05-31 16:53:17 +02:00
SGCMarkus c1c58746e9 FlareSummaryPlotGUI: bring up to date 2025-05-31 16:52:41 +02:00
SGCMarkus c36c227e11 generate_plots: add option to adjust plot text sizes 2025-05-25 18:22:32 +02:00
SGCMarkus cd04b272ca fix period plot generation after rework 2025-05-25 14:24:42 +02:00
SGCMarkus a41edfcaa7 add latex table generation file 2025-05-21 17:59:23 +02:00
SGCMarkus 44d5da5975 generate_plots: fix multithreaded plot generation 2025-05-08 14:55:21 +02:00
SGCMarkus 7d574febcf generate_plots: use multiprocessing 2025-05-06 11:48:01 +02:00
SGCMarkus 43eb79bcc6 FlaredetectorWidget: properly label print 2025-05-06 11:46:45 +02:00
SGCMarkus 1fc9b82a1a generate plots: fix using wrong dataset for full period histogram 2025-04-27 21:22:04 +02:00
SGCMarkus 060cae2264 generate_plots: bring uptodate for changes, add max flare peak plots 2025-04-27 20:32:44 +02:00
SGCMarkus 54bd2e4bff add updated data package 2025-04-27 20:31:50 +02:00
SGCMarkus a7a816a892 CalcAllFlaresThread: add isValid flag to final output 2025-04-27 20:30:50 +02:00
SGCMarkus 4ad7974bb1 flaredetector: util: optimize: improve minima detection 2025-04-27 20:29:46 +02:00
7 changed files with 782 additions and 675 deletions
BIN
View File
Binary file not shown.
+84
View File
@@ -0,0 +1,84 @@
import pandas as pd
import numpy as np
from main.astrodatagui.db.StarsDB import StarDB
db: StarDB = StarDB.getInstance("stars.db")
starMainIDs = db.getAllStars()
resFull = []
resUsed = []
resUnused = []
fullData = pd.read_pickle("datav5.1.cff")
usedMstars = pd.read_csv("../large sized plots/2025-5-31-sine/M/M_starlist.csv", header=0, names=["StarName"])
usedKstars = pd.read_csv("../large sized plots/2025-5-31-sine/K/K_starlist.csv", header=0, names=["StarName"])
usedGstars = pd.read_csv("../large sized plots/2025-5-31-sine/G/G_starlist.csv", header=0, names=["StarName"])
usedFstars = pd.read_csv("../large sized plots/2025-5-31-sine/F/F_starlist.csv", header=0, names=["StarName"])
for mainID in starMainIDs:
altNames = db.getStarAltNames(mainID)
infos = db.getStarInfos(mainID)
kicName = "-"
ticName = "-"
spType = "-"
for name in altNames:
if name[0].startswith("TIC"):
ticName = name[0]
if name[0].startswith("KIC"):
kicName = name[0]
spType = infos["SpType"]
hasValidSineFit = fullData[(fullData["StarName"] == mainID) & (fullData["FitType"] == "sine")]["isValidFold"].any()
hasValidPolyFit = fullData[(fullData["StarName"] == mainID) & (fullData["FitType"] == "poly")]["isValidFold"].any()
hasValidLinearFit = fullData[(fullData["StarName"] == mainID) & (fullData["FitType"] == "linear")]["isValidFold"].any()
fitTypeString = []
if(hasValidSineFit): fitTypeString.append("sine")
if(hasValidPolyFit): fitTypeString.append("poly")
if(hasValidLinearFit): fitTypeString.append("linear")
fitTypeString = ', '.join(fitTypeString)
resFull.append({"MainID": mainID,
"Spectral Type": spType,
"TIC": ticName,
"KIC": kicName,
"Fit Types": fitTypeString})
if((usedMstars["StarName"] == mainID).any() or (usedKstars["StarName"] == mainID).any() or
(usedGstars["StarName"] == mainID).any() or (usedFstars["StarName"] == mainID).any()):
resUsed.append({"MainID": mainID,
"Spectral Type": spType,
"TIC": ticName,
"KIC": kicName,
"Fit Types": fitTypeString})
else:
resUnused.append({"MainID": mainID,
"Spectral Type": spType,
"TIC": ticName,
"KIC": kicName,
"Fit Types": fitTypeString})
resFull = pd.DataFrame(resFull)
resFull.sort_values(by=["Spectral Type", "MainID"])
resUsed = pd.DataFrame(resUsed)
resUsed.sort_values(by=["Spectral Type", "MainID"])
resUnused = pd.DataFrame(resUnused)
resUnused.sort_values(by=["Spectral Type", "MainID"])
for sptype in ["M", "K", "G", "F"]:
texFile = open(f"table_{sptype}_used.tex", "w")
tex = resUsed[resUsed["Spectral Type"].str.startswith(sptype)].sort_values(by=["Spectral Type", "MainID"]).to_latex(index=False)
texFile.write(tex)
texFile.close()
texFile = open(f"table_full.tex", "w")
tex = resFull.sort_values(by=["Spectral Type", "MainID"]).to_latex(index=False)
texFile.write(tex)
texFile.close()
texFile = open(f"table_unused.tex", "w")
tex = resUnused.sort_values(by=["Spectral Type", "MainID"]).to_latex(index=False)
texFile.write(tex)
texFile.close()
+590 -499
View File
File diff suppressed because it is too large Load Diff
+21 -7
View File
@@ -15,6 +15,18 @@ from errno import EEXIST
from os import makedirs, path
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):
'''Creates a directory. equivalent to using mkdir -p on the command line'''
@@ -48,13 +60,13 @@ def getFlareCount(filesDict):
lc.plot()
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()
flattenedLc = lc.flatten()
flattenedLc.plot()
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()
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([], [], "x", color="red", label="Flare peaks")
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()
flattenedLc.plot()
@@ -76,7 +88,7 @@ def getFlareCount(filesDict):
plt.plot(p["FlarePeakTime"].value, p["FlarePeak"], "x", color="red")
plt.plot([], [], "x", color="red", label="Flare peaks")
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()
pdcsapValSec, pdcsapTds = getTotalValidDataInSeconds(lc, "pdcsap_flux")
@@ -86,7 +98,7 @@ def getFlareCount(filesDict):
pdcsapPeriodogram.plot(view="period")
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()
#pdcsapEpochTime = getEpochTime(lc)
@@ -108,7 +120,7 @@ def getFlareCount(filesDict):
optimizedFit["foldedLC"].flux[optimizedFit["foldedLC"].cycle == cycle][foldedIndex], "x", color="red")
plt.plot([], [], "x", color="red", label="Flare peaks")
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()
if(optimizedFit["periodFoldedLC"] is not None):
@@ -123,7 +135,7 @@ def getFlareCount(filesDict):
optimizedFit["periodFoldedLC"].flux[optimizedFit["periodFoldedLC"].cycle == cycle][foldedIndex], "x", color="red")
plt.plot([], [], "x", color="red", label="Flare peaks")
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()
filesDict["pdcsapPeaks"] = pdcsapPeaks
@@ -150,6 +162,8 @@ def getFlareCount(filesDict):
filesDict["pdcsapPeriodFoldedPeaksPhasePair"] = pdcsapPeriodFoldedPeaksPhasePair
filesDict['periodFitType'] = optimizedFit["periodFitType"]
filesDict["isValidFold"] = optimizedFit["isValid"]
csvFile = open(f"{starFolder}/{starNameR}_{source}-{sequence}.csv", "a")
csvFile.write("StarName,Spectral Type,Rotational Velocity,Rotenional Velocity Unit,Distance,Distance Unit,Source,Sequence,File Path,Initial folded Fit Type,Used folded Fit Type")
csvFile.write(f"{filesDict['StarName']},{filesDict['SpType']},{filesDict['RotVel']},{filesDict['RotVelUnit']},{filesDict['Distance']},{filesDict['DistanceUnit']},{filesDict['Source']},{filesDict['Sequence']},{filesDict['FilePath']},{filesDict['FitType']},{optimizedFit['fitType']}")
+66 -164
View File
@@ -120,7 +120,7 @@ class FlareSummaryPlotGUI(QWidget):
self.cbSpTypeUnknown.setChecked(False)
self.cbShowSAP = QCheckBox("SAP")
self.cbShowSAP.setChecked(True)
self.cbShowSAP.setChecked(False)
self.cbShowPDCSAP = QCheckBox("PDCSAP")
self.cbShowPDCSAP.setChecked(True)
@@ -129,12 +129,12 @@ class FlareSummaryPlotGUI(QWidget):
self.buttonGridLayout.addWidget(self.btShowFlaresPerStar, 0, 2)
self.buttonGridLayout.addWidget(self.btShowFlaresPerStarNormalized, 0, 3)
self.buttonGridLayout.addWidget(self.btShowPeriods, 0, 4)
self.buttonGridLayout.addWidget(self.btNumMinimaMaxima, 0, 5)
self.buttonGridLayout.addWidget(self.btNumMinimaMaximaNorm, 0, 6)
self.buttonGridLayout.addWidget(self.btShowFlaresInMinimaMaxima, 0, 7)
self.buttonGridLayout.addWidget(self.btShowFlaresInMinimaMaximaPerMinimaMaxima, 0, 8)
self.buttonGridLayout.addWidget(self.btShowFlaresBinnedOnPhase, 0, 9)
self.buttonGridLayout.addWidget(self.textNumBins, 0, 10)
#self.buttonGridLayout.addWidget(self.btNumMinimaMaxima, 0, 5)
#self.buttonGridLayout.addWidget(self.btNumMinimaMaximaNorm, 0, 6)
#self.buttonGridLayout.addWidget(self.btShowFlaresInMinimaMaxima, 0, 7)
#self.buttonGridLayout.addWidget(self.btShowFlaresInMinimaMaximaPerMinimaMaxima, 0, 8)
#self.buttonGridLayout.addWidget(self.btShowFlaresBinnedOnPhase, 0, 9)
#self.buttonGridLayout.addWidget(self.textNumBins, 0, 10)
self.buttonGridLayout.addWidget(QLabel("Sources: "), 1, 0)
self.buttonGridLayout.addWidget(self.cbKepler, 1, 1)
@@ -149,7 +149,7 @@ class FlareSummaryPlotGUI(QWidget):
self.buttonGridLayout.addWidget(self.cbSpTypeF, 2, 4)
#self.buttonGridLayout.addWidget(self.cbSpTypeUnknown, 2, 6)
self.buttonGridLayout.addWidget(self.cbShowSAP, 3, 0)
#self.buttonGridLayout.addWidget(self.cbShowSAP, 3, 0)
self.buttonGridLayout.addWidget(self.cbShowPDCSAP, 3, 1)
self.mainLayout.addLayout(self.buttonGridLayout)
@@ -243,27 +243,7 @@ class FlareSummaryPlotGUI(QWidget):
self.figure.canvas.draw_idle()
def btShowFlaresPerStarClicked(self):
data = self.starFLareDictList.drop(columns=['Distance',
'DistanceUnit',
'FilePath',
'RotVel',
'RotVelUnit',
'Sequence',
'pdcsapFits',
'pdcsapPeaks',
'sapFits',
'sapPeaks',
'sapPeriod',
'sapPeriodMinima',
'sapPeriodMinimaBoundaries',
'sapPeriodMaxima',
'sapPeriodMaximaBoundaries',
'pdcsapValidTimespans',
'pdcsapPeriod',
'pdcsapPeriodMinima',
'pdcsapPeriodMinimaBoundaries',
'pdcsapPeriodMaxima',
'pdcsapPeriodMaximaBoundaries'])
data = self.starFLareDictList
showSourceFilter = np.full(len(data), False)
@@ -277,9 +257,14 @@ class FlareSummaryPlotGUI(QWidget):
showTESS = data["Source"] == "TESS"
showSourceFilter |= showTESS
aggDic = {}
if(self.cbShowSAP.isChecked()):
aggDic["sapPeaksCount"] = "sum"
if(self.cbShowPDCSAP.isChecked()):
aggDic["pdcsapPeaksCount"] = "sum"
data = data[showSourceFilter].groupby(["StarName", "SpType"],
as_index=False).agg({"sapPeaksCount": "sum",
"pdcsapPeaksCount": "sum"})
as_index=False).agg(aggDic)
x = np.arange(start=1, stop=len(data)+1, step=1, dtype=int)
if(self.cbSpTypeL.isChecked()):
@@ -345,28 +330,7 @@ class FlareSummaryPlotGUI(QWidget):
self.figure.canvas.draw_idle()
def btShowFlaresPerStarNormalizedClicked(self):
data = self.starFLareDictList.drop(columns=['Distance',
'DistanceUnit',
'FilePath',
'RotVel',
'RotVelUnit',
'Sequence',
'pdcsapFits',
'pdcsapPeaks',
'sapFits',
'sapValidTimespans',
'sapPeaks',
'sapPeriod',
'sapPeriodMinima',
'sapPeriodMinimaBoundaries',
'sapPeriodMaxima',
'sapPeriodMaximaBoundaries',
'pdcsapValidTimespans',
'pdcsapPeriod',
'pdcsapPeriodMinima',
'pdcsapPeriodMinimaBoundaries',
'pdcsapPeriodMaxima',
'pdcsapPeriodMaximaBoundaries'])
data = self.starFLareDictList
showSourceFilter = np.full(len(data), False)
@@ -380,11 +344,16 @@ class FlareSummaryPlotGUI(QWidget):
showTESS = data["Source"] == "TESS"
showSourceFilter |= showTESS
aggDic = {}
if(self.cbShowSAP.isChecked()):
aggDic["sapPeaksCount"] = "sum"
aggDic["sapValidSeconds"] = "sum"
if(self.cbShowPDCSAP.isChecked()):
aggDic["pdcsapPeaksCount"] = "sum"
aggDic["pdcsapValidSeconds"] = "sum"
data = data[showSourceFilter].groupby(["StarName", "SpType"],
as_index=False).agg({"sapPeaksCount": "sum",
"pdcsapPeaksCount": "sum",
"sapValidSeconds": "sum",
"pdcsapValidSeconds": "sum"})
as_index=False).agg(aggDic)
x = np.arange(start=1, stop=len(data)+1, step=1, dtype=int)
if(self.cbSpTypeL.isChecked()):
@@ -462,30 +431,7 @@ class FlareSummaryPlotGUI(QWidget):
self.figure.canvas.draw_idle()
def btShowPeriodsClicked(self):
data = self.starFLareDictList.drop(columns=['Distance',
'DistanceUnit',
'FilePath',
'RotVel',
'RotVelUnit',
'Sequence',
'pdcsapFits',
'pdcsapPeaks',
'sapFits',
'sapValidTimespans',
'sapPeaks',
'sapPeriodMinima',
'sapPeriodMinimaBoundaries',
'sapPeriodMaxima',
'sapPeriodMaximaBoundaries',
'pdcsapValidTimespans',
'pdcsapPeriodMinima',
'pdcsapPeriodMinimaBoundaries',
'pdcsapPeriodMaxima',
'pdcsapPeriodMaximaBoundaries',
'sapPeaksCount',
'pdcsapPeaksCount',
'sapValidSeconds',
'pdcsapValidSeconds'])
data = self.starFLareDictList
showSourceFilter = np.full(len(data), False)
@@ -499,11 +445,14 @@ class FlareSummaryPlotGUI(QWidget):
showTESS = data["Source"] == "TESS"
showSourceFilter |= showTESS
print(data["sapPeriod"])
aggDic = {}
if(self.cbShowSAP.isChecked()):
aggDic["sapPeriod"] = "sum"
if(self.cbShowPDCSAP.isChecked()):
aggDic["pdcsapPeriod"] = "sum"
data = data[showSourceFilter].groupby(["StarName", "SpType"],
as_index=False).agg({"sapPeriod": "mean",
"pdcsapPeriod": "mean"})
as_index=False).agg(aggDic)
x = np.arange(start=1, stop=len(data)+1, step=1, dtype=int)
if(self.cbSpTypeL.isChecked()):
@@ -582,20 +531,7 @@ class FlareSummaryPlotGUI(QWidget):
pass
def btShowNumMinimaMaximaClicked(self):
data = self.starFLareDictList.drop(columns=['Distance',
'DistanceUnit',
'FilePath',
'RotVel',
'RotVelUnit',
'Sequence',
'pdcsapFits',
'sapFits',
'sapValidTimespans',
'pdcsapValidTimespans',
'sapPeaksCount',
'pdcsapPeaksCount',
'sapValidSeconds',
'pdcsapValidSeconds'])
data = self.starFLareDictList
showSourceFilter = np.full(len(data), False)
@@ -609,13 +545,15 @@ class FlareSummaryPlotGUI(QWidget):
showTESS = data["Source"] == "TESS"
showSourceFilter |= showTESS
print(data["sapPeriod"])
aggDic = {}
if(self.cbShowSAP.isChecked()):
aggDic["sapPeriodMinima"] = "sum"
aggDic["sapPeriodMaxima"] = "sum"
if(self.cbShowPDCSAP.isChecked()):
aggDic["pdcsapPeriodMinima"] = "sum"
aggDic["pdcsapPeriodMaxima"] = "sum"
data = data[showSourceFilter].groupby(["StarName", "SpType"],
as_index=False).agg({"sapPeriodMinima": sumArrayLengths,
"sapPeriodMaxima": sumArrayLengths,
"pdcsapPeriodMinima": sumArrayLengths,
"pdcsapPeriodMaxima": sumArrayLengths})
as_index=False).agg(aggDic)
x = np.arange(start=1, stop=len(data)+1, step=1, dtype=int)
if(self.cbSpTypeL.isChecked()):
@@ -718,20 +656,7 @@ class FlareSummaryPlotGUI(QWidget):
pass
def btShowNumMinimaMaximaNormalizedClicked(self):
data = self.starFLareDictList.drop(columns=['Distance',
'DistanceUnit',
'FilePath',
'RotVel',
'RotVelUnit',
'Sequence',
'pdcsapFits',
'sapFits',
'sapValidTimespans',
'pdcsapValidTimespans',
'sapPeaksCount',
'pdcsapPeaksCount',
'sapValidSeconds',
'pdcsapValidSeconds'])
data = self.starFLareDictList
showSourceFilter = np.full(len(data), False)
@@ -745,13 +670,15 @@ class FlareSummaryPlotGUI(QWidget):
showTESS = data["Source"] == "TESS"
showSourceFilter |= showTESS
print(data["sapPeriod"])
aggDic = {}
if(self.cbShowSAP.isChecked()):
aggDic["sapPeriodMinima"] = "sum"
aggDic["sapPeriodMaxima"] = "sum"
if(self.cbShowPDCSAP.isChecked()):
aggDic["pdcsapPeriodMinima"] = "sum"
aggDic["pdcsapPeriodMaxima"] = "sum"
data = data[showSourceFilter].groupby(["StarName", "SpType"],
as_index=False).agg({"sapPeriodMinima": sumArrayLengthsNorm,
"sapPeriodMaxima": sumArrayLengthsNorm,
"pdcsapPeriodMinima": sumArrayLengthsNorm,
"pdcsapPeriodMaxima": sumArrayLengthsNorm})
as_index=False).agg(aggDic)
x = np.arange(start=1, stop=len(data)+1, step=1, dtype=int)
if(self.cbSpTypeL.isChecked()):
@@ -854,20 +781,7 @@ class FlareSummaryPlotGUI(QWidget):
pass
def btShowFlaresInMinimaMaximaClicked(self):
data = self.starFLareDictList.drop(columns=['Distance',
'DistanceUnit',
'FilePath',
'RotVel',
'RotVelUnit',
'Sequence',
'pdcsapFits',
'sapFits',
'sapValidTimespans',
'pdcsapValidTimespans',
'sapPeaksCount',
'pdcsapPeaksCount',
'sapValidSeconds',
'pdcsapValidSeconds'])
data = self.starFLareDictList
showSourceFilter = np.full(len(data), False)
@@ -881,8 +795,6 @@ class FlareSummaryPlotGUI(QWidget):
showTESS = data["Source"] == "TESS"
showSourceFilter |= showTESS
print(data["sapPeriod"])
finalData = []
#data = data[showSourceFilter].groupby(["StarName", "SpType"],
# as_index=False).agg({"sapPeriod": "mean",
@@ -1011,20 +923,7 @@ class FlareSummaryPlotGUI(QWidget):
pass
def btShowFlaresInMinimaMaximaPerMinimaMaximaClicked(self):
data = self.starFLareDictList.drop(columns=['Distance',
'DistanceUnit',
'FilePath',
'RotVel',
'RotVelUnit',
'Sequence',
'pdcsapFits',
'sapFits',
'sapValidTimespans',
'pdcsapValidTimespans',
'sapPeaksCount',
'pdcsapPeaksCount',
'sapValidSeconds',
'pdcsapValidSeconds'])
data = self.starFLareDictList
showSourceFilter = np.full(len(data), False)
@@ -1038,8 +937,6 @@ class FlareSummaryPlotGUI(QWidget):
showTESS = data["Source"] == "TESS"
showSourceFilter |= showTESS
print(data["sapPeriod"])
finalData = []
for ind, row in data[showSourceFilter].reset_index().iterrows():
minimaCountSAP = getNumFlaresInBounds(row["sapFoldedPeaksPhasePair"],
@@ -1056,15 +953,20 @@ class FlareSummaryPlotGUI(QWidget):
"minimaCountPDCSAP": minimaCountPDCSAP, "maximaCountPDCSAP": maximaCountPDCSAP,
"minimasPDCSAP": len(row["pdcsapPeriodMinima"]), "maximasPDCSAP": len(row["pdcsapPeriodMaxima"])})
aggDic = {}
if(self.cbShowSAP.isChecked()):
aggDic["minimaCountSAP"] = "sum"
aggDic["maximaCountSAP"] = "sum"
aggDic["minimasSAP"] = "sum"
aggDic["maximasSAP"] = "sum"
if(self.cbShowPDCSAP.isChecked()):
aggDic["minimaCountPDCSAP"] = "sum"
aggDic["maximaCountPDCSAP"] = "sum"
aggDic["minimasPDCSAP"] = "sum"
aggDic["maximasPDCSAP"] = "sum"
data = pd.DataFrame(finalData).groupby(["StarName", "SpType"],
as_index=False).agg({"minimaCountSAP": "sum",
"maximaCountSAP": "sum",
"minimasSAP": "sum",
"maximasSAP": "sum",
"minimaCountPDCSAP": "sum",
"maximaCountPDCSAP": "sum",
"minimasPDCSAP": "sum",
"maximasPDCSAP": "sum"})
as_index=False).agg(aggDic)
x = np.arange(start=1, stop=len(data)+1, step=1, dtype=int)
if(self.cbSpTypeL.isChecked()):
+3 -3
View File
@@ -265,7 +265,7 @@ class FlaredetectorWidget(QtWidgets.QWidget):
self.periodsCalculated.emit([optimizedFold["SpotModulation"]])
foldOptimizePhase = optimizedFold["phase"]
foldOptimizeFit = optimizedFold["fit"]
print(self.FoldState["SpotModulation"])
print("SpotModulation", self.FoldState["SpotModulation"])
self.epochCalculated.emit(optimizedFold["epoch"])
else:
lc = lc.fold(period=self.FoldState["Period"],
@@ -301,8 +301,8 @@ class FlaredetectorWidget(QtWidgets.QWidget):
phase, sineFit, _ = getFoldedBestFit(lc, fitType=self.foldedFitType)
self.figureAxis.plot(phase, sineFit, color="red")
print(phase, sineFit)
minPhasesBoundsIndices, maxPhasesBoundsIndices = getPhaseRangesNearPeak(getFoldedFitPeakValley(sineFit), phase)
plotPhaseRangesNearPeak((minPhasesBoundsIndices, maxPhasesBoundsIndices), phase, ax=self.figureAxis)
#minPhasesBoundsIndices, maxPhasesBoundsIndices = getPhaseRangesNearPeak(getFoldedFitPeakValley(sineFit), phase)
#plotPhaseRangesNearPeak((minPhasesBoundsIndices, maxPhasesBoundsIndices), phase, ax=self.figureAxis)
except Exception as e:
print("Failed to get fit")
print(e)
+18 -2
View File
@@ -429,7 +429,9 @@ def getOptimizedFold(normalizedLC, preferedFoldedFitType):
spotModulationBefore = spotModulation
if(len(fitMaximaArgs) > 1):
print("fitMaximaArgs > 1: ", fitMaximaArgs)
if(len(fitMaximaArgs) == 2 and fitMaximaArgs[0] > len(phase)*0.1 and fitMaximaArgs[1] < len(phase)*0.1):
print(fitMaximaArgs[0], len(phase)*0.1, fitMaximaArgs[1], len(phase)*0.9)
print(fitMaximaArgs[0] > len(phase)*0.1, fitMaximaArgs[1] < len(phase)*0.9)
if(len(fitMaximaArgs) == 2 and fitMaximaArgs[0] > len(phase)*0.1 and fitMaximaArgs[1] < len(phase)*0.9):
halfPeriod = period/2
for lsP, blsP in zip(lsPeriods, blsPeriods):
if(abs(lsP.value - halfPeriod) < period*0.05):
@@ -454,9 +456,23 @@ def getOptimizedFold(normalizedLC, preferedFoldedFitType):
fitMinimaArgs = argrelextrema(np.asarray(fit), np.less)[0]
fitMinima = phase[0]
fitMinimaArg = 0
newFitMinimaArgs = []
for args in fitMinimaArgs:
if(abs(phase[args]) < abs(fitMinima)):
print("Phases: ", fit[0], fit[len(phase)-1], fit[args])
if(fit[0] < fit[args] and fit[len(fit)-1] < fit[args]):
print("Found new minima")
newFitMinimaArgs.append(0)
newFitMinimaArgs.append(args)
newFitMinimaArgs = set(newFitMinimaArgs)
print(newFitMinimaArgs)
for args in newFitMinimaArgs:
if(abs(phase[args]) < abs(fitMinima) and fit[args] < fit[fitMinimaArg]):
fitMinima = phase[args]
fitMinimaArg = args
if(abs(fitMinima) < phaseLength*0.01):
isValid = True