add file to estimate spectral type by B-V
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
from astroquery.simbad import Simbad
|
||||
import pandas as pd
|
||||
|
||||
simbad = Simbad()
|
||||
|
||||
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"]
|
||||
|
||||
filters = ["U", "B", "V", "R", "I", "J", "H", "K", "u", "g", "r", "i", "z", "G", "F150W", "F200W", "F444W"]
|
||||
for f in filters:
|
||||
simbad.add_votable_fields(f"flux({f})")
|
||||
|
||||
spTypeTable = pd.read_csv("cousins.cols")
|
||||
|
||||
weights = {"SpType": 0.0,
|
||||
"U-B": 2.0,
|
||||
"B-V": 2.0,
|
||||
"V-R": 0.8,
|
||||
"V-I": 0.7,
|
||||
"V-J": 0.6,
|
||||
"V-H": 0.5,
|
||||
"V-K": 0.4,
|
||||
"V-L": 0.0,
|
||||
"V-M": 0.0,
|
||||
"V-N": 0.0}
|
||||
|
||||
for star in bvStars:
|
||||
star = simbad.query_object(star)
|
||||
U_B = star["FLUX_U"] - star["FLUX_B"]
|
||||
B_V = star["FLUX_B"] - star["FLUX_V"]
|
||||
V_R = star["FLUX_V"] - star["FLUX_R"]
|
||||
V_I = star["FLUX_V"] - star["FLUX_I"]
|
||||
V_J = star["FLUX_V"] - star["FLUX_J"]
|
||||
V_H = star["FLUX_V"] - star["FLUX_H"]
|
||||
V_K = star["FLUX_V"] - star["FLUX_K"]
|
||||
|
||||
fluxDiff = {"U-B": U_B,
|
||||
"B-V": B_V,
|
||||
"V-R": V_R,
|
||||
"V-I": V_I,
|
||||
"V-J": V_J,
|
||||
"V-H": V_H,
|
||||
"V-K": V_K}
|
||||
fluxDiff = pd.DataFrame(fluxDiff)
|
||||
fluxDiffValColumns = fluxDiff.columns[fluxDiff.notna().iloc[0]]
|
||||
|
||||
matchingColumnsUBV = spTypeTable.columns.intersection(fluxDiffValColumns)
|
||||
distancesUBV = spTypeTable[matchingColumnsUBV].sub(fluxDiff.iloc[0]).pow(2).sum(axis=1)
|
||||
bestMatchIndexUBV = distancesUBV.idxmin()
|
||||
bestMatchNameUBV = spTypeTable.iloc[bestMatchIndexUBV, 0]
|
||||
|
||||
distancesUBVweighted = (
|
||||
spTypeTable[matchingColumnsUBV]
|
||||
.sub(fluxDiff.iloc[0][matchingColumnsUBV])
|
||||
.pow(2)
|
||||
.multiply([weights[col] for col in matchingColumnsUBV], axis=1)
|
||||
.sum(axis=1)
|
||||
)
|
||||
bestMatchIndexUBVweighted = distancesUBVweighted.idxmin()
|
||||
bestMatchNameUBVweighted = spTypeTable.iloc[bestMatchIndexUBVweighted, 0]
|
||||
|
||||
print(f"{star['MAIN_ID'].value[0]}: {bestMatchNameUBV}/{bestMatchNameUBVweighted} type star")
|
||||
print("Table entry: ")
|
||||
print(spTypeTable.iloc[bestMatchIndexUBV:bestMatchIndexUBV+1])
|
||||
print("Weighted Table entry:")
|
||||
print(spTypeTable.iloc[bestMatchIndexUBVweighted:bestMatchIndexUBVweighted+1])
|
||||
print("Star: ")
|
||||
print(fluxDiff)
|
||||
print("-------------------------------------------------------------------------------------")
|
||||
Reference in New Issue
Block a user