1
0
forked from IPKM/nmreval

added f-omega option to log-fourier transform; closes #134

This commit is contained in:
Dominik Demuth
2023-11-09 17:50:29 +01:00
parent dbb35cdba4
commit 9c5d91918f
5 changed files with 78 additions and 28 deletions

View File

@ -1,10 +1,11 @@
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'resources/_ui/integratederive_dialog.ui'
# Form implementation generated from reading ui file 'src/resources/_ui/integratederive_dialog.ui'
#
# Created by: PyQt5 UI code generator 5.12.3
# Created by: PyQt5 UI code generator 5.15.9
#
# WARNING! All changes made in this file will be lost!
# 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.
from PyQt5 import QtCore, QtGui, QtWidgets
@ -13,7 +14,7 @@ from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(400, 308)
Dialog.resize(400, 375)
self.verticalLayout = QtWidgets.QVBoxLayout(Dialog)
self.verticalLayout.setObjectName("verticalLayout")
self.listWidget = QtWidgets.QListWidget(Dialog)
@ -49,6 +50,9 @@ class Ui_Dialog(object):
self.log_checkbox = QtWidgets.QCheckBox(Dialog)
self.log_checkbox.setObjectName("log_checkbox")
self.verticalLayout.addWidget(self.log_checkbox)
self.freq_box = QtWidgets.QCheckBox(Dialog)
self.freq_box.setObjectName("freq_box")
self.verticalLayout.addWidget(self.freq_box)
self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
self.horizontalLayout_2.setContentsMargins(-1, 0, -1, -1)
self.horizontalLayout_2.setSpacing(3)
@ -67,8 +71,8 @@ class Ui_Dialog(object):
self.verticalLayout.addWidget(self.buttonBox)
self.retranslateUi(Dialog)
self.buttonBox.accepted.connect(Dialog.accept)
self.buttonBox.rejected.connect(Dialog.reject)
self.buttonBox.accepted.connect(Dialog.accept) # type: ignore
self.buttonBox.rejected.connect(Dialog.reject) # type: ignore
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
@ -80,4 +84,5 @@ class Ui_Dialog(object):
self.ft_comboBox.setItemText(1, _translate("Dialog", "Imag"))
self.ft_comboBox.setItemText(2, _translate("Dialog", "Complex"))
self.log_checkbox.setText(_translate("Dialog", "use logarithmic x axis"))
self.freq_box.setText(_translate("Dialog", "return x axis as f, not omega"))
self.newgraph_checkbox.setText(_translate("Dialog", "New graph"))

View File

@ -1139,13 +1139,14 @@ class UpperManagement(QtCore.QObject):
def logft(self, **kwargs):
new_sets = []
ft_mode = kwargs['ft_mode']
return_f = kwargs['return_f']
for set_id in kwargs['sets']:
data_i = self.data[set_id]
if ft_mode in ['cos', 'sin']:
new_data = Points(*logft(data_i.x, data_i.y, mode=ft_mode))
new_data = Points(*logft(data_i.x, data_i.y, mode=ft_mode, return_f=return_f))
else:
new_data = Signal(*logft(data_i.x, data_i.y, mode=ft_mode))
new_data = Signal(*logft(data_i.x, data_i.y, mode=ft_mode, return_f=return_f))
new_sets.append(self.add(new_data, color=data_i['color'], symbol=data_i['symbol'], line=data_i['line']))
self.data[new_sets[-1]].update(data_i.data.meta)

View File

@ -16,16 +16,19 @@ class QDeriveIntegrate(QtWidgets.QDialog, Ui_Dialog):
self.start_lineedit.setValidator(QtGui.QDoubleValidator())
self.stop_lineedit.setValidator(QtGui.QDoubleValidator())
self.ft_comboBox.hide()
self.freq_box.hide()
elif self.mode == 'd':
self.setWindowTitle('Differentiation dialog')
self.widget.hide()
self.ft_comboBox.hide()
self.freq_box.hide()
elif self.mode == 'l':
self.setWindowTitle('Logarithmic FT dialog')
self.log_checkbox.hide()
self.widget.hide()
self.freq_box.show()
else:
raise ValueError(f'Unknown mode {mode}, use "d", "i", or "l".')
@ -54,8 +57,10 @@ class QDeriveIntegrate(QtWidgets.QDialog, Ui_Dialog):
self.stop_lineedit.setEnabled(full_range != QtCore.Qt.Checked)
def get_options(self):
opts = {'graph': '' if self.newgraph_checkbox.isChecked() else self.graph_combobox.currentData(),
'mode': self.mode, 'sets': []}
opts = {
'graph': '' if self.newgraph_checkbox.isChecked() else self.graph_combobox.currentData(),
'mode': self.mode, 'sets': []
}
if self.mode == 'i':
start = None
@ -75,6 +80,7 @@ class QDeriveIntegrate(QtWidgets.QDialog, Ui_Dialog):
if self.mode == 'l':
opts['ft_mode'] = ['cos', 'sin', 'complex'][self.ft_comboBox.currentIndex()]
opts['return_f'] = self.freq_box.isChecked()
else:
opts['log'] = self.log_checkbox.isChecked()