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()