From 3d92dcb1bb70222c01ccbbcb775835a3ec7a2616 Mon Sep 17 00:00:00 2001 From: SGCMarkus Date: Mon, 2 Dec 2024 09:49:57 +0100 Subject: [PATCH] identify_unknown_sptypes: print UBV only match --- identify_unknown_sptypes.py | 38 ++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/identify_unknown_sptypes.py b/identify_unknown_sptypes.py index 190f453..3bcf244 100644 --- a/identify_unknown_sptypes.py +++ b/identify_unknown_sptypes.py @@ -44,26 +44,38 @@ for star in bvStars: 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] + matchingColumnsUBVIJHK = spTypeTable.columns.intersection(fluxDiffValColumns) + distancesUBV = spTypeTable[matchingColumnsUBVIJHK].sub(fluxDiff.iloc[0]).pow(2).sum(axis=1) + bestMatchIndexUBVIJHK = distancesUBV.idxmin() + bestMatchNameUBV = spTypeTable.iloc[bestMatchIndexUBVIJHK, 0] - distancesUBVweighted = ( - spTypeTable[matchingColumnsUBV] - .sub(fluxDiff.iloc[0][matchingColumnsUBV]) + distancesUBVIJHKweighted = ( + spTypeTable[matchingColumnsUBVIJHK] + .sub(fluxDiff.iloc[0][matchingColumnsUBVIJHK]) .pow(2) - .multiply([weights[col] for col in matchingColumnsUBV], axis=1) + .multiply([weights[col] for col in matchingColumnsUBVIJHK], axis=1) .sum(axis=1) ) - bestMatchIndexUBVweighted = distancesUBVweighted.idxmin() - bestMatchNameUBVweighted = spTypeTable.iloc[bestMatchIndexUBVweighted, 0] + bestMatchIndexUBVIJHKweighted = distancesUBVIJHKweighted.idxmin() + bestMatchNameUBVweighted = spTypeTable.iloc[bestMatchIndexUBVIJHKweighted, 0] - print(f"{star['MAIN_ID'].value[0]}: {bestMatchNameUBV}/{bestMatchNameUBVweighted} type star") + distancesUBVonlyWeighted = ( + spTypeTable[matchingColumnsUBVIJHK] + .sub(fluxDiff.iloc[0][matchingColumnsUBVIJHK]) + .pow(2) + .multiply([1.0 if(col == "U-B" or col == "B-V") else 0.0 for col in matchingColumnsUBVIJHK], axis=1) + .sum(axis=1) + ) + bestMatchIndexUBVonlyWeighted = distancesUBVonlyWeighted.idxmin() + bestMatchNameUBVonlyWeighted = spTypeTable.iloc[bestMatchIndexUBVonlyWeighted, 0] + + print(f"--- {star['MAIN_ID'].value[0]} ---") print("Table entry: ") - print(spTypeTable.iloc[bestMatchIndexUBV:bestMatchIndexUBV+1]) + print(spTypeTable.iloc[bestMatchIndexUBVIJHK:bestMatchIndexUBVIJHK+1]) print("Weighted Table entry:") - print(spTypeTable.iloc[bestMatchIndexUBVweighted:bestMatchIndexUBVweighted+1]) + print(spTypeTable.iloc[bestMatchIndexUBVIJHKweighted:bestMatchIndexUBVIJHKweighted+1]) + print("UBV Table entry:") + print(spTypeTable.iloc[bestMatchIndexUBVonlyWeighted:bestMatchIndexUBVonlyWeighted+1]) print("Star: ") print(fluxDiff) print("-------------------------------------------------------------------------------------") \ No newline at end of file