added autophase; fixes T217

This commit is contained in:
Dominik Demuth 2023-01-07 19:13:13 +01:00
parent 6533754e3a
commit f05d28f6e6
9 changed files with 237 additions and 172 deletions

View File

@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'resources/_ui/editsignalwidget.ui'
# Form implementation generated from reading ui file 'src/resources/_ui/editsignalwidget.ui'
#
# Created by: PyQt5 UI code generator 5.15.4
# Created by: PyQt5 UI code generator 5.15.2
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
@ -19,74 +19,91 @@ class Ui_Form(object):
self.verticalLayout.setContentsMargins(3, 3, 3, 3)
self.verticalLayout.setSpacing(3)
self.verticalLayout.setObjectName("verticalLayout")
self.groupBox_4 = QtWidgets.QGroupBox(Form)
self.groupBox_4.setObjectName("groupBox_4")
self.horizontalLayout_3 = QtWidgets.QHBoxLayout(self.groupBox_4)
self.baseline_box = QtWidgets.QGroupBox(Form)
self.baseline_box.setObjectName("baseline_box")
self.horizontalLayout_3 = QtWidgets.QHBoxLayout(self.baseline_box)
self.horizontalLayout_3.setContentsMargins(3, 3, 3, 3)
self.horizontalLayout_3.setObjectName("horizontalLayout_3")
self.baselinebutton = QtWidgets.QPushButton(self.groupBox_4)
self.baselinebutton = QtWidgets.QPushButton(self.baseline_box)
self.baselinebutton.setObjectName("baselinebutton")
self.horizontalLayout_3.addWidget(self.baselinebutton)
self.verticalLayout.addWidget(self.groupBox_4)
self.groupBox = QtWidgets.QGroupBox(Form)
self.groupBox.setObjectName("groupBox")
self.gridLayout_3 = QtWidgets.QGridLayout(self.groupBox)
self.verticalLayout.addWidget(self.baseline_box)
self.leftshift_box = QtWidgets.QGroupBox(Form)
self.leftshift_box.setObjectName("leftshift_box")
self.gridLayout_3 = QtWidgets.QGridLayout(self.leftshift_box)
self.gridLayout_3.setContentsMargins(3, 3, 3, 3)
self.gridLayout_3.setObjectName("gridLayout_3")
self.leftshiftbutton = QtWidgets.QPushButton(self.groupBox)
self.leftshiftbutton = QtWidgets.QPushButton(self.leftshift_box)
self.leftshiftbutton.setObjectName("leftshiftbutton")
self.gridLayout_3.addWidget(self.leftshiftbutton, 1, 0, 1, 2)
self.comboBox = QtWidgets.QComboBox(self.groupBox)
self.comboBox.setObjectName("comboBox")
self.comboBox.addItem("")
self.comboBox.addItem("")
self.gridLayout_3.addWidget(self.comboBox, 0, 0, 1, 1)
self.leftshift_comboBox = QtWidgets.QComboBox(self.leftshift_box)
self.leftshift_comboBox.setObjectName("leftshift_comboBox")
self.leftshift_comboBox.addItem("")
self.leftshift_comboBox.addItem("")
self.gridLayout_3.addWidget(self.leftshift_comboBox, 0, 0, 1, 1)
self.verticalLayout_2 = QtWidgets.QVBoxLayout()
self.verticalLayout_2.setContentsMargins(-1, 0, -1, -1)
self.verticalLayout_2.setSpacing(0)
self.verticalLayout_2.setObjectName("verticalLayout_2")
self.lsspinBox = QtWidgets.QSpinBox(self.groupBox)
self.lsspinBox.setMaximum(9999)
self.lsspinBox.setObjectName("lsspinBox")
self.verticalLayout_2.addWidget(self.lsspinBox)
self.lineEdit = QtWidgets.QLineEdit(self.groupBox)
self.lineEdit.setObjectName("lineEdit")
self.verticalLayout_2.addWidget(self.lineEdit)
self.ls_spinBox = QtWidgets.QSpinBox(self.leftshift_box)
self.ls_spinBox.setMaximum(9999)
self.ls_spinBox.setObjectName("ls_spinBox")
self.verticalLayout_2.addWidget(self.ls_spinBox)
self.ls_lineEdit = QtWidgets.QLineEdit(self.leftshift_box)
self.ls_lineEdit.setObjectName("ls_lineEdit")
self.verticalLayout_2.addWidget(self.ls_lineEdit)
self.gridLayout_3.addLayout(self.verticalLayout_2, 0, 1, 1, 1)
self.verticalLayout.addWidget(self.groupBox)
self.groupBox_6 = QtWidgets.QGroupBox(Form)
self.groupBox_6.setFlat(False)
self.groupBox_6.setObjectName("groupBox_6")
self.horizontalLayout_4 = QtWidgets.QHBoxLayout(self.groupBox_6)
self.verticalLayout.addWidget(self.leftshift_box)
self.zerofill_box = QtWidgets.QGroupBox(Form)
self.zerofill_box.setFlat(False)
self.zerofill_box.setObjectName("zerofill_box")
self.horizontalLayout_4 = QtWidgets.QHBoxLayout(self.zerofill_box)
self.horizontalLayout_4.setContentsMargins(3, 3, 3, 3)
self.horizontalLayout_4.setObjectName("horizontalLayout_4")
self.zfbutton = QtWidgets.QPushButton(self.groupBox_6)
self.zfbutton = QtWidgets.QPushButton(self.zerofill_box)
self.zfbutton.setObjectName("zfbutton")
self.horizontalLayout_4.addWidget(self.zfbutton)
self.verticalLayout.addWidget(self.groupBox_6)
self.groupBox_2 = QtWidgets.QGroupBox(Form)
self.groupBox_2.setFlat(False)
self.groupBox_2.setObjectName("groupBox_2")
self.gridLayout_4 = QtWidgets.QGridLayout(self.groupBox_2)
self.verticalLayout.addWidget(self.zerofill_box)
self.phase_box = QtWidgets.QGroupBox(Form)
self.phase_box.setFlat(False)
self.phase_box.setObjectName("phase_box")
self.gridLayout_4 = QtWidgets.QGridLayout(self.phase_box)
self.gridLayout_4.setContentsMargins(3, 3, 3, 3)
self.gridLayout_4.setVerticalSpacing(0)
self.gridLayout_4.setObjectName("gridLayout_4")
self.ph1slider = QtWidgets.QDoubleSpinBox(self.groupBox_2)
self.label_8 = QtWidgets.QLabel(self.phase_box)
self.label_8.setObjectName("label_8")
self.gridLayout_4.addWidget(self.label_8, 7, 0, 1, 1)
self.phase_prev_button = QtWidgets.QPushButton(self.phase_box)
self.phase_prev_button.setObjectName("phase_prev_button")
self.gridLayout_4.addWidget(self.phase_prev_button, 9, 0, 1, 1)
self.ph0slider = QtWidgets.QDoubleSpinBox(self.phase_box)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.ph0slider.sizePolicy().hasHeightForWidth())
self.ph0slider.setSizePolicy(sizePolicy)
self.ph0slider.setWrapping(True)
self.ph0slider.setMinimum(-180.0)
self.ph0slider.setMaximum(180.0)
self.ph0slider.setObjectName("ph0slider")
self.gridLayout_4.addWidget(self.ph0slider, 2, 1, 1, 1)
self.ph1slider = QtWidgets.QDoubleSpinBox(self.phase_box)
self.ph1slider.setWrapping(True)
self.ph1slider.setMinimum(-360.0)
self.ph1slider.setMaximum(360.0)
self.ph1slider.setWrapping(True)
self.ph1slider.setObjectName("ph1slider")
self.gridLayout_4.addWidget(self.ph1slider, 5, 1, 1, 1)
self.label_6 = QtWidgets.QLabel(self.groupBox_2)
self.phasebutton = QtWidgets.QPushButton(self.phase_box)
self.phasebutton.setObjectName("phasebutton")
self.gridLayout_4.addWidget(self.phasebutton, 9, 1, 1, 1)
self.label_6 = QtWidgets.QLabel(self.phase_box)
self.label_6.setObjectName("label_6")
self.gridLayout_4.addWidget(self.label_6, 4, 0, 3, 1)
self.pushButton_2 = QtWidgets.QPushButton(self.groupBox_2)
self.pushButton_2.setObjectName("pushButton_2")
self.gridLayout_4.addWidget(self.pushButton_2, 8, 0, 1, 1)
self.label = QtWidgets.QLabel(self.groupBox_2)
self.label = QtWidgets.QLabel(self.phase_box)
self.label.setObjectName("label")
self.gridLayout_4.addWidget(self.label, 1, 0, 3, 1)
self.pivot_lineedit = QtWidgets.QLineEdit(self.groupBox_2)
self.pivot_lineedit = QtWidgets.QLineEdit(self.phase_box)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
@ -95,91 +112,93 @@ class Ui_Form(object):
self.pivot_lineedit.setInputMethodHints(QtCore.Qt.ImhDigitsOnly)
self.pivot_lineedit.setObjectName("pivot_lineedit")
self.gridLayout_4.addWidget(self.pivot_lineedit, 7, 1, 1, 1)
self.ph0slider = QtWidgets.QDoubleSpinBox(self.groupBox_2)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.ph0slider.sizePolicy().hasHeightForWidth())
self.ph0slider.setSizePolicy(sizePolicy)
self.ph0slider.setMinimum(-180.0)
self.ph0slider.setMaximum(180.0)
self.ph0slider.setWrapping(True)
self.ph0slider.setObjectName("ph0slider")
self.gridLayout_4.addWidget(self.ph0slider, 2, 1, 1, 1)
self.label_8 = QtWidgets.QLabel(self.groupBox_2)
self.label_8.setObjectName("label_8")
self.gridLayout_4.addWidget(self.label_8, 7, 0, 1, 1)
self.phasebutton = QtWidgets.QPushButton(self.groupBox_2)
self.phasebutton.setObjectName("phasebutton")
self.gridLayout_4.addWidget(self.phasebutton, 8, 1, 1, 1)
self.verticalLayout.addWidget(self.groupBox_2)
self.groupBox_3 = QtWidgets.QGroupBox(Form)
self.autophase_check = QtWidgets.QCheckBox(self.phase_box)
self.autophase_check.setObjectName("autophase_check")
self.gridLayout_4.addWidget(self.autophase_check, 8, 0, 1, 2)
self.verticalLayout.addWidget(self.phase_box)
self.apod_box = QtWidgets.QGroupBox(Form)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.groupBox_3.sizePolicy().hasHeightForWidth())
self.groupBox_3.setSizePolicy(sizePolicy)
self.groupBox_3.setObjectName("groupBox_3")
self.verticalLayout_7 = QtWidgets.QVBoxLayout(self.groupBox_3)
sizePolicy.setHeightForWidth(self.apod_box.sizePolicy().hasHeightForWidth())
self.apod_box.setSizePolicy(sizePolicy)
self.apod_box.setObjectName("apod_box")
self.verticalLayout_7 = QtWidgets.QVBoxLayout(self.apod_box)
self.verticalLayout_7.setContentsMargins(3, 3, 3, 3)
self.verticalLayout_7.setObjectName("verticalLayout_7")
self.apodcombobox = QtWidgets.QComboBox(self.groupBox_3)
self.apodcombobox = QtWidgets.QComboBox(self.apod_box)
self.apodcombobox.setObjectName("apodcombobox")
self.verticalLayout_7.addWidget(self.apodcombobox)
self.label_2 = QtWidgets.QLabel(self.groupBox_3)
self.label_2.setIndent(3)
self.label_2.setObjectName("label_2")
self.verticalLayout_7.addWidget(self.label_2)
self.verticalLayout_8 = QtWidgets.QVBoxLayout()
self.verticalLayout_8.setSpacing(0)
self.verticalLayout_8.setObjectName("verticalLayout_8")
self.verticalLayout_7.addLayout(self.verticalLayout_8)
self.apod_name_label = QtWidgets.QLabel(self.apod_box)
self.apod_name_label.setIndent(3)
self.apod_name_label.setObjectName("apod_name_label")
self.verticalLayout_7.addWidget(self.apod_name_label)
self.apod_layout = QtWidgets.QVBoxLayout()
self.apod_layout.setSpacing(0)
self.apod_layout.setObjectName("apod_layout")
self.verticalLayout_7.addLayout(self.apod_layout)
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
self.pushButton = QtWidgets.QPushButton(self.groupBox_3)
self.pushButton.setObjectName("pushButton")
self.horizontalLayout.addWidget(self.pushButton)
self.apodbutton = QtWidgets.QPushButton(self.groupBox_3)
self.apod_prev_button = QtWidgets.QPushButton(self.apod_box)
self.apod_prev_button.setObjectName("apod_prev_button")
self.horizontalLayout.addWidget(self.apod_prev_button)
self.apodbutton = QtWidgets.QPushButton(self.apod_box)
self.apodbutton.setObjectName("apodbutton")
self.horizontalLayout.addWidget(self.apodbutton)
self.verticalLayout_7.addLayout(self.horizontalLayout)
self.verticalLayout.addWidget(self.groupBox_3)
self.groupBox_5 = QtWidgets.QGroupBox(Form)
self.groupBox_5.setObjectName("groupBox_5")
self.horizontalLayout_5 = QtWidgets.QHBoxLayout(self.groupBox_5)
self.verticalLayout.addWidget(self.apod_box)
self.fft_box = QtWidgets.QGroupBox(Form)
self.fft_box.setObjectName("fft_box")
self.horizontalLayout_5 = QtWidgets.QHBoxLayout(self.fft_box)
self.horizontalLayout_5.setContentsMargins(3, 3, 3, 3)
self.horizontalLayout_5.setObjectName("horizontalLayout_5")
self.fourierutton = QtWidgets.QPushButton(self.groupBox_5)
self.fourierutton = QtWidgets.QPushButton(self.fft_box)
self.fourierutton.setObjectName("fourierutton")
self.horizontalLayout_5.addWidget(self.fourierutton)
self.verticalLayout.addWidget(self.groupBox_5)
self.verticalLayout.addWidget(self.fft_box)
spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
self.verticalLayout.addItem(spacerItem)
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
Form.setTabOrder(self.baselinebutton, self.leftshift_comboBox)
Form.setTabOrder(self.leftshift_comboBox, self.ls_spinBox)
Form.setTabOrder(self.ls_spinBox, self.ls_lineEdit)
Form.setTabOrder(self.ls_lineEdit, self.leftshiftbutton)
Form.setTabOrder(self.leftshiftbutton, self.zfbutton)
Form.setTabOrder(self.zfbutton, self.ph0slider)
Form.setTabOrder(self.ph0slider, self.ph1slider)
Form.setTabOrder(self.ph1slider, self.pivot_lineedit)
Form.setTabOrder(self.pivot_lineedit, self.autophase_check)
Form.setTabOrder(self.autophase_check, self.phase_prev_button)
Form.setTabOrder(self.phase_prev_button, self.phasebutton)
Form.setTabOrder(self.phasebutton, self.apodcombobox)
Form.setTabOrder(self.apodcombobox, self.apod_prev_button)
Form.setTabOrder(self.apod_prev_button, self.apodbutton)
Form.setTabOrder(self.apodbutton, self.fourierutton)
def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "Form"))
self.groupBox_4.setTitle(_translate("Form", "Baseline correction"))
self.baseline_box.setTitle(_translate("Form", "Baseline correction"))
self.baselinebutton.setText(_translate("Form", "Apply"))
self.groupBox.setTitle(_translate("Form", "Left shift"))
self.leftshift_box.setTitle(_translate("Form", "Left shift"))
self.leftshiftbutton.setText(_translate("Form", "Apply"))
self.comboBox.setItemText(0, _translate("Form", "Points"))
self.comboBox.setItemText(1, _translate("Form", "Seconds"))
self.groupBox_6.setTitle(_translate("Form", "Zerofilling"))
self.leftshift_comboBox.setItemText(0, _translate("Form", "Points"))
self.leftshift_comboBox.setItemText(1, _translate("Form", "Seconds"))
self.zerofill_box.setTitle(_translate("Form", "Zerofilling"))
self.zfbutton.setText(_translate("Form", "Apply"))
self.groupBox_2.setTitle(_translate("Form", "Phase correction"))
self.phase_box.setTitle(_translate("Form", "Phase correction"))
self.label_8.setText(_translate("Form", "Pivot"))
self.phase_prev_button.setText(_translate("Form", "Preview"))
self.phasebutton.setText(_translate("Form", "Apply"))
self.label_6.setText(_translate("Form", "Phase 1"))
self.pushButton_2.setText(_translate("Form", "Preview"))
self.label.setText(_translate("Form", "Phase 0"))
self.pivot_lineedit.setText(_translate("Form", "0"))
self.label_8.setText(_translate("Form", "Pivot"))
self.phasebutton.setText(_translate("Form", "Apply"))
self.groupBox_3.setTitle(_translate("Form", "Apodization"))
self.label_2.setText(_translate("Form", "TextLabel"))
self.pushButton.setText(_translate("Form", "Preview"))
self.autophase_check.setText(_translate("Form", "Autophase at pivot point"))
self.apod_box.setTitle(_translate("Form", "Apodization"))
self.apod_name_label.setText(_translate("Form", "TextLabel"))
self.apod_prev_button.setText(_translate("Form", "Preview"))
self.apodbutton.setText(_translate("Form", "Apply"))
self.groupBox_5.setTitle(_translate("Form", "FFT"))
self.fft_box.setTitle(_translate("Form", "FFT"))
self.fourierutton.setText(_translate("Form", "Apply"))

