Merge branch 'master' into 194-fitrange

This commit is contained in:
Dominik Demuth 2024-01-18 18:20:54 +00:00
commit 8d9565705f
7 changed files with 223 additions and 166 deletions

View File

@ -29,10 +29,10 @@ jobs:
env: env:
GPG_KEYGRIP: ${{ vars.GPG_KEYGRIP }} GPG_KEYGRIP: ${{ vars.GPG_KEYGRIP }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
GO_PIPELINE_LABEL: ${{ env.YEAR }}.${{ gitea.run_number }}_${{ env.SHA_SHORT }}_bookworm GO_PIPELINE_LABEL: ${{ env.YEAR }}.${{ gitea.run_number }}_${{ env.SHA_SHORT }}
- name: Upload AppImage - name: Upload AppImage
run: ./tools/upload_gitea.sh run: ./tools/upload_gitea.sh
env: env:
GO_PIPELINE_LABEL: ${{ env.YEAR }}.${{ gitea.run_number }}_${{ env.SHA_SHORT }}_bookworm GO_PIPELINE_LABEL: ${{ env.YEAR }}.${{ gitea.run_number }}_${{ env.SHA_SHORT }}
UPLOAD_TOKEN: ${{ secrets.UPLOAD_TOKEN }} UPLOAD_TOKEN: ${{ secrets.UPLOAD_TOKEN }}
UPLOAD_USER: ${{ vars.UPLOAD_USER }} UPLOAD_USER: ${{ vars.UPLOAD_USER }}

View File

@ -1,10 +1,11 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'resources/_ui/fcreader.ui' # Form implementation generated from reading ui file 'src/resources/_ui/fcreader.ui'
# #
# Created by: PyQt5 UI code generator 5.12.3 # Created by: PyQt5 UI code generator 5.15.10
# #
# 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 from PyQt5 import QtCore, QtGui, QtWidgets
@ -47,6 +48,7 @@ class Ui_FCEval_dialog(object):
self.verticalLayout.addWidget(self.input_box) self.verticalLayout.addWidget(self.input_box)
self.region_box = QtWidgets.QGroupBox(FCEval_dialog) self.region_box = QtWidgets.QGroupBox(FCEval_dialog)
self.region_box.setCheckable(True) self.region_box.setCheckable(True)
self.region_box.setChecked(False)
self.region_box.setObjectName("region_box") self.region_box.setObjectName("region_box")
self.horizontalLayout = QtWidgets.QHBoxLayout(self.region_box) self.horizontalLayout = QtWidgets.QHBoxLayout(self.region_box)
self.horizontalLayout.setContentsMargins(3, 3, 3, 3) self.horizontalLayout.setContentsMargins(3, 3, 3, 3)
@ -139,6 +141,7 @@ class Ui_FCEval_dialog(object):
self.line.setObjectName("line") self.line.setObjectName("line")
self.gridLayout.addWidget(self.line, 2, 0, 1, 2) self.gridLayout.addWidget(self.line, 2, 0, 1, 2)
self.graph_comboBox = QtWidgets.QComboBox(self.out_box) self.graph_comboBox = QtWidgets.QComboBox(self.out_box)
self.graph_comboBox.setEnabled(False)
self.graph_comboBox.setObjectName("graph_comboBox") self.graph_comboBox.setObjectName("graph_comboBox")
self.gridLayout.addWidget(self.graph_comboBox, 3, 1, 1, 1) self.gridLayout.addWidget(self.graph_comboBox, 3, 1, 1, 1)
self.graph_checkbox = QtWidgets.QCheckBox(self.out_box) self.graph_checkbox = QtWidgets.QCheckBox(self.out_box)
@ -167,8 +170,8 @@ class Ui_FCEval_dialog(object):
self.label_6.setBuddy(self.m0_cb) self.label_6.setBuddy(self.m0_cb)
self.retranslateUi(FCEval_dialog) self.retranslateUi(FCEval_dialog)
self.buttonBox.accepted.connect(FCEval_dialog.accept) self.buttonBox.accepted.connect(FCEval_dialog.accept) # type: ignore
self.buttonBox.rejected.connect(FCEval_dialog.reject) self.buttonBox.rejected.connect(FCEval_dialog.reject) # type: ignore
QtCore.QMetaObject.connectSlotsByName(FCEval_dialog) QtCore.QMetaObject.connectSlotsByName(FCEval_dialog)
def retranslateUi(self, FCEval_dialog): def retranslateUi(self, FCEval_dialog):
@ -178,7 +181,7 @@ class Ui_FCEval_dialog(object):
self.file_pushbutton.setText(_translate("FCEval_dialog", "Add HDF files...")) self.file_pushbutton.setText(_translate("FCEval_dialog", "Add HDF files..."))
self.dir_pushbutton.setText(_translate("FCEval_dialog", "Add directory...")) self.dir_pushbutton.setText(_translate("FCEval_dialog", "Add directory..."))
self.overwrite_cb.setText(_translate("FCEval_dialog", "Overwrite prev. data")) self.overwrite_cb.setText(_translate("FCEval_dialog", "Overwrite prev. data"))
self.region_box.setTitle(_translate("FCEval_dialog", "Evaluate region (empty values default to start/end)")) self.region_box.setTitle(_translate("FCEval_dialog", "Evaluate region (empty values default to values of the script)"))
self.start_lineedit.setPlaceholderText(_translate("FCEval_dialog", "start pos in µs")) self.start_lineedit.setPlaceholderText(_translate("FCEval_dialog", "start pos in µs"))
self.stop_lineedit.setPlaceholderText(_translate("FCEval_dialog", "end pos in µs")) self.stop_lineedit.setPlaceholderText(_translate("FCEval_dialog", "end pos in µs"))
self.fit_box.setTitle(_translate("FCEval_dialog", "Fit equation")) self.fit_box.setTitle(_translate("FCEval_dialog", "Fit equation"))

View File

@ -1,10 +1,11 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'resources/_ui/smoothdialog.ui' # Form implementation generated from reading ui file 'src/resources/_ui/smoothdialog.ui'
# #
# Created by: PyQt5 UI code generator 5.12.3 # Created by: PyQt5 UI code generator 5.15.10
# #
# 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 from PyQt5 import QtCore, QtGui, QtWidgets
@ -17,9 +18,37 @@ class Ui_SmoothDialog(object):
self.gridLayout = QtWidgets.QGridLayout(SmoothDialog) self.gridLayout = QtWidgets.QGridLayout(SmoothDialog)
self.gridLayout.setSpacing(3) self.gridLayout.setSpacing(3)
self.gridLayout.setObjectName("gridLayout") self.gridLayout.setObjectName("gridLayout")
spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
self.gridLayout.addItem(spacerItem, 7, 0, 1, 1)
self.frac_label = QtWidgets.QLabel(SmoothDialog) self.frac_label = QtWidgets.QLabel(SmoothDialog)
self.frac_label.setObjectName("frac_label") self.frac_label.setObjectName("frac_label")
self.gridLayout.addWidget(self.frac_label, 1, 0, 1, 1) self.gridLayout.addWidget(self.frac_label, 2, 0, 1, 1)
self.line = QtWidgets.QFrame(SmoothDialog)
self.line.setFrameShape(QtWidgets.QFrame.HLine)
self.line.setFrameShadow(QtWidgets.QFrame.Sunken)
self.line.setObjectName("line")
self.gridLayout.addWidget(self.line, 5, 0, 1, 2)
self.widget = QtWidgets.QWidget(SmoothDialog)
self.widget.setObjectName("widget")
self.horizontalLayout_2 = QtWidgets.QHBoxLayout(self.widget)
self.horizontalLayout_2.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout_2.setSpacing(3)
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
self.label = QtWidgets.QLabel(self.widget)
self.label.setObjectName("label")
self.horizontalLayout_2.addWidget(self.label)
self.polynom_spinBox = QtWidgets.QSpinBox(self.widget)
self.polynom_spinBox.setMinimum(1)
self.polynom_spinBox.setMaximum(3)
self.polynom_spinBox.setObjectName("polynom_spinBox")
self.horizontalLayout_2.addWidget(self.polynom_spinBox)
self.gridLayout.addWidget(self.widget, 3, 0, 1, 2)
self.y_checkBox = QtWidgets.QCheckBox(SmoothDialog)
self.y_checkBox.setObjectName("y_checkBox")
self.gridLayout.addWidget(self.y_checkBox, 6, 1, 1, 1)
self.x_checkBox = QtWidgets.QCheckBox(SmoothDialog)
self.x_checkBox.setObjectName("x_checkBox")
self.gridLayout.addWidget(self.x_checkBox, 6, 0, 1, 1)
self.widget_2 = QtWidgets.QWidget(SmoothDialog) self.widget_2 = QtWidgets.QWidget(SmoothDialog)
self.widget_2.setObjectName("widget_2") self.widget_2.setObjectName("widget_2")
self.horizontalLayout_3 = QtWidgets.QHBoxLayout(self.widget_2) self.horizontalLayout_3 = QtWidgets.QHBoxLayout(self.widget_2)
@ -35,37 +64,17 @@ class Ui_SmoothDialog(object):
self.iter_spinBox.setProperty("value", 1) self.iter_spinBox.setProperty("value", 1)
self.iter_spinBox.setObjectName("iter_spinBox") self.iter_spinBox.setObjectName("iter_spinBox")
self.horizontalLayout_3.addWidget(self.iter_spinBox) self.horizontalLayout_3.addWidget(self.iter_spinBox)
self.gridLayout.addWidget(self.widget_2, 3, 0, 1, 2) self.gridLayout.addWidget(self.widget_2, 4, 0, 1, 2)
self.line = QtWidgets.QFrame(SmoothDialog)
self.line.setFrameShape(QtWidgets.QFrame.HLine)
self.line.setFrameShadow(QtWidgets.QFrame.Sunken)
self.line.setObjectName("line")
self.gridLayout.addWidget(self.line, 4, 0, 1, 2)
self.buttonBox = QtWidgets.QDialogButtonBox(SmoothDialog)
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Apply|QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
self.buttonBox.setObjectName("buttonBox")
self.gridLayout.addWidget(self.buttonBox, 7, 0, 1, 2)
self.widget = QtWidgets.QWidget(SmoothDialog)
self.widget.setObjectName("widget")
self.horizontalLayout_2 = QtWidgets.QHBoxLayout(self.widget)
self.horizontalLayout_2.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout_2.setSpacing(3)
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
self.label = QtWidgets.QLabel(self.widget)
self.label.setObjectName("label")
self.horizontalLayout_2.addWidget(self.label)
self.polynom_spinBox = QtWidgets.QSpinBox(self.widget)
self.polynom_spinBox.setMinimum(1)
self.polynom_spinBox.setMaximum(3)
self.polynom_spinBox.setObjectName("polynom_spinBox")
self.horizontalLayout_2.addWidget(self.polynom_spinBox)
self.gridLayout.addWidget(self.widget, 2, 0, 1, 2)
self.frac_spinBox = QtWidgets.QSpinBox(SmoothDialog) self.frac_spinBox = QtWidgets.QSpinBox(SmoothDialog)
self.frac_spinBox.setMinimum(1) self.frac_spinBox.setMinimum(1)
self.frac_spinBox.setMaximum(999) self.frac_spinBox.setMaximum(999)
self.frac_spinBox.setObjectName("frac_spinBox") self.frac_spinBox.setObjectName("frac_spinBox")
self.gridLayout.addWidget(self.frac_spinBox, 1, 1, 1, 1) self.gridLayout.addWidget(self.frac_spinBox, 2, 1, 1, 1)
self.buttonBox = QtWidgets.QDialogButtonBox(SmoothDialog)
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Apply|QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
self.buttonBox.setObjectName("buttonBox")
self.gridLayout.addWidget(self.buttonBox, 8, 0, 1, 2)
self.comboBox = QtWidgets.QComboBox(SmoothDialog) self.comboBox = QtWidgets.QComboBox(SmoothDialog)
self.comboBox.setObjectName("comboBox") self.comboBox.setObjectName("comboBox")
self.comboBox.addItem("") self.comboBox.addItem("")
@ -77,22 +86,17 @@ class Ui_SmoothDialog(object):
self.comboBox.addItem("") self.comboBox.addItem("")
self.comboBox.addItem("") self.comboBox.addItem("")
self.comboBox.addItem("") self.comboBox.addItem("")
self.gridLayout.addWidget(self.comboBox, 0, 0, 1, 2) self.gridLayout.addWidget(self.comboBox, 1, 0, 1, 2)
spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) self.label_2 = QtWidgets.QLabel(SmoothDialog)
self.gridLayout.addItem(spacerItem, 6, 0, 1, 1) self.label_2.setObjectName("label_2")
self.y_checkBox = QtWidgets.QCheckBox(SmoothDialog) self.gridLayout.addWidget(self.label_2, 0, 0, 1, 2)
self.y_checkBox.setObjectName("y_checkBox")
self.gridLayout.addWidget(self.y_checkBox, 5, 1, 1, 1)
self.x_checkBox = QtWidgets.QCheckBox(SmoothDialog)
self.x_checkBox.setObjectName("x_checkBox")
self.gridLayout.addWidget(self.x_checkBox, 5, 0, 1, 1)
self.frac_label.setBuddy(self.frac_spinBox) self.frac_label.setBuddy(self.frac_spinBox)
self.label_3.setBuddy(self.iter_spinBox)
self.label.setBuddy(self.polynom_spinBox) self.label.setBuddy(self.polynom_spinBox)
self.label_3.setBuddy(self.iter_spinBox)
self.retranslateUi(SmoothDialog) self.retranslateUi(SmoothDialog)
self.buttonBox.accepted.connect(SmoothDialog.accept) self.buttonBox.accepted.connect(SmoothDialog.accept) # type: ignore
self.buttonBox.rejected.connect(SmoothDialog.reject) self.buttonBox.rejected.connect(SmoothDialog.reject) # type: ignore
QtCore.QMetaObject.connectSlotsByName(SmoothDialog) QtCore.QMetaObject.connectSlotsByName(SmoothDialog)
SmoothDialog.setTabOrder(self.comboBox, self.frac_spinBox) SmoothDialog.setTabOrder(self.comboBox, self.frac_spinBox)
SmoothDialog.setTabOrder(self.frac_spinBox, self.polynom_spinBox) SmoothDialog.setTabOrder(self.frac_spinBox, self.polynom_spinBox)
@ -104,9 +108,11 @@ class Ui_SmoothDialog(object):
_translate = QtCore.QCoreApplication.translate _translate = QtCore.QCoreApplication.translate
SmoothDialog.setWindowTitle(_translate("SmoothDialog", "1D smoothing filter")) SmoothDialog.setWindowTitle(_translate("SmoothDialog", "1D smoothing filter"))
self.frac_label.setText(_translate("SmoothDialog", "Window length")) self.frac_label.setText(_translate("SmoothDialog", "Window length"))
self.label_3.setText(_translate("SmoothDialog", "Iterations"))
self.label.setText(_translate("SmoothDialog", "Polynomial degree")) self.label.setText(_translate("SmoothDialog", "Polynomial degree"))
self.polynom_spinBox.setToolTip(_translate("SmoothDialog", "Deg")) self.polynom_spinBox.setToolTip(_translate("SmoothDialog", "Deg"))
self.y_checkBox.setText(_translate("SmoothDialog", "y log-spaced?"))
self.x_checkBox.setText(_translate("SmoothDialog", "x log-spaced?"))
self.label_3.setText(_translate("SmoothDialog", "Iterations"))
self.frac_spinBox.setToolTip(_translate("SmoothDialog", "<html><head/><body><p>Number of data points used as smoothing window.</p></body></html>")) self.frac_spinBox.setToolTip(_translate("SmoothDialog", "<html><head/><body><p>Number of data points used as smoothing window.</p></body></html>"))
self.comboBox.setItemText(0, _translate("SmoothDialog", "Moving mean")) self.comboBox.setItemText(0, _translate("SmoothDialog", "Moving mean"))
self.comboBox.setItemText(1, _translate("SmoothDialog", "Savitzky-Golay")) self.comboBox.setItemText(1, _translate("SmoothDialog", "Savitzky-Golay"))
@ -117,5 +123,4 @@ class Ui_SmoothDialog(object):
self.comboBox.setItemText(6, _translate("SmoothDialog", "Moving maximum")) self.comboBox.setItemText(6, _translate("SmoothDialog", "Moving maximum"))
self.comboBox.setItemText(7, _translate("SmoothDialog", "Moving minimum")) self.comboBox.setItemText(7, _translate("SmoothDialog", "Moving minimum"))
self.comboBox.setItemText(8, _translate("SmoothDialog", "Moving sum")) self.comboBox.setItemText(8, _translate("SmoothDialog", "Moving sum"))
self.y_checkBox.setText(_translate("SmoothDialog", "y log-spaced?")) self.label_2.setText(_translate("SmoothDialog", "<html><head/><body><p><span style=\" font-weight:600;\">Note:</span> Sets must be sorted for correct results</p></body></html>"))
self.x_checkBox.setText(_translate("SmoothDialog", "x log-spaced?"))

