astrodatagui: add custom results to simbad queries

This commit is contained in:
2024-03-08 13:51:47 +01:00
parent 04b3c6253e
commit bc520b031c
+37 -1
View File
@@ -21,12 +21,21 @@ class AstrodataGUI(QtWidgets.QMainWindow):
self.listDownloaded.itemClicked.connect(self.starSelected)
self.listSequences.itemClicked.connect(self.sequenceSelected)
self.setupCustomSimbadQueries()
self.show()
self.loadDB()
self.updateStarList()
def setupCustomSimbadQueries(self):
self.simbad = Simbad()
self.simbad.add_votable_fields("sptype")
self.simbad.add_votable_fields("velocity")
self.simbad.add_votable_fields("diameter")
self.simbad.add_votable_fields("distance")
def loadDB(self):
try:
self.starDB: StarDB = StarDB.getInstance(DEFAULT_DB)
@@ -57,9 +66,14 @@ class AstrodataGUI(QtWidgets.QMainWindow):
diag = NewStarDialog()
if not diag.exec():
return
try:
result = self.simbad.query_object(diag.starIdentifier)
except:
self.showErrorMessage("Simbad Error", "Failed to fetcch information from Simbad, aborting...")
return
try:
mainName = Simbad.query_object(diag.starIdentifier)["MAIN_ID"][0]
mainName = result["MAIN_ID"][0]
except:
self.showErrorMessage("Main Identifier Error", "Failed to grab main identifier, aborting...")
return
@@ -70,6 +84,28 @@ class AstrodataGUI(QtWidgets.QMainWindow):
self.showErrorMessage("Identifier Error", "Failed to grab all identifiers, aborting...")
return
try:
specType = result["SP_TYPE"][0]
except:
print("No spectral type found")
specType = "-"
rotVel = "-"
rotVelUnit = ""
try:
if(result["RVZ_TYPE"][0] == "v"):
rotVel = result["RV_VALUE"][0]
rotVelUnit = str(result["RV_VALUE"].unit)
except:
print("No radial velocity found")
try:
dist = result["Distance_distance"][0]
distUnit = result["Distance_unit"][0]
except:
dist = "-"
distUnit = ""
self.starDB.insertStar(mainName, altNames, diag.productManifest)
self.updateStarList()