View File

@ -656,7 +656,8 @@ class SignalContainer(ExperimentContainer):
def _update_actions(self):
super()._update_actions()
self.actions.update({'ph': self._data.manual_phase, 'bls': self._data.baseline_spline})
self.actions.update({'ph': self._data.manual_phase, 'bls': self._data.baseline_spline,
'autoph': self._data.autophase})
if isinstance(self._data, Spectrum):
self.actions.update({'bl': self._data.baseline, 'ls': self._data.shift,
'divide': self._data.divide, 'ft': self.fourier})

View File

@ -81,7 +81,7 @@ class DataTree(QtWidgets.QTreeWidget):
self.update_indexes()
@QtCore.pyqtSlot(QtWidgets.QTreeWidgetItem)
def data_change(self, item: QtWidgets.QTreeWidgetItem) -> Tuple[set, set]:
def data_change(self, item: QtWidgets.QTreeWidgetItem) -> tuple[set, set]:
idd = item.data(0, QtCore.Qt.UserRole)
is_selected = item.checkState(0) == QtCore.Qt.Checked
to_be_hidden = set()
@ -259,7 +259,7 @@ class DataTree(QtWidgets.QTreeWidget):
set_cnt = 0
item.setText(1, f'G[{graph_cnt}]')
else:
item.setText(1, f'G[{graph_cnt}].S[{set_cnt}]')
item.setText(1, f'.S[{set_cnt}]')
set_cnt += 1
iterator += 1

