add binning

This commit is contained in:
Dominik Demuth 2023-06-15 19:57:13 +02:00
parent 7732544f69
commit 1703b8d514
4 changed files with 46 additions and 0 deletions

View File

@ -480,6 +480,13 @@ class ExperimentContainer(QtCore.QObject):
return new_data return new_data
def binning(self, digits: int):
new_data = self.copy(full=True)
new_data.data = self._data.binning(decimals=digits)
print(new_data.x)
return new_data
class PointContainer(ExperimentContainer): class PointContainer(ExperimentContainer):
symbols = symbolcycle() symbols = symbolcycle()

View File

@ -25,6 +25,7 @@ from ..io.filedialog import *
from ..lib import get_icon, make_action_icons from ..lib import get_icon, make_action_icons
from ..lib.pg_objects import RegionItem from ..lib.pg_objects import RegionItem
from ..lib.starter import make_starter from ..lib.starter import make_starter
from ..math.binning import BinningWindow
from ..math.evaluation import QEvalDialog from ..math.evaluation import QEvalDialog
from ..math.interpol import InterpolDialog from ..math.interpol import InterpolDialog
from ..math.mean_dialog import QMeanTimes from ..math.mean_dialog import QMeanTimes
@ -696,6 +697,14 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
self.eval.exec() self.eval.exec()
@QtCore.pyqtSlot(name='on_actionBinning_triggered')
def open_binning(self):
dialog = BinningWindow(self)
res = dialog.exec()
if res:
digits = dialog.spinbox.value()
self.management.binning(digits)
@QtCore.pyqtSlot(name='on_actionDerivation_triggered') @QtCore.pyqtSlot(name='on_actionDerivation_triggered')
# @QtCore.pyqtSlot(name='on_actionIntegration_triggered') # @QtCore.pyqtSlot(name='on_actionIntegration_triggered')
@QtCore.pyqtSlot(name='on_actionFilon_triggered') @QtCore.pyqtSlot(name='on_actionFilon_triggered')

View File

@ -766,6 +766,15 @@ class UpperManagement(QtCore.QObject):
self.newData.emit(new_key, dest_graph) self.newData.emit(new_key, dest_graph)
def binning(self, digits: int):
_active = self.graphs[self.current_graph].active
new_data = []
for sid in _active:
key = self.add(self.data[sid].binning(digits=digits))
new_data.append(key)
self.newData.emit(new_data, '')
@QtCore.pyqtSlot(int, dict) @QtCore.pyqtSlot(int, dict)
def smooth_data(self, npoints, param_kwargs): def smooth_data(self, npoints, param_kwargs):
_active = self.graphs[self.current_graph].active _active = self.graphs[self.current_graph].active

View File

@ -0,0 +1,21 @@
from ..Qt import QtWidgets
class BinningWindow(QtWidgets.QDialog):
def __init__(self, parent=None):
super().__init__(parent=parent)
layout = QtWidgets.QFormLayout()
self.label = QtWidgets.QLabel('Digits (negative values position left of decimal point)')
self.spinbox = QtWidgets.QSpinBox()
self.spinbox.setMinimum(-10)
self.spinbox.setMaximum(10)
layout.addRow(self.label, self.spinbox)
self.dialogbox = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel)
self.dialogbox.accepted.connect(self.accept)
self.dialogbox.rejected.connect(self.reject)
layout.addWidget(self.dialogbox)
self.setLayout(layout)