View File

@ -22,14 +22,16 @@ class QFCReader(QtWidgets.QDialog, Ui_FCEval_dialog):
self.start_lineedit.setValidator(QtGui.QDoubleValidator()) self.start_lineedit.setValidator(QtGui.QDoubleValidator())
self.stop_lineedit.setValidator(QtGui.QDoubleValidator()) self.stop_lineedit.setValidator(QtGui.QDoubleValidator())
self.graph_checkbox.stateChanged.connect(lambda x: self.graph_comboBox.setEnabled(not bool(x))) self.graph_checkbox.stateChanged.connect(
lambda x: self.graph_comboBox.setEnabled(x == QtCore.Qt.CheckState.Unchecked)
)
self.listWidget.installEventFilter(self) self.listWidget.installEventFilter(self)
def eventFilter(self, src: QtCore.QObject, evt: QtCore.QEvent) -> bool: def eventFilter(self, src: QtCore.QObject, evt: QtCore.QEvent) -> bool:
# intercept key press in listwidget to allow deletion with Del # intercept key press in listwidget to allow deletion with Del
if evt.type() == QtCore.QEvent.KeyPress: if evt.type() == QtCore.QEvent.Type.KeyPress:
if evt.key() == QtCore.Qt.Key_Delete: if evt.key() == QtCore.Qt.Key.Key_Delete:
self.listWidget.takeItem(self.listWidget.currentRow()) self.listWidget.takeItem(self.listWidget.currentRow())
return True return True
@ -41,21 +43,25 @@ class QFCReader(QtWidgets.QDialog, Ui_FCEval_dialog):
@QtCore.pyqtSlot(int, name='on_region_checkBox_stateChanged') @QtCore.pyqtSlot(int, name='on_region_checkBox_stateChanged')
def use_region(self, state: int): def use_region(self, state: int):
self.start_lineedit.setEnabled(state == QtCore.Qt.Checked) self.start_lineedit.setEnabled(state == QtCore.Qt.CheckState.Checked)
self.stop_lineedit.setEnabled(state == QtCore.Qt.Checked) self.stop_lineedit.setEnabled(state == QtCore.Qt.CheckState.Checked)
@QtCore.pyqtSlot(name='on_file_pushbutton_clicked') @QtCore.pyqtSlot(name='on_file_pushbutton_clicked')
@QtCore.pyqtSlot(name='on_dir_pushbutton_clicked') @QtCore.pyqtSlot(name='on_dir_pushbutton_clicked')
def get_input(self): def get_input(self):
if self.sender() == self.file_pushbutton: if self.sender() == self.file_pushbutton:
infiles, _ = QtWidgets.QFileDialog.getOpenFileNames(caption='Select HDF files', infiles, _ = QtWidgets.QFileDialog.getOpenFileNames(
directory=str(self.path), caption='Select HDF files',
filter='HDF files (*.h5)') directory=str(self.path),
filter='HDF files (*.h5)',
)
else: else:
infiles = QtWidgets.QFileDialog.getExistingDirectory(caption='Select input directory', infiles = QtWidgets.QFileDialog.getExistingDirectory(
directory=str(self.path), caption='Select input directory',
options=QtWidgets.QFileDialog.ShowDirsOnly) directory=str(self.path),
options=QtWidgets.QFileDialog.ShowDirsOnly,
)
infiles = [infiles] if infiles else infiles infiles = [infiles] if infiles else infiles
if infiles: if infiles:
@ -65,9 +71,12 @@ class QFCReader(QtWidgets.QDialog, Ui_FCEval_dialog):
@QtCore.pyqtSlot(name='on_savebutton_clicked') @QtCore.pyqtSlot(name='on_savebutton_clicked')
def save_path(self): def save_path(self):
outfile = QtWidgets.QFileDialog.getExistingDirectory(self, caption='Select directory', outfile = QtWidgets.QFileDialog.getExistingDirectory(
directory=self.label.text(), self,
options=QtWidgets.QFileDialog.ShowDirsOnly) caption='Select directory',
directory=self.label.text(),
options=QtWidgets.QFileDialog.ShowDirsOnly,
)
if outfile: if outfile:
self.label.setText(outfile) self.label.setText(outfile)
@ -110,6 +119,6 @@ class QFCReader(QtWidgets.QDialog, Ui_FCEval_dialog):
grp = '' grp = ''
if not self.graph_checkbox.isChecked(): if not self.graph_checkbox.isChecked():
grp = self.graph_comboBox.currentData(QtCore.Qt.UserRole) grp = self.graph_comboBox.currentData(QtCore.Qt.ItemDataRole.UserRole)
self.data_read.emit(ret_vals, grp) self.data_read.emit(ret_vals, grp)

