From 7799836cf708612613220158ff489b572734e87c Mon Sep 17 00:00:00 2001 From: SGCMarkus Date: Wed, 13 Mar 2024 09:38:17 +0100 Subject: [PATCH] astrodatagui: implement features of all current plot options --- main/astrodatagui/AstrodataGUI.py | 37 ++++++++++++++++++++- main/astrodatagui/ui/FlaredetectorWidget.py | 33 ++++++++++++++++-- 2 files changed, 66 insertions(+), 4 deletions(-) diff --git a/main/astrodatagui/AstrodataGUI.py b/main/astrodatagui/AstrodataGUI.py index a9baf2a..64757b7 100644 --- a/main/astrodatagui/AstrodataGUI.py +++ b/main/astrodatagui/AstrodataGUI.py @@ -22,6 +22,12 @@ class AstrodataGUI(QtWidgets.QMainWindow): self.listDownloaded.itemClicked.connect(self.starSelected) self.listSequences.itemClicked.connect(self.sequenceSelected) + self.cbEnableFlattenPlot.stateChanged.connect(self.plotOptionsCBChecked) + self.cbEnableRemoveOutliers.stateChanged.connect(self.plotOptionsCBChecked) + self.cbEnableRemoveNans.stateChanged.connect(self.plotOptionsCBChecked) + self.cbEnableFold.stateChanged.connect(self.plotOptionsCBChecked) + self.cbEnableBin.stateChanged.connect(self.plotOptionsCBChecked) + self.setupCustomSimbadQueries() self.show() @@ -159,4 +165,33 @@ class AstrodataGUI(QtWidgets.QMainWindow): source = seqText[0] seq = seqText[1] filePath = self.starDB.getFilePath(mainName, source, seq) - self.flaredetectorPreview.plotFitsFile(filePath, mainName) \ No newline at end of file + self.flaredetectorPreview.plotFitsFile(filePath, mainName) + + def plotOptionsCBChecked(self, state): + flatten = self.cbEnableFlattenPlot.isChecked() + remOutliers = self.cbEnableRemoveOutliers.isChecked() + remNans = self.cbEnableRemoveNans.isChecked() + fold = self.cbEnableFold.isChecked() + binC = self.cbEnableBin.isChecked() + if(fold): + try: + period = float(self.edFoldPeriod.text()) + epoch = float(self.edFoldEpochTime.text()) + except: + fold = False + if(binC): + try: + binSize = float(self.edBinSize.text()) + except: + binC = False + foldList = [fold, 0, 0] + if(fold): + foldList[1] = period + foldList[2] = epoch + + binList = [binC, 0] + if(binC): + binList[1] = binSize + + self.flaredetectorPreview.updatePlot(flatten, remOutliers, + remNans, foldList, binList) \ No newline at end of file diff --git a/main/astrodatagui/ui/FlaredetectorWidget.py b/main/astrodatagui/ui/FlaredetectorWidget.py index 15dc5a0..301182f 100644 --- a/main/astrodatagui/ui/FlaredetectorWidget.py +++ b/main/astrodatagui/ui/FlaredetectorWidget.py @@ -23,8 +23,35 @@ class FlaredetectorWidget(QtWidgets.QWidget): def plotFitsFile(self, fitsFilePath, mainName: str): print(f"Plotting: {fitsFilePath}") self.figureAxis.clear() - lc = lk.read(fitsFilePath) - lc.flux = lc['sap_flux'] + self.currentLC = lk.read(fitsFilePath) + self.currentLC.flux = self.currentLC['sap_flux'] + self.currentMainName = mainName label = f"{mainName} - SAP Flux" - lc.plot(column="sap_flux", label=label, ax=self.figureAxis) + self.currentLC.plot(column="sap_flux", label=label, ax=self.figureAxis) + self.figure.canvas.draw_idle() + + def updatePlot(self, flatten: bool, remOutliers: bool, remNans: bool, fold: list, binList: list): + lc = self.currentLC + label = f"{self.currentMainName}" + if(flatten): + lc = lc.flatten() + label += " - flattened" + if(remOutliers): + lc = lc.remove_outliers() + label += " - no ol" + if(remNans): + lc = lc.remove_nans() + label += " - no nans" + if(len(fold) == 3 and fold[0]): + period = float(fold[1]) + epoch = float(fold[2]) + lc = lc.fold(period=period, epoch_time=epoch) + label += " - folded" + if(len(binList) == 2 and binList[0]): + binSize = float(binList[1]) + lc = lc.bin(time_bin_size=binSize) + label += " - binned" + + self.figureAxis.clear() + lc.plot(label=label, ax=self.figureAxis) self.figure.canvas.draw_idle() \ No newline at end of file