View File

@ -18,8 +18,8 @@ class EditSignalWidget(QtWidgets.QWidget, Ui_Form):
self.apodlist = find_models(apodization)
self.lineEdit.hide()
self.lineEdit.setValidator(QtGui.QDoubleValidator())
self.ls_lineEdit.hide()
self.ls_lineEdit.setValidator(QtGui.QDoubleValidator())
for ap in self.apodlist:
self.apodcombobox.addItem(str(ap().name))
@ -32,8 +32,8 @@ class EditSignalWidget(QtWidgets.QWidget, Ui_Form):
self.leftshiftbutton.clicked.connect(lambda: self.apply_changes('ls'))
self.fourierutton.clicked.connect(lambda: self.apply_changes('ft'))
self.pushButton.clicked.connect(lambda: self.preview_triggered.emit('ap'))
self.pushButton_2.clicked.connect(lambda: self.preview_triggered.emit('ph'))
self.apod_prev_button.clicked.connect(lambda: self.preview_triggered.emit('ap'))
self.phase_prev_button.clicked.connect(lambda: self.preview_triggered.emit('ph'))
@QtCore.pyqtSlot(str)
def apply_changes(self, sender):
@ -41,8 +41,8 @@ class EditSignalWidget(QtWidgets.QWidget, Ui_Form):
self.do_something.emit(sender, tuple())
elif sender == 'ls':
if self.comboBox.currentIndex() == 0:
_nop = int(self.lsspinBox.text())
if self.leftshift_comboBox.currentIndex() == 0:
_nop = int(self.ls_spinBox.text())
stype = 'pts'
else:
try:
@ -54,14 +54,17 @@ class EditSignalWidget(QtWidgets.QWidget, Ui_Form):
elif sender == 'ap':
apodmodel = self.apodlist[self.apodcombobox.currentIndex()]
p = [float(x.text()) for x in self.groupBox_3.findChildren(QtWidgets.QLineEdit)]
p = [float(x.text()) for x in self.apod_box.findChildren(QtWidgets.QLineEdit)]
self.do_something.emit(sender, (p, apodmodel))
elif sender == 'ph':
ph0 = float(self.ph0slider.value())
ph1 = float(self.ph1slider.value())
pvt = float(self.pivot_lineedit.text())
self.do_something.emit(sender, (ph0, ph1, pvt))
if self.autophase_check.isChecked():
self.do_something.emit('autoph', (pvt,))
else:
ph0 = float(self.ph0slider.value())
ph1 = float(self.ph1slider.value())
self.do_something.emit(sender, (ph0, ph1, pvt))
else:
print('You should never reach this by accident.')
@ -69,10 +72,10 @@ class EditSignalWidget(QtWidgets.QWidget, Ui_Form):
@QtCore.pyqtSlot(int, name='on_apodcombobox_currentIndexChanged')
def change_apodization(self, index):
apod_func = self.apodlist[index]
self.label_2.setText(convert(apod_func.equation))
self.apod_name_label.setText(convert(apod_func.equation))
while self.verticalLayout_8.count():
item = self.verticalLayout_8.takeAt(0)
while self.apod_layout.count():
item = self.apod_layout.takeAt(0)
try:
item.widget().deleteLater()
except AttributeError:
@ -80,13 +83,13 @@ class EditSignalWidget(QtWidgets.QWidget, Ui_Form):
for k, v in enumerate(apod_func.params):
widgt = FormWidget(name=v)
self.verticalLayout_8.addWidget(widgt)
self.apod_layout.addWidget(widgt)
@QtCore.pyqtSlot(int, name='on_comboBox_currentIndexChanged')
@QtCore.pyqtSlot(int, name='on_leftshift_comboBox_currentIndexChanged')
def change_ls(self, idx):
if idx:
self.lineEdit.show()
self.lsspinBox.hide()
self.ls_lineEdit.show()
self.ls_spinBox.hide()
else:
self.lineEdit.hide()
self.lsspinBox.show()
self.ls_lineEdit.hide()
self.ls_spinBox.show()

