added tnmh; some bugfixes

This commit is contained in:
Dominik Demuth 2023-07-05 19:51:06 +02:00
parent 8de4a0cbd3
commit a310a78fb9
7 changed files with 131 additions and 140 deletions

View File

@ -472,7 +472,6 @@ class Ui_BaseWindow(object):
self.menuStuff.addAction(self.actionTetris)
self.menuStuff.addAction(self.actionMine)
self.menuDSC.addAction(self.actionTNMH_model)
self.menuDSC.addAction(self.actionTNMH)
self.menubar.addAction(self.menuFile.menuAction())
self.menubar.addAction(self.menuWindow.menuAction())
self.menubar.addAction(self.menuData.menuAction())
@ -640,7 +639,7 @@ class Ui_BaseWindow(object):
self.actionShow_error_log.setText(_translate("BaseWindow", "Show error log"))
self.actionCreate_starter.setText(_translate("BaseWindow", "Create starter.."))
self.actionAbout.setText(_translate("BaseWindow", "About..."))
self.actionTNMH_model.setText(_translate("BaseWindow", "Tg determination,,,"))
self.actionTNMH_model.setText(_translate("BaseWindow", "Tg , Hodge, TNMH,,,"))
self.actionBinning.setText(_translate("BaseWindow", "Binning..."))
self.actionTNMH.setText(_translate("BaseWindow", "TNMH..."))
from ..data.datawidget.datawidget import DataWidget

View File

