generate_latex_table: update printed tables
This commit is contained in:
+62
-9
@@ -1,9 +1,19 @@
|
|||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
import numpy as np
|
||||||
from main.astrodatagui.db.StarsDB import StarDB
|
from main.astrodatagui.db.StarsDB import StarDB
|
||||||
|
|
||||||
db: StarDB = StarDB.getInstance("stars.db")
|
db: StarDB = StarDB.getInstance("stars.db")
|
||||||
starMainIDs = db.getAllStars()
|
starMainIDs = db.getAllStars()
|
||||||
res = []
|
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:
|
for mainID in starMainIDs:
|
||||||
altNames = db.getStarAltNames(mainID)
|
altNames = db.getStarAltNames(mainID)
|
||||||
infos = db.getStarInfos(mainID)
|
infos = db.getStarInfos(mainID)
|
||||||
@@ -16,16 +26,59 @@ for mainID in starMainIDs:
|
|||||||
if name[0].startswith("KIC"):
|
if name[0].startswith("KIC"):
|
||||||
kicName = name[0]
|
kicName = name[0]
|
||||||
spType = infos["SpType"]
|
spType = infos["SpType"]
|
||||||
res.append({"MainID": mainID,
|
|
||||||
"Spectral Type": spType,
|
|
||||||
"TIC": ticName,
|
|
||||||
"KIC": kicName})
|
|
||||||
|
|
||||||
resDF = pd.DataFrame(res)
|
hasValidSineFit = fullData[(fullData["StarName"] == mainID) & (fullData["FitType"] == "sine")]["isValidFold"].any()
|
||||||
resDF.sort_values(by=["Spectral Type", "MainID"]) #.to_latex(index=False)
|
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"]:
|
for sptype in ["M", "K", "G", "F"]:
|
||||||
texFile = open(f"table_{sptype}.tex", "w")
|
texFile = open(f"table_{sptype}_used.tex", "w")
|
||||||
tex = resDF[resDF["Spectral Type"].str.startswith(sptype)].sort_values(by=["Spectral Type", "MainID"]).to_latex(index=False)
|
tex = resUsed[resUsed["Spectral Type"].str.startswith(sptype)].sort_values(by=["Spectral Type", "MainID"]).to_latex(index=False)
|
||||||
texFile.write(tex)
|
texFile.write(tex)
|
||||||
texFile.close()
|
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()
|
||||||
Reference in New Issue
Block a user