View File

@ -103,7 +103,7 @@ class QPhasedialog(QPreviewDialogs, Ui_SignalEdit):
return float(self.ph0slider.text()), float(self.ph1slider.text()), float(self.pivot_lineedit.text())
def move_line(self, evt):
self.pivot_lineedit.setText(str(int(evt.value())))
self.pivot_lineedit.setText(f'{evt.value():.5g}')
class QApodDialog(QPreviewDialogs, Ui_ApodEdit):

View File

@ -54,6 +54,21 @@ class PhaseCommand(QtWidgets.QUndoCommand):
self.__data.apply('ph', self.__phase)
class AutophaseCommand(QtWidgets.QUndoCommand):
def __init__(self, data, pvt: float):
super().__init__('Autophase')
self.__data = data
self.__data_data = copy.deepcopy(data.data)
self.__pvt = pvt
def undo(self):
self.__data.data = copy.deepcopy(self.__data_data)
def redo(self):
self.__data.apply('autoph', (self.__pvt,))
class ShiftCommand(QtWidgets.QUndoCommand):
def __init__(self, data, value, mode):
super().__init__('Fourier')

View File

@ -87,14 +87,15 @@ class UpperManagement(QtCore.QObject):
'cut': (CutCommand, 'Cut'),
'ap': (ApodizationCommand, 'Apodization'),
'zf': (ZerofillCommand, 'Zerofill'),
'ph': (PhaseCommand, 'Phase'),
'ph': (PhaseCommand, 'Phase correction'),
'autoph': (AutophaseCommand, 'Autophase'),
'bl': (BaselineCommand, 'Baseline'),
'bls': (BaselineSplineCommand, 'Baseline'),
'ft': (FourierCommand, 'Fourier'),
'ft_pake': 'FT (de-paked)',
'sort': (SortCommand, 'Sort'),
'norm': (NormCommand, 'Normalize'),
'center': (CenterCommand, 'Center on max')
'center': (CenterCommand, 'Center on max'),
}
def __init__(self, window):

