astrodatagui: use new thread for count all flairs
This commit is contained in:
@@ -9,6 +9,8 @@ import numpy as np
|
||||
from .db.StarsDB import StarDB
|
||||
from .ui.NewStarDialog import NewStarDialog
|
||||
|
||||
from .CalcAllFlaresThread import CalcAllFlaresThread
|
||||
|
||||
DEFAULT_DB = "stars.db"
|
||||
|
||||
class AstrodataGUI(QtWidgets.QMainWindow):
|
||||
@@ -61,6 +63,8 @@ class AstrodataGUI(QtWidgets.QMainWindow):
|
||||
self.loadDB()
|
||||
self.updateStarList()
|
||||
|
||||
self.calcAllFlaresThread = None
|
||||
|
||||
def setupCustomSimbadQueries(self):
|
||||
self.simbad = Simbad()
|
||||
self.simbad.add_votable_fields("sptype")
|
||||
@@ -344,22 +348,31 @@ class AstrodataGUI(QtWidgets.QMainWindow):
|
||||
view = self.comboPlotPeriodogramView.currentText()
|
||||
self.flaredetectorPreview.setPeriodogramState(periodogramEnabled, method, view)
|
||||
|
||||
def btCountAllFlaresClicked(self):
|
||||
allStarsDictList = []
|
||||
def btCountAllFlaresClickedDone(self, allFlaresDictList):
|
||||
print(allFlaresDictList)
|
||||
self.calcAllFlaresThread = None
|
||||
|
||||
for starName in self.starDB.getAllStars():
|
||||
sequences = self.starDB.getStarSequences(starName)
|
||||
infos = self.starDB.getStarInfos(starName)
|
||||
for sourceSeq in sequences:
|
||||
source = sourceSeq["Source"]
|
||||
seq = sourceSeq["Sequence"]
|
||||
filePath = self.starDB.getFilePath(starName, source, seq)
|
||||
allStarsDictList.append({"StarName": starName,
|
||||
"SpType": infos["SpType"],
|
||||
"RotVel": infos["RotVel"],
|
||||
"RotVelUnit": infos["RotVelUnit"],
|
||||
"Distance": infos["Distance"],
|
||||
"DistanceUnit": infos["DistanceUnit"],
|
||||
"Source": source,
|
||||
"Sequence": seq,
|
||||
"FilePath": filePath})
|
||||
def btCountAllFlaresClicked(self):
|
||||
if(self.calcAllFlaresThread is None):
|
||||
allStarsDictList = []
|
||||
|
||||
for starName in self.starDB.getAllStars():
|
||||
sequences = self.starDB.getStarSequences(starName)
|
||||
infos = self.starDB.getStarInfos(starName)
|
||||
for sourceSeq in sequences:
|
||||
source = sourceSeq["Source"]
|
||||
seq = sourceSeq["Sequence"]
|
||||
filePath = self.starDB.getFilePath(starName, source, seq)
|
||||
allStarsDictList.append({"StarName": starName,
|
||||
"SpType": infos["SpType"],
|
||||
"RotVel": infos["RotVel"],
|
||||
"RotVelUnit": infos["RotVelUnit"],
|
||||
"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()
|
||||
Reference in New Issue
Block a user