astrodatagui: use new thread for count all flairs

This commit is contained in:
2024-05-14 22:32:41 +02:00
parent 2c11166640
commit 724ce3e13f
+31 -18
View File
@@ -9,6 +9,8 @@ import numpy as np
from .db.StarsDB import StarDB from .db.StarsDB import StarDB
from .ui.NewStarDialog import NewStarDialog from .ui.NewStarDialog import NewStarDialog
from .CalcAllFlaresThread import CalcAllFlaresThread
DEFAULT_DB = "stars.db" DEFAULT_DB = "stars.db"
class AstrodataGUI(QtWidgets.QMainWindow): class AstrodataGUI(QtWidgets.QMainWindow):
@@ -61,6 +63,8 @@ class AstrodataGUI(QtWidgets.QMainWindow):
self.loadDB() self.loadDB()
self.updateStarList() self.updateStarList()
self.calcAllFlaresThread = None
def setupCustomSimbadQueries(self): def setupCustomSimbadQueries(self):
self.simbad = Simbad() self.simbad = Simbad()
self.simbad.add_votable_fields("sptype") self.simbad.add_votable_fields("sptype")
@@ -344,22 +348,31 @@ class AstrodataGUI(QtWidgets.QMainWindow):
view = self.comboPlotPeriodogramView.currentText() view = self.comboPlotPeriodogramView.currentText()
self.flaredetectorPreview.setPeriodogramState(periodogramEnabled, method, view) self.flaredetectorPreview.setPeriodogramState(periodogramEnabled, method, view)
def btCountAllFlaresClicked(self): def btCountAllFlaresClickedDone(self, allFlaresDictList):
allStarsDictList = [] print(allFlaresDictList)
self.calcAllFlaresThread = None
for starName in self.starDB.getAllStars(): def btCountAllFlaresClicked(self):
sequences = self.starDB.getStarSequences(starName) if(self.calcAllFlaresThread is None):
infos = self.starDB.getStarInfos(starName) allStarsDictList = []
for sourceSeq in sequences:
source = sourceSeq["Source"] for starName in self.starDB.getAllStars():
seq = sourceSeq["Sequence"] sequences = self.starDB.getStarSequences(starName)
filePath = self.starDB.getFilePath(starName, source, seq) infos = self.starDB.getStarInfos(starName)
allStarsDictList.append({"StarName": starName, for sourceSeq in sequences:
"SpType": infos["SpType"], source = sourceSeq["Source"]
"RotVel": infos["RotVel"], seq = sourceSeq["Sequence"]
"RotVelUnit": infos["RotVelUnit"], filePath = self.starDB.getFilePath(starName, source, seq)
"Distance": infos["Distance"], allStarsDictList.append({"StarName": starName,
"DistanceUnit": infos["DistanceUnit"], "SpType": infos["SpType"],
"Source": source, "RotVel": infos["RotVel"],
"Sequence": seq, "RotVelUnit": infos["RotVelUnit"],
"FilePath": filePath}) "Distance": infos["Distance"],
"DistanceUnit": infos["DistanceUnit"],
"Source": source,
"Sequence": seq,
"FilePath": filePath})
self.calcAllFlaresThread = CalcAllFlaresThread(allStarsDictList)
self.calcAllFlaresThread.finished.connect(self.btCountAllFlaresClickedDone)
self.calcAllFlaresThread.start()