Add standard deviation to averaging methods of pick points
This commit is contained in:
parent
05862730a0
commit
4f0a7827ba
@ -1,10 +1,11 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Form implementation generated from reading ui file 'resources/_ui/ptstab.ui'
|
# Form implementation generated from reading ui file './nmreval/src/resources/_ui/ptstab.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
|
||||||
@ -45,6 +46,7 @@ class Ui_Form(object):
|
|||||||
self.average_combobox.addItem("")
|
self.average_combobox.addItem("")
|
||||||
self.average_combobox.addItem("")
|
self.average_combobox.addItem("")
|
||||||
self.average_combobox.addItem("")
|
self.average_combobox.addItem("")
|
||||||
|
self.average_combobox.addItem("")
|
||||||
self.horizontalLayout.addWidget(self.average_combobox)
|
self.horizontalLayout.addWidget(self.average_combobox)
|
||||||
self.verticalLayout.addWidget(self.groupBox)
|
self.verticalLayout.addWidget(self.groupBox)
|
||||||
self.groupBox_2 = QtWidgets.QGroupBox(Form)
|
self.groupBox_2 = QtWidgets.QGroupBox(Form)
|
||||||
@ -111,7 +113,7 @@ class Ui_Form(object):
|
|||||||
"Single number for points (e.g. 1e-6); \n"
|
"Single number for points (e.g. 1e-6); \n"
|
||||||
"two numbers separated by space for regions (e.g. 1e-6 5e-6). \n"
|
"two numbers separated by space for regions (e.g. 1e-6 5e-6). \n"
|
||||||
"Changing between regions and points is NOT possible"))
|
"Changing between regions and points is NOT possible"))
|
||||||
self.groupBox.setTitle(_translate("Form", "Average"))
|
self.groupBox.setTitle(_translate("Form", "Average (drop-down used for pts and regions)"))
|
||||||
self.left_pt.setSuffix(_translate("Form", " pts"))
|
self.left_pt.setSuffix(_translate("Form", " pts"))
|
||||||
self.left_pt.setPrefix(_translate("Form", "- "))
|
self.left_pt.setPrefix(_translate("Form", "- "))
|
||||||
self.right_pt.setSuffix(_translate("Form", " pts"))
|
self.right_pt.setSuffix(_translate("Form", " pts"))
|
||||||
@ -119,6 +121,7 @@ class Ui_Form(object):
|
|||||||
self.average_combobox.setItemText(0, _translate("Form", "Mean"))
|
self.average_combobox.setItemText(0, _translate("Form", "Mean"))
|
||||||
self.average_combobox.setItemText(1, _translate("Form", "Sum"))
|
self.average_combobox.setItemText(1, _translate("Form", "Sum"))
|
||||||
self.average_combobox.setItemText(2, _translate("Form", "Integral"))
|
self.average_combobox.setItemText(2, _translate("Form", "Integral"))
|
||||||
|
self.average_combobox.setItemText(3, _translate("Form", "Std. deviation"))
|
||||||
self.groupBox_2.setTitle(_translate("Form", "Special value"))
|
self.groupBox_2.setTitle(_translate("Form", "Special value"))
|
||||||
self.special_comboBox.setToolTip(_translate("Form", "Automatic selection of respective points"))
|
self.special_comboBox.setToolTip(_translate("Form", "Automatic selection of respective points"))
|
||||||
self.special_comboBox.setItemText(0, _translate("Form", "max(y)"))
|
self.special_comboBox.setItemText(0, _translate("Form", "max(y)"))
|
||||||
|
@ -91,7 +91,7 @@ class PointSelectWidget(QtWidgets.QWidget, Ui_Form):
|
|||||||
item = QtWidgets.QListWidgetItem(f'{self.pts[-1][0]:.5g} - {self.pts[-1][1]:.5g}')
|
item = QtWidgets.QListWidgetItem(f'{self.pts[-1][0]:.5g} - {self.pts[-1][1]:.5g}')
|
||||||
else:
|
else:
|
||||||
item = QtWidgets.QListWidgetItem(f'{self.pts[-1]:.5g}')
|
item = QtWidgets.QListWidgetItem(f'{self.pts[-1]:.5g}')
|
||||||
item.setFlags(item.flags() ^ QtCore.Qt.ItemIsEditable)
|
item.setFlags(item.flags() ^ QtCore.Qt.ItemFlag.ItemIsEditable)
|
||||||
self.peaktable.blockSignals(True)
|
self.peaktable.blockSignals(True)
|
||||||
self.peaktable.addItem(item)
|
self.peaktable.addItem(item)
|
||||||
self.peaktable.blockSignals(False)
|
self.peaktable.blockSignals(False)
|
||||||
@ -103,7 +103,7 @@ class PointSelectWidget(QtWidgets.QWidget, Ui_Form):
|
|||||||
@QtCore.pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def apply(self) -> dict:
|
def apply(self) -> dict:
|
||||||
ret_dic = {'avg_range': [self.left_pt.value(), self.right_pt.value()],
|
ret_dic = {'avg_range': [self.left_pt.value(), self.right_pt.value()],
|
||||||
'avg_mode': {0: 'mean', 1: 'sum', 2: 'integral'}[self.average_combobox.currentIndex()],
|
'avg_mode': {0: 'mean', 1: 'sum', 2: 'integral', 3: 'std'}[self.average_combobox.currentIndex()],
|
||||||
'special': None, 'idx': None,
|
'special': None, 'idx': None,
|
||||||
'xy': (self.xbutton.isChecked(), self.ybutton.isChecked())}
|
'xy': (self.xbutton.isChecked(), self.ybutton.isChecked())}
|
||||||
|
|
||||||
@ -199,4 +199,4 @@ class PointSelectWidget(QtWidgets.QWidget, Ui_Form):
|
|||||||
|
|
||||||
@QtCore.pyqtSlot(int, name='on_graph_checkbox_stateChanged')
|
@QtCore.pyqtSlot(int, name='on_graph_checkbox_stateChanged')
|
||||||
def changed_state(self, checked):
|
def changed_state(self, checked):
|
||||||
self.graph_combobox.setEnabled(checked != QtCore.Qt.Checked)
|
self.graph_combobox.setEnabled(checked != QtCore.Qt.CheckState.Checked)
|
||||||
|
@ -294,7 +294,7 @@ class Points:
|
|||||||
|
|
||||||
avg_range (tuple of int) :
|
avg_range (tuple of int) :
|
||||||
Region for average of y values. Tuple (a, b) uses ``y[i-a:i+b+1]`` around index `i`. Default is (0, 0).
|
Region for average of y values. Tuple (a, b) uses ``y[i-a:i+b+1]`` around index `i`. Default is (0, 0).
|
||||||
avg_mode (str {'mean', 'sum', 'integral'} , optional) :
|
avg_mode (str {'mean', 'sum', 'integral', 'std'} , optional) :
|
||||||
Averaging type
|
Averaging type
|
||||||
|
|
||||||
`mean` : Arithmetic average
|
`mean` : Arithmetic average
|
||||||
@ -303,6 +303,8 @@ class Points:
|
|||||||
|
|
||||||
'integral`: Integration over range using Simpson's rule
|
'integral`: Integration over range using Simpson's rule
|
||||||
|
|
||||||
|
'std': Standard deviation
|
||||||
|
|
||||||
pts (list, optional) :
|
pts (list, optional) :
|
||||||
If given, points will be appended.
|
If given, points will be appended.
|
||||||
|
|
||||||
@ -313,8 +315,8 @@ class Points:
|
|||||||
if (idx is None) and (special is None):
|
if (idx is None) and (special is None):
|
||||||
raise ValueError('Either `idx` or `special` must be given')
|
raise ValueError('Either `idx` or `special` must be given')
|
||||||
|
|
||||||
if avg_mode not in ['mean', 'sum', 'integral']:
|
if avg_mode not in ['mean', 'sum', 'integral', 'std']:
|
||||||
raise ValueError(f'Parameter `avg_mode` is `mean`, `sum`, `integral`, not `{avg_mode}`' )
|
raise ValueError(f'Parameter `avg_mode` is `mean`, `sum`, `integral`, `std`, not `{avg_mode}`' )
|
||||||
|
|
||||||
if pts is None:
|
if pts is None:
|
||||||
pts = []
|
pts = []
|
||||||
@ -388,6 +390,10 @@ class Points:
|
|||||||
y_mean = simpson(y[left:right].real, x=x[left:right])
|
y_mean = simpson(y[left:right].real, x=x[left:right])
|
||||||
y_err_mean = np.linalg.norm(cumulative_trapezoid(y_err[left:right].real, x=x[left:right]))
|
y_err_mean = np.linalg.norm(cumulative_trapezoid(y_err[left:right].real, x=x[left:right]))
|
||||||
|
|
||||||
|
elif mode == 'std':
|
||||||
|
y_mean = np.std(y[left:right])
|
||||||
|
y_err_mean = 0.
|
||||||
|
|
||||||
else:
|
else:
|
||||||
y_mean = y[idx].real
|
y_mean = y[idx].real
|
||||||
y_err_mean = y_err[idx]
|
y_err_mean = y_err[idx]
|
||||||
|
@ -42,7 +42,7 @@ Changing between regions and points is NOT possible</string>
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBox">
|
<widget class="QGroupBox" name="groupBox">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Average</string>
|
<string>Average (drop-down used for pts and regions)</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
@ -109,6 +109,11 @@ Changing between regions and points is NOT possible</string>
|
|||||||
<string>Integral</string>
|
<string>Integral</string>
|
||||||
</property>
|
</property>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Std. deviation</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
Loading…
Reference in New Issue
Block a user