View File

@ -3,14 +3,21 @@ import numpy.polynomial.polynomial as poly
from scipy import signal as signal from scipy import signal as signal
__all__ = ['smooth', 'loess', 'savgol', __all__ = [
'running_max', 'running_min', 'smooth',
'running_var', 'running_std', 'loess',
'running_median', 'running_mean', 'savgol',
'running_sum'] 'running_max',
'running_min',
'running_var',
'running_std',
'running_median',
'running_mean',
'running_sum',
]
def loess(x, y, window_size, it=0, deg=2): def loess(x, y, window_size: int, it: int = 0, deg: int = 2):
# ULTRA LANGSAM !!! # ULTRA LANGSAM !!!
it = max(it, 0) it = max(it, 0)
@ -81,19 +88,19 @@ def savgol(x, y, window_size: int, deg: int = 2, mode: str = 'mirror'):
return new_y return new_y
def running_mean(x, y, window_size): def running_mean(x, y, window_size: int):
return _running_func(np.nanmean, x, y, window_size) return _running_func(np.nanmean, x, y, window_size)
def running_median(x, y, window_size): def running_median(x, y, window_size: int):
return _running_func(np.nanmedian, x, y, window_size) return _running_func(np.nanmedian, x, y, window_size)
def running_std(x, y, window_size): def running_std(x, y, window_size: int):
return _running_func(np.nanstd, x, y, window_size) return _running_func(np.nanstd, x, y, window_size)
def running_var(x, y, window_size): def running_var(x, y, window_size: int):
return _running_func(np.nanvar, x, y, window_size) return _running_func(np.nanvar, x, y, window_size)
@ -132,11 +139,27 @@ def _moving_window(arr, nn):
return np.lib.stride_tricks.as_strided(arr, shapes, strides) return np.lib.stride_tricks.as_strided(arr, shapes, strides)
_funcs = {'loess': loess, 'savgol': savgol, 'mean': running_mean, 'median': running_median, _funcs = {
'std': running_std, 'var': running_var, 'max': running_max, 'min': running_min, 'sum': running_sum} 'loess': loess,
'savgol': savgol,
'mean': running_mean,
'median': running_median,
'std': running_std,
'var': running_var,
'max': running_max,
'min': running_min,
'sum': running_sum,
}
def smooth(data, window_size, mode='mean', logx=False, logy=False, **kwargs): def smooth(
data: 'Data',
window_size: int,
mode: str = 'mean',
logx: bool = False,
logy: bool = False,
**kwargs
):
try: try:
func = _funcs[mode] func = _funcs[mode]
except KeyError: except KeyError:
@ -162,6 +185,6 @@ def smooth(data, window_size, mode='mean', logx=False, logy=False, **kwargs):
new_y = 10**new_y new_y = 10**new_y
new_data = data.copy() new_data = data.copy()
new_data.set_data(x=new_x, y=new_y, y_err=None) new_data.set_data(x=new_x, y=new_y, y_err=np.zeros_like(new_y))
return new_data return new_data

