astrodatagui: setup on click for the 2 lists and plot the data
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
from PyQt5 import QtWidgets, uic
|
||||
import os
|
||||
|
||||
from astroquery.simbad import Simbad
|
||||
|
||||
from .db.StarsDB import StarDB
|
||||
from .ui.NewStarDialog import NewStarDialog
|
||||
|
||||
@@ -16,14 +18,18 @@ class AstrodataGUI(QtWidgets.QMainWindow):
|
||||
self.actionExit.triggered.connect(self.actionExitTriggered)
|
||||
|
||||
self.btAddNew.clicked.connect(self.addNewClicked)
|
||||
self.listDownloaded.itemClicked.connect(self.starSelected)
|
||||
self.listSequences.itemClicked.connect(self.sequenceSelected)
|
||||
|
||||
self.show()
|
||||
|
||||
self.loadDB()
|
||||
|
||||
self.updateStarList()
|
||||
|
||||
def loadDB(self):
|
||||
try:
|
||||
self.starDB = StarDB.getInstance(DEFAULT_DB)
|
||||
self.starDB: StarDB = StarDB.getInstance(DEFAULT_DB)
|
||||
except Exception as e:
|
||||
self.showErrorMessage("DB Connection failed",
|
||||
f"Could not connect to local database file {DEFAULT_DB}\n\
|
||||
@@ -49,4 +55,44 @@ class AstrodataGUI(QtWidgets.QMainWindow):
|
||||
|
||||
def addNewClicked(self):
|
||||
diag = NewStarDialog()
|
||||
diag.exec()
|
||||
if not diag.exec():
|
||||
return
|
||||
|
||||
try:
|
||||
mainName = Simbad.query_object(diag.starIdentifier)["MAIN_ID"][0]
|
||||
except:
|
||||
self.showErrorMessage("Main Identifier Error", "Failed to grab main identifier, aborting...")
|
||||
return
|
||||
|
||||
try:
|
||||
altNames = Simbad.query_objectids(mainName)
|
||||
except:
|
||||
self.showErrorMessage("Identifier Error", "Failed to grab all identifiers, aborting...")
|
||||
return
|
||||
|
||||
self.starDB.insertStar(mainName, altNames, diag.productManifest)
|
||||
|
||||
self.updateStarList()
|
||||
|
||||
def updateStarList(self):
|
||||
self.listDownloaded.clear()
|
||||
|
||||
for star in self.starDB.getAllStars():
|
||||
self.listDownloaded.addItem(star[0])
|
||||
|
||||
def updateSequenceList(self, sourceSeqTouple):
|
||||
self.listSequences.clear()
|
||||
for sT in sourceSeqTouple:
|
||||
self.listSequences.addItem(f"{sT[0]} - {sT[1]}")
|
||||
|
||||
def starSelected(self, item):
|
||||
seqs = self.starDB.getStarData(item.text())
|
||||
self.updateSequenceList(seqs)
|
||||
|
||||
def sequenceSelected(self, item):
|
||||
seqText = item.text().split(" - ")
|
||||
mainName = self.listDownloaded.currentItem().text()
|
||||
source = seqText[0]
|
||||
seq = seqText[1]
|
||||
filePath = self.starDB.getFilePath(mainName, source, seq)
|
||||
self.flaredetectorPreview.plotFitsFile(filePath)
|
||||
Reference in New Issue
Block a user