194-fitrange #219

Merged
dominik merged 7 commits from 194-fitrange into master 2024-01-18 18:25:07 +00:00
Showing only changes of commit 37d93bb577 - Show all commits

View File

@ -22,7 +22,8 @@ class Namespace:
if basic: if basic:
self.add_namespace( self.add_namespace(
{'x': (None, 'x values'), {
'x': (None, 'x values'),
'y': (None, 'x values'), 'y': (None, 'x values'),
'y_err': (None, 'y error values'), 'y_err': (None, 'y error values'),
'fit': (None, 'dictionary of fit parameter', 'fit["PIKA"]'), 'fit': (None, 'dictionary of fit parameter', 'fit["PIKA"]'),
@ -32,7 +33,8 @@ class Namespace:
) )
self.add_namespace( self.add_namespace(
{'sin': (np.sin, 'Sine', 'sin(PIKA)'), {
'sin': (np.sin, 'Sine', 'sin(PIKA)'),
'cos': (np.cos, 'Cosine', 'cos(PIKA)'), 'cos': (np.cos, 'Cosine', 'cos(PIKA)'),
'tan': (np.tan, 'Tangens', 'tan(PIKA)'), 'tan': (np.tan, 'Tangens', 'tan(PIKA)'),
'ln': (np.log, 'Natural Logarithm', 'ln(PIKA)'), 'ln': (np.log, 'Natural Logarithm', 'ln(PIKA)'),
@ -45,7 +47,8 @@ class Namespace:
parents=('Basic', 'Functions')) parents=('Basic', 'Functions'))
self.add_namespace( self.add_namespace(
{'max': (np.max, 'Maximum value', 'max(PIKA)'), {
'max': (np.max, 'Maximum value', 'max(PIKA)'),
'min': (np.min, 'Minimum value', 'min(PIKA)'), 'min': (np.min, 'Minimum value', 'min(PIKA)'),
'argmax': (np.argmax, 'Index of maximum value', 'argmax(PIKA)'), 'argmax': (np.argmax, 'Index of maximum value', 'argmax(PIKA)'),
'argmin': (np.argmax, 'Index of minimum value', 'argmin(PIKA)'), 'argmin': (np.argmax, 'Index of minimum value', 'argmin(PIKA)'),
@ -54,19 +57,24 @@ class Namespace:
if const: if const:
self.add_namespace( self.add_namespace(
{'e': (constants.e, 'e / As'), {
'e': (constants.e, 'e / As'),
'eps0': (constants.epsilon0, 'epsilon0 / As/Vm'), 'eps0': (constants.epsilon0, 'epsilon0 / As/Vm'),
'Eu': (constants.Eu,), 'h': (constants.h, 'h / eVs'), 'Eu': (constants.Eu,),
'hbar': (constants.hbar, 'hbar / eVs'), 'kB': (constants.kB, 'kB / eV/K'), 'h': (constants.h, 'h / eVs'),
'mu0': (constants.mu0, 'mu0 / Vs/Am'), 'NA': (constants.NA, 'NA / 1/mol'), 'hbar': (constants.hbar, 'hbar / eVs'),
'pi': (constants.pi,), 'R': (constants.R, 'R / eV'), 'kB': (constants.kB, 'kB / eV/K'),
'mu0': (constants.mu0, 'mu0 / Vs/Am'),
'NA': (constants.NA, 'NA / 1/mol'),
'pi': (constants.pi,),
'R': (constants.R, 'R / eV'),
}, },
parents=('Constants', 'Maybe useful'), parents=('Constants', 'Maybe useful'),
) )
self.add_namespace( self.add_namespace(
{f'gamma["{k}"]': (v, k, f'gamma["{k}"]') for k, v in constants.gamma.items()}, {f'gamma["{k}"]': (v, k, f'gamma["{k}"]') for k, v in constants.gamma.items()},
parents=('Constants', 'Magnetogyric ratios (in 1/(sT))') parents=('Constants', 'Gyromagnetic ratios (in 1/(sT))')
) )
if fitfuncs: if fitfuncs:
@ -199,7 +207,7 @@ class QNamespaceWidget(QtWidgets.QWidget, Ui_Form):
for entry in subspace: for entry in subspace:
key_item = QtWidgets.QTableWidgetItem(entry) key_item = QtWidgets.QTableWidgetItem(entry)
key_item.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled) key_item.setFlags(QtCore.Qt.ItemFlag.ItemIsSelectable | QtCore.Qt.ItemFlag.ItemIsEnabled)
vals = self.namespace.namespace[entry] vals = self.namespace.namespace[entry]
@ -214,12 +222,12 @@ class QNamespaceWidget(QtWidgets.QWidget, Ui_Form):
display = vals[1] display = vals[1]
value_item = QtWidgets.QTableWidgetItem(display) value_item = QtWidgets.QTableWidgetItem(display)
value_item.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled) value_item.setFlags(QtCore.Qt.ItemFlag.ItemIsSelectable | QtCore.Qt.ItemFlag.ItemIsEnabled)
key_item.setData(QtCore.Qt.UserRole, alias) key_item.setData(QtCore.Qt.ItemDataRole.UserRole, alias)
key_item.setData(QtCore.Qt.UserRole+1, entry) key_item.setData(QtCore.Qt.ItemDataRole.UserRole+1, entry)
value_item.setData(QtCore.Qt.UserRole, alias) value_item.setData(QtCore.Qt.ItemDataRole.UserRole, alias)
value_item.setData(QtCore.Qt.UserRole+1, entry) value_item.setData(QtCore.Qt.ItemDataRole.UserRole+1, entry)
row = self.namespace_table.rowCount() row = self.namespace_table.rowCount()
self.namespace_table.setRowCount(row+1) self.namespace_table.setRowCount(row+1)
@ -241,5 +249,5 @@ class QNamespaceWidget(QtWidgets.QWidget, Ui_Form):
@QtCore.pyqtSlot(QtWidgets.QTableWidgetItem, name='on_namespace_table_itemDoubleClicked') @QtCore.pyqtSlot(QtWidgets.QTableWidgetItem, name='on_namespace_table_itemDoubleClicked')
def item_selected(self, item: QtWidgets.QTableWidgetItem): def item_selected(self, item: QtWidgets.QTableWidgetItem):
self.selected.emit(item.data(QtCore.Qt.UserRole)) self.selected.emit(item.data(QtCore.Qt.ItemDataRole.UserRole))
self.sendKey.emit(item.data(QtCore.Qt.UserRole+1)) self.sendKey.emit(item.data(QtCore.Qt.ItemDataRole.UserRole+1))