@ -90,9 +90,6 @@ class Ui_Wizard(object):
self.checkBox_6.setChecked(True)
self.checkBox_6.setObjectName("checkBox_6")
self.gridLayout_4.addWidget(self.checkBox_6, 2, 0, 1, 1)
self.pushButton_4 = QtWidgets.QPushButton(self.wizardPage2)
self.pushButton_4.setObjectName("pushButton_4")
self.gridLayout_4.addWidget(self.pushButton_4, 2, 2, 1, 1)
self.new_graph_tau_check = QtWidgets.QCheckBox(self.wizardPage2)
self.new_graph_tau_check.setChecked(True)
self.new_graph_tau_check.setObjectName("new_graph_tau_check")
@ -106,6 +103,7 @@ class Ui_Wizard(object):
self.checkBox_5.setObjectName("checkBox_5")
self.gridLayout_4.addWidget(self.checkBox_5, 3, 0, 1, 1)
self.new_graph_tau_combo = QtWidgets.QComboBox(self.wizardPage2)
self.new_graph_tau_combo.setEnabled(False)
self.new_graph_tau_combo.setObjectName("new_graph_tau_combo")
self.gridLayout_4.addWidget(self.new_graph_tau_combo, 0, 2, 1, 1)
self.checkBox_4 = QtWidgets.QCheckBox(self.wizardPage2)
@ -116,6 +114,9 @@ class Ui_Wizard(object):
self.checkBox.setChecked(True)
self.checkBox.setObjectName("checkBox")
self.gridLayout_4.addWidget(self.checkBox, 0, 0, 1, 1)
self.pushButton_4 = QtWidgets.QPushButton(self.wizardPage2)
self.pushButton_4.setObjectName("pushButton_4")
self.gridLayout_4.addWidget(self.pushButton_4, 4, 1, 1, 2)
self.gridLayout_2.addLayout(self.gridLayout_4, 3, 0, 1, 2)
Wizard.addPage(self.wizardPage2)
self.wizardPage = QtWidgets.QWizardPage()
@ -128,31 +129,13 @@ class Ui_Wizard(object):
self.wizardPage.setObjectName("wizardPage")
self.gridLayout_6 = QtWidgets.QGridLayout(self.wizardPage)
self.gridLayout_6.setObjectName("gridLayout_6")
self.fit_tnhm_fitbutton_2 = QtWidgets.QPushButton(self.wizardPage)
self.fit_tnhm_fitbutton_2.setObjectName("fit_tnhm_fitbutton_2")
self.gridLayout_6.addWidget(self.fit_tnhm_fitbutton_2, 0, 0, 1, 2)
self.graphicsView_3 = PlotWidget(self.wizardPage)
self.graphicsView_3.setObjectName("graphicsView_3")
self.gridLayout_6.addWidget(self.graphicsView_3, 1, 0, 1, 1)
self.gridLayout_3 = QtWidgets.QGridLayout()
self.gridLayout_3.setObjectName("gridLayout_3")
self.tnmh_tg_combo_2 = QtWidgets.QComboBox(self.wizardPage)
self.tnmh_tg_combo_2.setObjectName("tnmh_tg_combo_2")
self.tnmh_tg_combo_2.addItem("")
self.tnmh_tg_combo_2.addItem("")
self.tnmh_tg_combo_2.addItem("")
self.tnmh_tg_combo_2.addItem("")
self.tnmh_tg_combo_2.addItem("")
self.gridLayout_3.addWidget(self.tnmh_tg_combo_2, 0, 1, 1, 1)
self.label_3 = QtWidgets.QLabel(self.wizardPage)
self.label_3.setObjectName("label_3")
self.gridLayout_3.addWidget(self.label_3, 0, 0, 1, 1)
spacerItem1 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
self.gridLayout_3.addItem(spacerItem1, 1, 0, 1, 1)
self.gridLayout_6.addLayout(self.gridLayout_3, 1, 1, 1, 1)
self.fit_tnhm_fitbutton = QtWidgets.QPushButton(self.wizardPage)
self.fit_tnhm_fitbutton.setObjectName("fit_tnhm_fitbutton")
self.gridLayout_6.addWidget(self.fit_tnhm_fitbutton, 0, 0, 1, 2)
self.treeWidget_2 = QtWidgets.QTreeWidget(self.wizardPage)
self.treeWidget_2.setObjectName("treeWidget_2")
self.treeWidget_2.headerItem().setText(0, "1")
self.treeWidget_2.header().setVisible(False)
self.gridLayout_6.addWidget(self.treeWidget_2, 2, 0, 1, 1)
self.gridLayout_5 = QtWidgets.QGridLayout()
self.gridLayout_5.setObjectName("gridLayout_5")
@ -161,20 +144,26 @@ class Ui_Wizard(object):
self.new_graph_tnmh_check_2.setObjectName("new_graph_tnmh_check_2")
self.gridLayout_5.addWidget(self.new_graph_tnmh_check_2, 1, 0, 1, 1)
self.checkBox_14 = QtWidgets.QCheckBox(self.wizardPage)
self.checkBox_14.setChecked(True)
self.checkBox_14.setObjectName("checkBox_14")
self.gridLayout_5.addWidget(self.checkBox_14, 0, 0, 1, 1)
self.pushButton_2 = QtWidgets.QPushButton(self.wizardPage)
self.pushButton_2.setObjectName("pushButton_2")
self.gridLayout_5.addWidget(self.pushButton_2, 2, 0, 1, 2)
self.checkBox_13 = QtWidgets.QCheckBox(self.wizardPage)
self.checkBox_13.setChecked(True)
self.checkBox_13.setObjectName("checkBox_13")
self.gridLayout_5.addWidget(self.checkBox_13, 0, 1, 1, 1)
self.new_graph_tnmh_combo_2 = QtWidgets.QComboBox(self.wizardPage)
self.new_graph_tnmh_combo_2.setEnabled(False)
self.new_graph_tnmh_combo_2.setObjectName("new_graph_tnmh_combo_2")
self.gridLayout_5.addWidget(self.new_graph_tnmh_combo_2, 1, 1, 1, 1)
spacerItem2 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
self.gridLayout_5.addItem(spacerItem2, 3, 0, 1, 1)
spacerItem1 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
self.gridLayout_5.addItem(spacerItem1, 3, 0, 1, 1)
self.gridLayout_6.addLayout(self.gridLayout_5, 2, 1, 1, 1)
self.graphicsView_3 = PlotWidget(self.wizardPage)
self.graphicsView_3.setObjectName("graphicsView_3")
self.gridLayout_6.addWidget(self.graphicsView_3, 1, 0, 1, 2)
Wizard.addPage(self.wizardPage)
self.retranslateUi(Wizard)
@ -191,20 +180,14 @@ class Ui_Wizard(object):
self.wizardPage2.setTitle(_translate("Wizard", "Hodge"))
self.toolButton.setText(_translate("Wizard", "Calculate Hodge"))
self.checkBox_6.setText(_translate("Wizard", "End"))
self.pushButton_4.setText(_translate("Wizard", "Export"))
self.new_graph_tau_check.setText(_translate("Wizard", "New graph"))
self.checkBox_7.setText(_translate("Wizard", "Fictive"))
self.checkBox_5.setText(_translate("Wizard", "Inflection"))
self.checkBox_4.setText(_translate("Wizard", "Midpoint"))
self.checkBox.setText(_translate("Wizard", "Onset"))
self.pushButton_4.setText(_translate("Wizard", "Export"))
self.wizardPage.setTitle(_translate("Wizard", "TNMH"))
self.fit_tnhm_fitbutton_2.setText(_translate("Wizard", "Fit TNMH model"))
self.tnmh_tg_combo_2.setItemText(0, _translate("Wizard", "Fictive"))
self.tnmh_tg_combo_2.setItemText(1, _translate("Wizard", "Onset"))
self.tnmh_tg_combo_2.setItemText(2, _translate("Wizard", "Midpoint"))
self.tnmh_tg_combo_2.setItemText(3, _translate("Wizard", "End"))
self.tnmh_tg_combo_2.setItemText(4, _translate("Wizard", "Inflection"))
self.label_3.setText(_translate("Wizard", "Tg for TNMH"))
self.fit_tnhm_fitbutton.setText(_translate("Wizard", "Fit TNMH model"))
self.new_graph_tnmh_check_2.setText(_translate("Wizard", "New graph"))
self.checkBox_14.setText(_translate("Wizard", "Export fit"))
self.pushButton_2.setText(_translate("Wizard", "Export"))

