Compare commits

...

2 Commits

Author SHA1 Message Date
SGCMarkus 748589da17 fix period plot generation after rework 2025-05-21 19:44:23 +02:00
SGCMarkus a41edfcaa7 add latex table generation file 2025-05-21 17:59:23 +02:00
2 changed files with 35 additions and 4 deletions
+31
View File
@@ -0,0 +1,31 @@
import pandas as pd
from main.astrodatagui.db.StarsDB import StarDB
db: StarDB = StarDB.getInstance("stars.db")
starMainIDs = db.getAllStars()
res = []
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"]
res.append({"MainID": mainID,
"Spectral Type": spType,
"TIC": ticName,
"KIC": kicName})
resDF = pd.DataFrame(res)
resDF.sort_values(by=["Spectral Type", "MainID"]) #.to_latex(index=False)
for sptype in ["M", "K", "G", "F"]:
texFile = open(f"table_{sptype}.tex", "w")
tex = resDF[resDF["Spectral Type"].str.startswith(sptype)].sort_values(by=["Spectral Type", "MainID"]).to_latex(index=False)
texFile.write(tex)
texFile.close()
+4 -4
View File
@@ -86,6 +86,8 @@ def plotBinsHistogram(PDCSAPdataList, PDCSAPlabelList, PDCSAPcolorList, bins, ti
axHistoPhase.plot(fit[0], fit[1], color="blue") axHistoPhase.plot(fit[0], fit[1], color="blue")
fitCol = [fit[1] for fit in foldedFits] fitCol = [fit[1] for fit in foldedFits]
fitCol = np.array(list(itertools.chain.from_iterable(fitCol))) fitCol = np.array(list(itertools.chain.from_iterable(fitCol)))
if(len(fitCol) == 0):
fitCol = np.array([0, 1])
axHistoPhase.set_ylim(np.min(fitCol), np.max(fitCol)*1.2) axHistoPhase.set_ylim(np.min(fitCol), np.max(fitCol)*1.2)
plt.savefig(filename) plt.savefig(filename)
@@ -246,9 +248,7 @@ def plotStarPeriod(data, showSourceFilter, folderPath, starName):
nameFilter &= showSourceFilter nameFilter &= showSourceFilter
finalData = pd.concat([finalData, data[nameFilter]], ignore_index=True) finalData = pd.concat([finalData, data[nameFilter]], ignore_index=True)
pdcsapbinningData = []
pdcsapbinningDataSpotModDiffPeriod = [] pdcsapbinningDataSpotModDiffPeriod = []
foldedFits = []
foldedPeriodFits = [] foldedPeriodFits = []
locFolder = f"{folderPath}/stars/{starNameR}/" locFolder = f"{folderPath}/stars/{starNameR}/"
mkdir_p(f"{locFolder}/") mkdir_p(f"{locFolder}/")
@@ -265,12 +265,12 @@ def plotStarPeriod(data, showSourceFilter, folderPath, starName):
normPhase = normalizePhase(td.value, np.abs(PDCSAPminOrigPhase), np.abs(PDCSAPmaxOrigPhase)) 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']},{row['pdcsapSpotModulation']},{normPhase},{peak['FlarePeak']}") csvFile.write(f"{row['StarName']},{row['SpType']},{row['Source']},{row['FilePath']},{pv['FlarePeakTime']},{pv['FlarePeak']},{row['pdcsapPeriod']},{row['pdcsapSpotModulation']},{normPhase},{peak['FlarePeak']}")
csvFile.write("\n") csvFile.write("\n")
pdcsapbinningData.append({"SpType": f'{row["SpType"][0:2] if len(row["SpType"]) > 1 else row["SpType"][0]}', pdcsapbinningDataSpotModDiffPeriod.append({"SpType": f'{row["SpType"][0:2] if len(row["SpType"]) > 1 else row["SpType"][0]}',
"PDCSAPNormPhasePeriod": normPhase, "PDCSAPNormPhasePeriod": normPhase,
"PeakPeriod": peak["FlarePeak"]}) "PeakPeriod": peak["FlarePeak"]})
if(peak["FlarePeak"] > 100): if(peak["FlarePeak"] > 100):
print(row["StarName"], "has over 100 peak") print(row["StarName"], "has over 100 peak")
foldedFits.append([normalizePhase(row["pdcsapFoldedFitPhase"]), row["pdcsapFoldedFit"]]) foldedPeriodFits.append([normalizePhase(row["pdcsapFoldedFitPhase"]), row["pdcsapFoldedFit"]])
csvFile.close() csvFile.close()
pdcsapbinningDataSpotModDiffPeriod = pd.DataFrame(pdcsapbinningDataSpotModDiffPeriod) if len(pdcsapbinningDataSpotModDiffPeriod) > 0 else None pdcsapbinningDataSpotModDiffPeriod = pd.DataFrame(pdcsapbinningDataSpotModDiffPeriod) if len(pdcsapbinningDataSpotModDiffPeriod) > 0 else None