Add UI option to optimize the lightcurve fold
This commit is contained in:
@@ -39,6 +39,7 @@ class AstrodataGUI(QtWidgets.QMainWindow):
|
|||||||
self.cbPlotRemoveOutliersEnable.stateChanged.connect(self.plotOptionsCBChecked)
|
self.cbPlotRemoveOutliersEnable.stateChanged.connect(self.plotOptionsCBChecked)
|
||||||
self.cbPlotRemoveNansEnable.stateChanged.connect(self.plotOptionsCBChecked)
|
self.cbPlotRemoveNansEnable.stateChanged.connect(self.plotOptionsCBChecked)
|
||||||
self.cbPlotBinEnable.stateChanged.connect(self.plotOptionsCBChecked)
|
self.cbPlotBinEnable.stateChanged.connect(self.plotOptionsCBChecked)
|
||||||
|
self.cbPlotFoldOptimize.stateChanged.connect(self.plotOptionsCBChecked)
|
||||||
self.cbPlotFlattenPlotEnable.stateChanged.connect(self.plotOptionsExclusiveCBChecked)
|
self.cbPlotFlattenPlotEnable.stateChanged.connect(self.plotOptionsExclusiveCBChecked)
|
||||||
self.cbPlotFoldEnable.stateChanged.connect(self.plotOptionsExclusiveCBChecked)
|
self.cbPlotFoldEnable.stateChanged.connect(self.plotOptionsExclusiveCBChecked)
|
||||||
self.cbPlotPeriodogramEnable.stateChanged.connect(self.plotOptionsExclusiveCBChecked)
|
self.cbPlotPeriodogramEnable.stateChanged.connect(self.plotOptionsExclusiveCBChecked)
|
||||||
@@ -281,6 +282,9 @@ class AstrodataGUI(QtWidgets.QMainWindow):
|
|||||||
case self.cbPlotBinEnable:
|
case self.cbPlotBinEnable:
|
||||||
self.updateFlaredetectionWidgetBin()
|
self.updateFlaredetectionWidgetBin()
|
||||||
|
|
||||||
|
case self.cbPlotFoldOptimize:
|
||||||
|
self.updateFlaredetectionWidgetFold()
|
||||||
|
|
||||||
def plotOptionsExclusiveCBChecked(self, state):
|
def plotOptionsExclusiveCBChecked(self, state):
|
||||||
print(f"{self.sender().objectName()} is set to {state}")
|
print(f"{self.sender().objectName()} is set to {state}")
|
||||||
if(state == QtCore.Qt.Checked):
|
if(state == QtCore.Qt.Checked):
|
||||||
@@ -395,13 +399,14 @@ class AstrodataGUI(QtWidgets.QMainWindow):
|
|||||||
|
|
||||||
def updateFlaredetectionWidgetFold(self):
|
def updateFlaredetectionWidgetFold(self):
|
||||||
foldEnabled = self.cbPlotFoldEnable.isChecked()
|
foldEnabled = self.cbPlotFoldEnable.isChecked()
|
||||||
|
optimizeEnabled = self.cbPlotFoldOptimize.isChecked()
|
||||||
try:
|
try:
|
||||||
period = float(self.edPlotFoldPeriod.text())
|
period = float(self.edPlotFoldPeriod.text())
|
||||||
epoch = float(self.edPlotFoldEpochTime.text())
|
epoch = float(self.edPlotFoldEpochTime.text())
|
||||||
except:
|
except:
|
||||||
print(f"Invalid period/epoch detected, aborting")
|
print(f"Invalid period/epoch detected, aborting")
|
||||||
return
|
return
|
||||||
self.flaredetectorPreview.setFoldState(foldEnabled, period, epoch)
|
self.flaredetectorPreview.setFoldState(foldEnabled, period, epoch, optimizeEnabled)
|
||||||
|
|
||||||
def updateFlaredetectionWidgetPeriodogram(self):
|
def updateFlaredetectionWidgetPeriodogram(self):
|
||||||
periodogramEnabled = self.cbPlotPeriodogramEnable.isChecked()
|
periodogramEnabled = self.cbPlotPeriodogramEnable.isChecked()
|
||||||
|
|||||||
@@ -708,57 +708,7 @@
|
|||||||
<layout class="QGridLayout" name="gridLayout_3">
|
<layout class="QGridLayout" name="gridLayout_3">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
<item row="2" column="0">
|
<item row="2" column="1">
|
||||||
<widget class="QLabel" name="label_8">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>60</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>60</width>
|
|
||||||
<height>16777215</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Epoch Time: </string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QLabel" name="label_7">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>60</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>60</width>
|
|
||||||
<height>16777215</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Period: </string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1">
|
|
||||||
<widget class="QLineEdit" name="edPlotFoldPeriod">
|
<widget class="QLineEdit" name="edPlotFoldPeriod">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
@@ -783,7 +733,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="3" column="1">
|
||||||
<widget class="QLineEdit" name="edPlotFoldEpochTime">
|
<widget class="QLineEdit" name="edPlotFoldEpochTime">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
@@ -808,6 +758,56 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="label_7">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>60</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>60</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Period: </string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QLabel" name="label_8">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>60</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>60</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Epoch Time: </string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QCheckBox" name="cbPlotFoldEnable">
|
<widget class="QCheckBox" name="cbPlotFoldEnable">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -822,6 +822,20 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QCheckBox" name="cbPlotFoldOptimize">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label_26">
|
||||||
|
<property name="text">
|
||||||
|
<string>Optimize:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
|||||||
@@ -156,8 +156,9 @@ class FlaredetectorWidget(QtWidgets.QWidget):
|
|||||||
self.updateFit()
|
self.updateFit()
|
||||||
self.updatePlot()
|
self.updatePlot()
|
||||||
|
|
||||||
def setFoldState(self, enabled: bool, period: float, epoch: float):
|
def setFoldState(self, enabled: bool, period: float, epoch: float, optimize: bool):
|
||||||
self.FoldState["Enabled"] = enabled
|
self.FoldState["Enabled"] = enabled
|
||||||
|
self.FoldState["Optimize"] = optimize
|
||||||
if(period < 0):
|
if(period < 0):
|
||||||
print(f"Negative period detected, setting default 1")
|
print(f"Negative period detected, setting default 1")
|
||||||
period = 1
|
period = 1
|
||||||
@@ -246,6 +247,9 @@ class FlaredetectorWidget(QtWidgets.QWidget):
|
|||||||
lc = self.currentFlattenLC
|
lc = self.currentFlattenLC
|
||||||
label += " - flattened"
|
label += " - flattened"
|
||||||
if(self.FoldState["Enabled"]):
|
if(self.FoldState["Enabled"]):
|
||||||
|
if(self.FoldState["Optimize"]):
|
||||||
|
pass
|
||||||
|
else:
|
||||||
lc = lc.fold(period=self.FoldState["Period"],
|
lc = lc.fold(period=self.FoldState["Period"],
|
||||||
epoch_time=self.FoldState["EpochTime"])
|
epoch_time=self.FoldState["EpochTime"])
|
||||||
label += " - folded"
|
label += " - folded"
|
||||||
|
|||||||
@@ -391,3 +391,6 @@ def plotPhaseRangesNearPeak(indices, phase, ax=None):
|
|||||||
|
|
||||||
def getEpochTime(lc):
|
def getEpochTime(lc):
|
||||||
return lc.time.value[argrelextrema(np.asarray(lc.flux.value), np.less, order=500)[0]][0]
|
return lc.time.value[argrelextrema(np.asarray(lc.flux.value), np.less, order=500)[0]][0]
|
||||||
|
|
||||||
|
def getOptimizedFold(normalizedLC, period):
|
||||||
|
pass
|
||||||
|
|||||||
Reference in New Issue
Block a user