View File

@ -87,8 +87,8 @@ class TgCalculator(QtWidgets.QWizard, Ui_Wizard):
self.add_sets()
self.new_graph_tau_combo.setEnabled(False)
self.new_graph_tau_check.stateChanged.connect(lambda state: self.new_graph_tau_combo.setEnabled(not bool(state)))
self.new_graph_tau_check.stateChanged.connect(lambda state: self.new_graph_tnmh_combo_2.setEnabled(not bool(state)))
def __call__(self):
self.clear()
@ -119,6 +119,7 @@ class TgCalculator(QtWidgets.QWizard, Ui_Wizard):
self.new_graph_tau_combo.clear()
for graphs in self._management.graphs.list():
self.new_graph_tau_combo.addItem(graphs[1], userData=graphs[0])
self.new_graph_tnmh_combo_2.addItem(graphs[1], userData=graphs[0])
min_x = 10_000_000
max_x = -10_000_000
@ -157,11 +158,11 @@ class TgCalculator(QtWidgets.QWizard, Ui_Wizard):
self.dsc_plot.addItem(tg_plot)
fictive_cp = PlotItem(pen=mkPen(c.rgb()))
# self.graphicsView_2.addItem(fictive_cp)
self.graphicsView_3.addItem(fictive_cp)
tnmh_fit = PlotItem()
tnmh_fit.set_line(style=2, color=c)
# self.graphicsView_2.addItem(tnmh_fit)
self.graphicsView_3.addItem(tnmh_fit)
self._plots[key] = (data_plot, tg_plot, glass, liquid, tangent, fictive_cp, tnmh_fit)
self._tg_value[key] = {
@ -251,29 +252,16 @@ class TgCalculator(QtWidgets.QWizard, Ui_Wizard):
for val in plot:
val.setVisible(is_checked)
@QtCore.pyqtSlot(name='on_pushButton_2_clicked')
def get_fictive(self):
baselines = tuple(lim.getRegion() for lim in self.limits)
if baselines[0][0] > baselines[1][0]:
baselines = baselines[1], baselines[0]
def get_fictive(self, key, baselines):
plot = self._plots[key]
data, _ = self._dsc[key]
for idx in range(self.listWidget.count()):
item = self.listWidget.item(idx)
if item.checkState() == QtCore.Qt.Unchecked:
continue
cp, tg = data.get_fictive_cp(*baselines)
key = item.data(QtCore.Qt.UserRole)
plot = self._plots[key]
data, _ = self._dsc[key]
plot[5].setData(cp.x, cp.y)
self._dsc[key] = (data, cp)
cp, tg = data.get_fictive_cp(*baselines)
plot[5].setData(cp.x, cp.y)
self._dsc[key] = (data, cp)
self._tg_value[key]['fictive'] = (tg, 0)
self._update_tg_plots()
return cp
@QtCore.pyqtSlot(name='on_fit_tnhm_fitbutton_clicked')
def make_tnmh(self):
@ -281,22 +269,62 @@ class TgCalculator(QtWidgets.QWizard, Ui_Wizard):
if baselines[0][0] > baselines[1][0]:
baselines = baselines[1], baselines[0]
self.treeWidget_2.clear()
for idx in range(self.listWidget.count()):
item = self.listWidget.item(idx)
if item.checkState() == QtCore.Qt.Unchecked:
continue
key = item.data(QtCore.Qt.UserRole)
plot = self._plots[key]
_, data = self._dsc[key]
if data is None:
continue
data = self.get_fictive(key, baselines)
res = data.calculate_tnmh([60, 0.5, 1, 2e5], *baselines, return_fictive=False)
self._fit[key] = res
plot = self._plots[key]
plot[-1].setData(res.x, res.y)
for idx in range(self.listWidget.count()):
item = self.listWidget.item(idx)
tree_item = QtWidgets.QTreeWidgetItem([item.text()])
values = self._fit.get(item.data(QtCore.Qt.UserRole))
if values is not None:
child_item = QtWidgets.QTreeWidgetItem([values.parameter_string()])
tree_item.addChild(child_item)
self.treeWidget_2.addTopLevelItem(tree_item)
@QtCore.pyqtSlot(name='on_pushButton_2_clicked')
def export_tnmh(self):
ret_dic = {}
for idx in range(self.listWidget.count()):
item = self.listWidget.item(idx)
if item.checkState() == QtCore.Qt.Unchecked:
continue
key = item.data(QtCore.Qt.UserRole)
if self.checkBox_13.isChecked():
_, cp = self._dsc[key]
else:
cp = None
if self.checkBox_14.isChecked():
line = self._fit[key]
else:
line = None
ret_dic[key] = (cp, line)
if self.new_graph_tnmh_check_2.isChecked():
ret_dic['graph'] = ''
else:
ret_dic['graph'] = self.new_graph_tnmh_combo_2.currentData()
self.newData.emit(ret_dic, 'tnmh')
@QtCore.pyqtSlot(name='on_toolButton_clicked')
def hodge(self):
for tg_type, (plot, data, fitplots, fit) in self._hodge.items():
@ -334,15 +362,14 @@ class TgCalculator(QtWidgets.QWizard, Ui_Wizard):
for cb in (self.checkBox, self.checkBox_4, self.checkBox_6, self.checkBox_5, self.checkBox_7):
if cb.isChecked():
item = cb.text().lower()
v = self._hodge.get(item)
ret_dic2[item] = v[1]
data = self._hodge.get(item)
if data[1] is not None:
ret_dic2[item] = data[1]
if self.new_graph_tau_check.isChecked():
ret_dic2['graph'] = self.new_graph_tau_combo.currentData()
else:
ret_dic2['graph'] = ''
print(ret_dic2)
else:
ret_dic2['graph'] = self.new_graph_tau_combo.currentData()
self.newData.emit(ret_dic2, 'hodge')

View File

@ -800,6 +800,25 @@ class UpperManagement(QtCore.QObject):
set_id_list.append(self.add(v))
self.newData.emit(set_id_list, graph_id)
elif dtype == 'tnmh':
set_id_list = []
graph_id = dic1.pop('graph')
for k, (tg, fit) in dic1.items():
p: ExperimentContainer = self[k]
col = p.plot_real.linecolor
tg_data_id = []
if tg is not None:
set_id_list.append(self.add(tg, color=col))
set_id = self.add(fit, color=col)
self[set_id].setLine(style=LineStyle.Dashed)
self[set_id].setSymbol(symbol=SymbolStyle.No)
set_id_list.append(set_id)
self.newData.emit(set_id_list, graph_id)
@QtCore.pyqtSlot(int, dict)
def smooth_data(self, npoints, param_kwargs):
_active = self.graphs[self.current_graph].active

View File

@ -228,7 +228,7 @@ class FitResult(Points):
print(' #data :', self.nobs)
print(' #var :', self.nvar)
print('\nParameter')
print(self._parameter_string())
print(self.parameter_string())
if statistics:
print('Statistics')
@ -240,7 +240,7 @@ class FitResult(Points):
print(self._correlation_string())
print()
def _parameter_string(self):
def parameter_string(self):
ret_val = ''
for pval in self.parameter.values():

View File

@ -332,7 +332,6 @@
<string>DSC</string>
</property>
<addaction name="actionTNMH_model"/>
<addaction name="actionTNMH"/>
</widget>
<addaction name="menuFile"/>
<addaction name="menuWindow"/>
@ -1033,7 +1032,7 @@
</action>
<action name="actionTNMH_model">
<property name="text">
<string>Tg determination,,,</string>
<string>Tg , Hodge, TNMH,,,</string>
</property>
</action>
<action name="actionBinning">

View File

@ -154,13 +154,6 @@
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="pushButton_4">
<property name="text">
<string>Export</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="new_graph_tau_check">
<property name="text">
@ -192,7 +185,11 @@
</widget>
</item>
<item row="0" column="2">
<widget class="QComboBox" name="new_graph_tau_combo"/>
<widget class="QComboBox" name="new_graph_tau_combo">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="checkBox_4">
@ -214,6 +211,13 @@
</property>
</widget>
</item>
<item row="4" column="1" colspan="2">
<widget class="QPushButton" name="pushButton_4">
<property name="text">
<string>Export</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
@ -233,70 +237,17 @@
</property>
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="0" colspan="2">
<widget class="QPushButton" name="fit_tnhm_fitbutton_2">
<widget class="QPushButton" name="fit_tnhm_fitbutton">
<property name="text">
<string>Fit TNMH model</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="PlotWidget" name="graphicsView_3"/>
</item>
<item row="1" column="1">
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="1">
<widget class="QComboBox" name="tnmh_tg_combo_2">
<item>
<property name="text">
<string>Fictive</string>
</property>
</item>
<item>
<property name="text">
<string>Onset</string>
</property>
</item>
<item>
<property name="text">
<string>Midpoint</string>
</property>
</item>
<item>
<property name="text">
<string>End</string>
</property>
</item>
<item>
<property name="text">
<string>Inflection</string>
</property>
</item>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Tg for TNMH</string>
</property>
</widget>
</item>
<item row="1" column="0">
<spacer name="verticalSpacer_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>
</layout>
</item>
<item row="2" column="0">
<widget class="QTreeWidget" name="treeWidget_2">
<attribute name="headerVisible">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string notr="true">1</string>
@ -321,6 +272,9 @@
<property name="text">
<string>Export fit</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
@ -335,10 +289,17 @@
<property name="text">
<string>Export dTf / dT</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="new_graph_tnmh_combo_2"/>
<widget class="QComboBox" name="new_graph_tnmh_combo_2">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<spacer name="verticalSpacer_4">
@ -355,6 +316,9 @@
</item>
</layout>
</item>
<item row="1" column="0" colspan="2">
<widget class="PlotWidget" name="graphicsView_3"/>
</item>
</layout>
</widget>
</widget>