View File

@ -55,8 +55,9 @@ class Signal(Points):
return self
def simple_phase(self, pos: int = 0, avg: int = 0):
ph = np.mean(np.angle(self._y)[pos-avg:pos+avg+1])
def autophase(self, pos: float = 0, avg: int = 0):
pos = np.argmin(np.abs(pos-self.x))
ph = np.mean(np.angle(self.y)[pos-avg:pos+avg+1])
self._y *= np.exp(-1j*ph)
self.meta['phase'].append((ph, 0, 0))

View File

@ -30,7 +30,7 @@
<number>3</number>
</property>
<item>
<widget class="QGroupBox" name="groupBox_4">
<widget class="QGroupBox" name="baseline_box">
<property name="title">
<string>Baseline correction</string>
</property>
@ -58,7 +58,7 @@
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<widget class="QGroupBox" name="leftshift_box">
<property name="title">
<string>Left shift</string>
</property>
@ -83,7 +83,7 @@
</widget>
</item>
<item row="0" column="0">
<widget class="QComboBox" name="comboBox">
<widget class="QComboBox" name="leftshift_comboBox">
<item>
<property name="text">
<string>Points</string>
@ -105,14 +105,14 @@
<number>0</number>
</property>
<item>
<widget class="QSpinBox" name="lsspinBox">
<widget class="QSpinBox" name="ls_spinBox">
<property name="maximum">
<number>9999</number>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit"/>
<widget class="QLineEdit" name="ls_lineEdit"/>
</item>
</layout>
</item>
@ -120,7 +120,7 @@
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_6">
<widget class="QGroupBox" name="zerofill_box">
<property name="title">
<string>Zerofilling</string>
</property>
@ -151,7 +151,7 @@
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<widget class="QGroupBox" name="phase_box">
<property name="title">
<string>Phase correction</string>
</property>
@ -174,6 +174,39 @@
<property name="verticalSpacing">
<number>0</number>
</property>
<item row="7" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Pivot</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QPushButton" name="phase_prev_button">
<property name="text">
<string>Preview</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="ph0slider">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="wrapping">
<bool>true</bool>
</property>
<property name="minimum">
<double>-180.000000000000000</double>
</property>
<property name="maximum">
<double>180.000000000000000</double>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QDoubleSpinBox" name="ph1slider">
<property name="wrapping">
@ -187,6 +220,13 @@
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QPushButton" name="phasebutton">
<property name="text">
<string>Apply</string>
</property>
</widget>
</item>
<item row="4" column="0" rowspan="3">
<widget class="QLabel" name="label_6">
<property name="text">
@ -194,13 +234,6 @@
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QPushButton" name="pushButton_2">
<property name="text">
<string>Preview</string>
</property>
</widget>
</item>
<item row="1" column="0" rowspan="3">
<widget class="QLabel" name="label">
<property name="text">
@ -224,36 +257,10 @@
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="ph0slider">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="wrapping">
<bool>true</bool>
</property>
<property name="minimum">
<double>-180.000000000000000</double>
</property>
<property name="maximum">
<double>180.000000000000000</double>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_8">
<item row="8" column="0" colspan="2">
<widget class="QCheckBox" name="autophase_check">
<property name="text">
<string>Pivot</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QPushButton" name="phasebutton">
<property name="text">
<string>Apply</string>
<string>Autophase at pivot point</string>
</property>
</widget>
</item>
@ -261,7 +268,7 @@
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<widget class="QGroupBox" name="apod_box">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -288,7 +295,7 @@
<widget class="QComboBox" name="apodcombobox"/>
</item>
<item>
<widget class="QLabel" name="label_2">
<widget class="QLabel" name="apod_name_label">
<property name="text">
<string>TextLabel</string>
</property>
@ -298,7 +305,7 @@
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_8">
<layout class="QVBoxLayout" name="apod_layout">
<property name="spacing">
<number>0</number>
</property>
@ -307,7 +314,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="pushButton">
<widget class="QPushButton" name="apod_prev_button">
<property name="text">
<string>Preview</string>
</property>
@ -326,7 +333,7 @@
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_5">
<widget class="QGroupBox" name="fft_box">
<property name="title">
<string>FFT</string>
</property>
@ -368,6 +375,24 @@
</item>
</layout>
</widget>
<tabstops>
<tabstop>baselinebutton</tabstop>
<tabstop>leftshift_comboBox</tabstop>
<tabstop>ls_spinBox</tabstop>
<tabstop>ls_lineEdit</tabstop>
<tabstop>leftshiftbutton</tabstop>
<tabstop>zfbutton</tabstop>
<tabstop>ph0slider</tabstop>
<tabstop>ph1slider</tabstop>
<tabstop>pivot_lineedit</tabstop>
<tabstop>autophase_check</tabstop>
<tabstop>phase_prev_button</tabstop>
<tabstop>phasebutton</tabstop>
<tabstop>apodcombobox</tabstop>
<tabstop>apod_prev_button</tabstop>
<tabstop>apodbutton</tabstop>
<tabstop>fourierutton</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>