View File

@ -96,11 +96,14 @@
<item> <item>
<widget class="QGroupBox" name="region_box"> <widget class="QGroupBox" name="region_box">
<property name="title"> <property name="title">
<string>Evaluate region (empty values default to start/end)</string> <string>Evaluate region (empty values default to values of the script)</string>
</property> </property>
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing"> <property name="spacing">
<number>3</number> <number>3</number>
@ -311,7 +314,11 @@
</widget> </widget>
</item> </item>
<item row="3" column="1"> <item row="3" column="1">
<widget class="QComboBox" name="graph_comboBox"/> <widget class="QComboBox" name="graph_comboBox">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item> </item>
<item row="3" column="0"> <item row="3" column="0">
<widget class="QCheckBox" name="graph_checkbox"> <widget class="QCheckBox" name="graph_checkbox">

View File

@ -17,7 +17,20 @@
<property name="spacing"> <property name="spacing">
<number>3</number> <number>3</number>
</property> </property>
<item row="1" column="0"> <item row="7" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0">
<widget class="QLabel" name="frac_label"> <widget class="QLabel" name="frac_label">
<property name="text"> <property name="text">
<string>Window length</string> <string>Window length</string>
@ -27,68 +40,14 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0" colspan="2"> <item row="5" column="0" colspan="2">
<widget class="QWidget" name="widget_2" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="spacing">
<number>3</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Iterations</string>
</property>
<property name="buddy">
<cstring>iter_spinBox</cstring>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="iter_spinBox">
<property name="maximum">
<number>3</number>
</property>
<property name="singleStep">
<number>1</number>
</property>
<property name="value">
<number>1</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="Line" name="line"> <widget class="Line" name="line">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="0" colspan="2"> <item row="3" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QWidget" name="widget" native="true"> <widget class="QWidget" name="widget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing"> <property name="spacing">
@ -132,7 +91,65 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="6" column="1">
<widget class="QCheckBox" name="y_checkBox">
<property name="text">
<string>y log-spaced?</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QCheckBox" name="x_checkBox">
<property name="text">
<string>x log-spaced?</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QWidget" name="widget_2" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="spacing">
<number>3</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Iterations</string>
</property>
<property name="buddy">
<cstring>iter_spinBox</cstring>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="iter_spinBox">
<property name="maximum">
<number>3</number>
</property>
<property name="singleStep">
<number>1</number>
</property>
<property name="value">
<number>1</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="frac_spinBox"> <widget class="QSpinBox" name="frac_spinBox">
<property name="toolTip"> <property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Number of data points used as smoothing window.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Number of data points used as smoothing window.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
@ -145,7 +162,17 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="0" colspan="2"> <item row="8" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QComboBox" name="comboBox"> <widget class="QComboBox" name="comboBox">
<item> <item>
<property name="text"> <property name="text">
@ -194,30 +221,13 @@
</item> </item>
</widget> </widget>
</item> </item>
<item row="6" column="0"> <item row="0" column="0" colspan="2">
<spacer name="verticalSpacer"> <widget class="QLabel" name="label_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="5" column="1">
<widget class="QCheckBox" name="y_checkBox">
<property name="text"> <property name="text">
<string>y log-spaced?</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Note:&lt;/span&gt; Sets must be sorted for correct results&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
</widget> <property name="margin">
</item> <number>3</number>
<item row="5" column="0">
<widget class="QCheckBox" name="x_checkBox">
<property name="text">
<string>x log-spaced?</string>
</property> </property>
</widget> </widget>
</item> </item>