astrodatagui: support changing between frequency/period view in periodogram

This commit is contained in:
2024-03-19 13:52:54 +01:00
parent b722bc03bb
commit 60e4a4782e
3 changed files with 47 additions and 18 deletions
+4 -2
View File
@@ -36,6 +36,7 @@ class AstrodataGUI(QtWidgets.QMainWindow):
self.comboPlotFluxType.currentTextChanged.connect(self.plotOptionsComboBoxTextChanged)
self.comboPlotNormalizeUnit.currentTextChanged.connect(self.plotOptionsComboBoxTextChanged)
self.comboPlotPeriodogramMethod.currentTextChanged.connect(self.plotOptionsComboBoxTextChanged)
self.comboPlotPeriodogramView.currentTextChanged.connect(self.plotOptionsComboBoxTextChanged)
self.sbRemoveOutliersSigma.valueChanged.connect(self.plotOptionsSpinBoxValueChanged)
@@ -255,7 +256,7 @@ class AstrodataGUI(QtWidgets.QMainWindow):
case self.comboPlotNormalizeUnit:
self.updateFlaredetectionWidgetNormalize()
case self.comboPlotPeriodogramMethod:
case (self.comboPlotPeriodogramMethod | self.comboPlotPeriodogramView):
self.updateFlaredetectionWidgetPeriodogram()
def plotOptionsSpinBoxValueChanged(self):
@@ -328,4 +329,5 @@ class AstrodataGUI(QtWidgets.QMainWindow):
def updateFlaredetectionWidgetPeriodogram(self):
periodogramEnabled = self.cbPlotPeriodogramEnable.isChecked()
method = self.comboPlotPeriodogramMethod.currentText()
self.flaredetectorPreview.setPeriodogramState(periodogramEnabled, method)
view = self.comboPlotPeriodogramView.currentText()
self.flaredetectorPreview.setPeriodogramState(periodogramEnabled, method, view)
+35 -14
View File
@@ -826,20 +826,6 @@
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="cbPlotPeriodogramEnable">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_21">
<property name="text">
<string>Method: </string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="comboPlotPeriodogramMethod">
<item>
@@ -854,6 +840,41 @@
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_21">
<property name="text">
<string>Method: </string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="cbPlotPeriodogramEnable">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_23">
<property name="text">
<string>View: </string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="comboPlotPeriodogramView">
<item>
<property name="text">
<string>frequency</string>
</property>
</item>
<item>
<property name="text">
<string>period</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</item>
+8 -2
View File
@@ -37,7 +37,7 @@ class FlaredetectorWidget(QtWidgets.QWidget):
self.BinState = {"Enabled": False, "Size": None}
self.FlattenState = {"Enabled": False, "WindowLength": 101, "PolynomialOrder": 2}
self.FoldState = {"Enabled": False, "Period": 1, "EpochTime": 0}
self.PeriodogramState = {"Enabled": False, "Method": "lombscargle"}
self.PeriodogramState = {"Enabled": False, "Method": "lombscargle", "View": "frequency"}
def setFitsFile(self, fitsFilePath, mainName: str):
print(f"Plotting: {fitsFilePath}")
@@ -131,12 +131,16 @@ class FlaredetectorWidget(QtWidgets.QWidget):
self.PeriodogramState["Enabled"] = False
self.updatePlot()
def setPeriodogramState(self, enabled: bool, method: str):
def setPeriodogramState(self, enabled: bool, method: str, view: str):
self.PeriodogramState["Enabled"] = enabled
if(method not in ["lombscargle", "boxleastsquares", "ls", "bls"]):
print(f"Unsupported method detected, setting default lombscargle")
method = "lombscargle"
if(view not in ["frequency", "period"]):
print(f"Unsupported view detected, setting default frequency")
view = "frequency"
self.PeriodogramState["Method"] = method
self.PeriodogramState["View"] = view
if(self.PeriodogramState["Enabled"]):
self.FoldState["Enabled"] = False
self.FlattenState["Enabled"] = False
@@ -176,6 +180,8 @@ class FlaredetectorWidget(QtWidgets.QWidget):
self.figureAxis.clear()
if(self.FoldState["Enabled"]):
lc.scatter(label=label, ax=self.figureAxis)
elif(self.PeriodogramState["Enabled"]):
lc.plot(label=label, ax=self.figureAxis, view=self.PeriodogramState["View"])
else:
lc.plot(label=label, ax=self.figureAxis)
self.figure.canvas.draw_idle()