diff --git a/generate_latex_table.py b/generate_latex_table.py index 919caed..8e035d3 100644 --- a/generate_latex_table.py +++ b/generate_latex_table.py @@ -1,9 +1,19 @@ import pandas as pd +import numpy as np from main.astrodatagui.db.StarsDB import StarDB db: StarDB = StarDB.getInstance("stars.db") 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: altNames = db.getStarAltNames(mainID) infos = db.getStarInfos(mainID) @@ -16,16 +26,59 @@ for mainID in starMainIDs: if name[0].startswith("KIC"): kicName = name[0] spType = infos["SpType"] - res.append({"MainID": mainID, - "Spectral Type": spType, - "TIC": ticName, - "KIC": kicName}) + + 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) -resDF = pd.DataFrame(res) -resDF.sort_values(by=["Spectral Type", "MainID"]) #.to_latex(index=False) + 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}.tex", "w") - tex = resDF[resDF["Spectral Type"].str.startswith(sptype)].sort_values(by=["Spectral Type", "MainID"]).to_latex(index=False) + 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() \ No newline at end of file + 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() \ No newline at end of file