identify_unknown_sptypes: use vizier tic catalogue and print best match

This commit is contained in:
2024-12-04 11:54:06 +01:00
parent db3c8be556
commit bef934176d
+100 -12
View File
@@ -1,5 +1,10 @@
from astroquery.simbad import Simbad from astroquery.simbad import Simbad
from astroquery.vizier import Vizier
from astropy.coordinates import Angle
import pandas as pd import pandas as pd
import numpy as np
from main.astrodatagui.db.StarsDB import StarDB
class bcolors: class bcolors:
HEADER = '\033[95m' HEADER = '\033[95m'
@@ -13,6 +18,8 @@ class bcolors:
simbad = Simbad() simbad = Simbad()
starDB: StarDB = StarDB.getInstance("stars.db")
bvStars = ["1RXS J064643.6-770027", "BD-08 995", "CPD-19 878", "PM J07058-5848", "TYC 1360-957-1", "TYC 4595-107-1"] bvStars = ["1RXS J064643.6-770027", "BD-08 995", "CPD-19 878", "PM J07058-5848", "TYC 1360-957-1", "TYC 4595-107-1"]
jhcStars = ["2MASS J18524052+4156057", "2MASS J18534407+4208274", "2MASS J18535462+4135227", "2MASS J19335656+4010546"] jhcStars = ["2MASS J18524052+4156057", "2MASS J18534407+4208274", "2MASS J18535462+4135227", "2MASS J19335656+4010546"]
@@ -20,6 +27,9 @@ filters = ["U", "B", "V", "R", "I", "J", "H", "K", "u", "g", "r", "i", "z", "G",
for f in filters: for f in filters:
simbad.add_votable_fields(f"flux({f})") simbad.add_votable_fields(f"flux({f})")
vizierTIC = Vizier(catalog="IV/38/tic",
columns=["TIC", "HIP", "TYC", "UCAC4", "2MASS", "GAIA", "KIC", "S/G", "Teff", "Rad", "Mass", "LClass", "Dist"])
spTypeTable = pd.read_csv("cousins.cols") spTypeTable = pd.read_csv("cousins.cols")
weights = {"SpType": 0.0, weights = {"SpType": 0.0,
@@ -34,7 +44,45 @@ weights = {"SpType": 0.0,
"V-M": 0.0, "V-M": 0.0,
"V-N": 0.0} "V-N": 0.0}
for star in bvStars: spTypeTeffMinTable = {2700: "M",
4000: "K",
5440: "G",
6300: "F",
7920: "A"}
def getSpTypeFromTeff(Teff):
if(Teff >= 30000):
return "O"
elif(Teff >= 10000):
return "B"
elif(Teff >= 7500):
return "A"
elif(Teff >= 6000):
return "F"
elif(Teff >= 5200):
return "G"
elif(Teff >= 3700):
return "K"
elif(Teff >= 2400):
return "M"
else:
return "L"
resTable = {"StarID": [],
"simbad B-V": [],
"simbad SpType": [],
"vizier Teff": [],
"vizier Mass": [],
"vizier Radius": [],
"vizier SpType": [],
"vizier Lum. Class": [],
"Final SpType": []}
resTable = pd.DataFrame(resTable)
allStars = []
allStars.extend(bvStars)
allStars.extend(jhcStars)
for star in allStars:
star = simbad.query_object(star) star = simbad.query_object(star)
U_B = star["FLUX_U"] - star["FLUX_B"] U_B = star["FLUX_U"] - star["FLUX_B"]
B_V = star["FLUX_B"] - star["FLUX_V"] B_V = star["FLUX_B"] - star["FLUX_V"]
@@ -77,15 +125,55 @@ for star in bvStars:
.sum(axis=1) .sum(axis=1)
) )
bestMatchIndexUBVonlyWeighted = distancesUBVonlyWeighted.idxmin() bestMatchIndexUBVonlyWeighted = distancesUBVonlyWeighted.idxmin()
bestMatchNameUBVonlyWeighted = spTypeTable.iloc[bestMatchIndexUBVonlyWeighted, 0] bestMatchNameUBVonlyWeighted = spTypeTable.iloc[bestMatchIndexUBVonlyWeighted, 0] if (not np.isnan(U_B) or not np.isnan(B_V)) else ""
print(f"--- {bcolors.BOLD}{bcolors.OKGREEN}{star['MAIN_ID'].value[0]}{bcolors.ENDC} ---") starName = star['MAIN_ID'].value[0]
print(f"Best no weights match: {bcolors.FAIL}{bestMatchNameUBV}{bcolors.ENDC}") regionResults = vizierTIC.query_region(starName,
print(spTypeTable.iloc[bestMatchIndexUBVIJHK:bestMatchIndexUBVIJHK+1]) radius=Angle(5, "arcsec"))
print(f"Best weights match: {bcolors.FAIL}{bestMatchNameUBVweighted}{bcolors.ENDC}") altNames = [an[0] for an in starDB.getStarAltNames(starName)[:-1]]
print(spTypeTable.iloc[bestMatchIndexUBVIJHKweighted:bestMatchIndexUBVIJHKweighted+1]) vizierTable = None
print(f"Best UBV match: {bcolors.FAIL}{bestMatchNameUBVonlyWeighted}{bcolors.ENDC}") for reg in regionResults:
print(spTypeTable.iloc[bestMatchIndexUBVonlyWeighted:bestMatchIndexUBVonlyWeighted+1]) for row in reg:
print(f"Star: ") for aN in altNames:
print(fluxDiff) if((str(row["TIC"]) in aN or
print("-------------------------------------------------------------------------------------") str(row["GAIA"]) in aN or
str(row["_2MASS"]) in aN) and
row["LClass"] == "DWARF"):
vizierTable = row
break
else:
continue
break
else:
continue
break
Teff = vizierTable["Teff"]
vizierSpType = getSpTypeFromTeff(Teff)
finalSpType = ""
if(bestMatchNameUBVonlyWeighted == "" or
bestMatchNameUBVonlyWeighted[0] == vizierSpType):
finalSpType = vizierSpType
else:
if(bestMatchNameUBVonlyWeighted[1] == "0"):
finalSpType = vizierSpType
else:
finalSpType = bestMatchNameUBVonlyWeighted[0]
if(vizierTable is None):
resTable = pd.concat([resTable,
pd.DataFrame([[starName, B_V[0], bestMatchNameUBVonlyWeighted,
"", "", "", "", "",
finalSpType]],
columns=resTable.columns)],
ignore_index=True)
else:
resTable = pd.concat([resTable,
pd.DataFrame([[starName, B_V[0], bestMatchNameUBVonlyWeighted,
vizierTable["Teff"], vizierTable["Mass"], vizierTable["Rad"], vizierSpType, vizierTable["LClass"],
finalSpType]],
columns=resTable.columns)],
ignore_index=True)
print(resTable.to_string())