forked from IPKM/nmreval
split ficitive cp and tnmh
This commit is contained in:
parent
25f7ff5616
commit
9f6d4e0d0c
@ -14,9 +14,39 @@ from PyQt5 import QtCore, QtGui, QtWidgets
|
|||||||
class Ui_Dialog(object):
|
class Ui_Dialog(object):
|
||||||
def setupUi(self, Dialog):
|
def setupUi(self, Dialog):
|
||||||
Dialog.setObjectName("Dialog")
|
Dialog.setObjectName("Dialog")
|
||||||
Dialog.resize(842, 683)
|
Dialog.resize(1042, 683)
|
||||||
self.gridLayout = QtWidgets.QGridLayout(Dialog)
|
self.gridLayout = QtWidgets.QGridLayout(Dialog)
|
||||||
self.gridLayout.setObjectName("gridLayout")
|
self.gridLayout.setObjectName("gridLayout")
|
||||||
|
self.verticalLayout_2 = QtWidgets.QVBoxLayout()
|
||||||
|
self.verticalLayout_2.setObjectName("verticalLayout_2")
|
||||||
|
self.label = QtWidgets.QLabel(Dialog)
|
||||||
|
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Maximum)
|
||||||
|
sizePolicy.setHorizontalStretch(0)
|
||||||
|
sizePolicy.setVerticalStretch(0)
|
||||||
|
sizePolicy.setHeightForWidth(self.label.sizePolicy().hasHeightForWidth())
|
||||||
|
self.label.setSizePolicy(sizePolicy)
|
||||||
|
self.label.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop)
|
||||||
|
self.label.setObjectName("label")
|
||||||
|
self.verticalLayout_2.addWidget(self.label)
|
||||||
|
self.label_3 = QtWidgets.QLabel(Dialog)
|
||||||
|
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Maximum)
|
||||||
|
sizePolicy.setHorizontalStretch(0)
|
||||||
|
sizePolicy.setVerticalStretch(0)
|
||||||
|
sizePolicy.setHeightForWidth(self.label_3.sizePolicy().hasHeightForWidth())
|
||||||
|
self.label_3.setSizePolicy(sizePolicy)
|
||||||
|
self.label_3.setText("")
|
||||||
|
self.label_3.setObjectName("label_3")
|
||||||
|
self.verticalLayout_2.addWidget(self.label_3)
|
||||||
|
self.label_4 = QtWidgets.QLabel(Dialog)
|
||||||
|
self.label_4.setObjectName("label_4")
|
||||||
|
self.verticalLayout_2.addWidget(self.label_4)
|
||||||
|
self.label_5 = QtWidgets.QLabel(Dialog)
|
||||||
|
self.label_5.setText("")
|
||||||
|
self.label_5.setObjectName("label_5")
|
||||||
|
self.verticalLayout_2.addWidget(self.label_5)
|
||||||
|
spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
|
||||||
|
self.verticalLayout_2.addItem(spacerItem)
|
||||||
|
self.gridLayout.addLayout(self.verticalLayout_2, 0, 3, 2, 1)
|
||||||
self.graphicsView = PlotWidget(Dialog)
|
self.graphicsView = PlotWidget(Dialog)
|
||||||
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.MinimumExpanding)
|
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.MinimumExpanding)
|
||||||
sizePolicy.setHorizontalStretch(0)
|
sizePolicy.setHorizontalStretch(0)
|
||||||
@ -28,20 +58,6 @@ class Ui_Dialog(object):
|
|||||||
self.graphicsView_2 = PlotWidget(Dialog)
|
self.graphicsView_2 = PlotWidget(Dialog)
|
||||||
self.graphicsView_2.setObjectName("graphicsView_2")
|
self.graphicsView_2.setObjectName("graphicsView_2")
|
||||||
self.gridLayout.addWidget(self.graphicsView_2, 1, 2, 1, 1)
|
self.gridLayout.addWidget(self.graphicsView_2, 1, 2, 1, 1)
|
||||||
self.buttonBox = QtWidgets.QDialogButtonBox(Dialog)
|
|
||||||
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
|
|
||||||
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
|
|
||||||
self.buttonBox.setObjectName("buttonBox")
|
|
||||||
self.gridLayout.addWidget(self.buttonBox, 3, 2, 1, 1)
|
|
||||||
self.label = QtWidgets.QLabel(Dialog)
|
|
||||||
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Preferred)
|
|
||||||
sizePolicy.setHorizontalStretch(0)
|
|
||||||
sizePolicy.setVerticalStretch(0)
|
|
||||||
sizePolicy.setHeightForWidth(self.label.sizePolicy().hasHeightForWidth())
|
|
||||||
self.label.setSizePolicy(sizePolicy)
|
|
||||||
self.label.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop)
|
|
||||||
self.label.setObjectName("label")
|
|
||||||
self.gridLayout.addWidget(self.label, 2, 2, 1, 1)
|
|
||||||
self.verticalLayout = QtWidgets.QVBoxLayout()
|
self.verticalLayout = QtWidgets.QVBoxLayout()
|
||||||
self.verticalLayout.setObjectName("verticalLayout")
|
self.verticalLayout.setObjectName("verticalLayout")
|
||||||
self.listWidget = QtWidgets.QListWidget(Dialog)
|
self.listWidget = QtWidgets.QListWidget(Dialog)
|
||||||
@ -76,6 +92,11 @@ class Ui_Dialog(object):
|
|||||||
self.pushButton_3.setObjectName("pushButton_3")
|
self.pushButton_3.setObjectName("pushButton_3")
|
||||||
self.verticalLayout.addWidget(self.pushButton_3)
|
self.verticalLayout.addWidget(self.pushButton_3)
|
||||||
self.gridLayout.addLayout(self.verticalLayout, 0, 0, 3, 1)
|
self.gridLayout.addLayout(self.verticalLayout, 0, 0, 3, 1)
|
||||||
|
self.buttonBox = QtWidgets.QDialogButtonBox(Dialog)
|
||||||
|
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
|
||||||
|
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
|
||||||
|
self.buttonBox.setObjectName("buttonBox")
|
||||||
|
self.gridLayout.addWidget(self.buttonBox, 3, 2, 1, 2)
|
||||||
|
|
||||||
self.retranslateUi(Dialog)
|
self.retranslateUi(Dialog)
|
||||||
self.buttonBox.accepted.connect(Dialog.accept) # type: ignore
|
self.buttonBox.accepted.connect(Dialog.accept) # type: ignore
|
||||||
@ -85,7 +106,8 @@ class Ui_Dialog(object):
|
|||||||
def retranslateUi(self, Dialog):
|
def retranslateUi(self, Dialog):
|
||||||
_translate = QtCore.QCoreApplication.translate
|
_translate = QtCore.QCoreApplication.translate
|
||||||
Dialog.setWindowTitle(_translate("Dialog", "SImba, everything the light touches is our kingdom"))
|
Dialog.setWindowTitle(_translate("Dialog", "SImba, everything the light touches is our kingdom"))
|
||||||
self.label.setText(_translate("Dialog", "sdff"))
|
self.label.setText(_translate("Dialog", "<html><head/><body><p><span style=\" font-weight:600;\">Tg values:</span></p></body></html>"))
|
||||||
|
self.label_4.setText(_translate("Dialog", "<html><head/><body><p><span style=\" font-weight:600;\">TNMH parameter:</span></p></body></html>"))
|
||||||
self.pushButton.setText(_translate("Dialog", "Calculate Tg"))
|
self.pushButton.setText(_translate("Dialog", "Calculate Tg"))
|
||||||
self.pushButton_2.setText(_translate("Dialog", "Fictive Cp"))
|
self.pushButton_2.setText(_translate("Dialog", "Fictive Cp"))
|
||||||
self.label_2.setText(_translate("Dialog", "Tg for TNMH"))
|
self.label_2.setText(_translate("Dialog", "Tg for TNMH"))
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
from itertools import cycle
|
from itertools import cycle
|
||||||
|
|
||||||
from numpy import array
|
from numpy import array, nan
|
||||||
from pyqtgraph import mkPen, mkBrush
|
from pyqtgraph import mkPen, mkBrush
|
||||||
|
|
||||||
from nmreval.lib.colors import Tab10
|
from nmreval.lib.colors import Tab10
|
||||||
@ -22,6 +22,7 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog):
|
|||||||
self._dsc = {}
|
self._dsc = {}
|
||||||
self._plots = {}
|
self._plots = {}
|
||||||
self._tg_value = {}
|
self._tg_value = {}
|
||||||
|
self._fit = {}
|
||||||
|
|
||||||
self.limits = RegionItem(), RegionItem()
|
self.limits = RegionItem(), RegionItem()
|
||||||
for lim in self.limits:
|
for lim in self.limits:
|
||||||
@ -43,6 +44,11 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog):
|
|||||||
self.graphicsView.removeItem(val)
|
self.graphicsView.removeItem(val)
|
||||||
self.graphicsView_2.removeItem(val)
|
self.graphicsView_2.removeItem(val)
|
||||||
|
|
||||||
|
self._dsc = {}
|
||||||
|
self._plots = {}
|
||||||
|
self._tg_value = {}
|
||||||
|
self._fit = {}
|
||||||
|
|
||||||
def add_sets(self):
|
def add_sets(self):
|
||||||
min_x = 10_000_000
|
min_x = 10_000_000
|
||||||
max_x = -10_000_000
|
max_x = -10_000_000
|
||||||
@ -60,7 +66,7 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog):
|
|||||||
item.setForeground(mkBrush(c.rgb()))
|
item.setForeground(mkBrush(c.rgb()))
|
||||||
self.listWidget.addItem(item)
|
self.listWidget.addItem(item)
|
||||||
|
|
||||||
self._dsc[key] = data
|
self._dsc[key] = (data, None)
|
||||||
|
|
||||||
data_plot = PlotItem(x=data.x, y=data.y, pen=mkPen(c.rgb()))
|
data_plot = PlotItem(x=data.x, y=data.y, pen=mkPen(c.rgb()))
|
||||||
self.graphicsView.addItem(data_plot)
|
self.graphicsView.addItem(data_plot)
|
||||||
@ -88,6 +94,7 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog):
|
|||||||
self.graphicsView_2.addItem(tnmh_fit)
|
self.graphicsView_2.addItem(tnmh_fit)
|
||||||
|
|
||||||
self._plots[key] = (data_plot, tg_plot, glass, liquid, tangent, fictive_cp, tnmh_fit)
|
self._plots[key] = (data_plot, tg_plot, glass, liquid, tangent, fictive_cp, tnmh_fit)
|
||||||
|
self._tg_value[key] = {'onset': (nan, nan), 'mid': (nan, nan), 'end': (nan, nan), 'inflection': (nan, nan), 'fictive': (nan, nan)}
|
||||||
|
|
||||||
if self._limitless:
|
if self._limitless:
|
||||||
dist = max_x - min_x
|
dist = max_x - min_x
|
||||||
@ -108,22 +115,27 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog):
|
|||||||
|
|
||||||
key = item.data(QtCore.Qt.UserRole)
|
key = item.data(QtCore.Qt.UserRole)
|
||||||
plot = self._plots[key]
|
plot = self._plots[key]
|
||||||
data = self._dsc[key]
|
data, _ = self._dsc[key]
|
||||||
|
|
||||||
tg_results, glass, liquid, tangent = data.glass_transition(*baselines)
|
tg_results, glass, liquid, tangent = data.glass_transition(*baselines)
|
||||||
|
|
||||||
for i, line in enumerate((glass, liquid, tangent)):
|
for i, line in enumerate((glass, liquid, tangent)):
|
||||||
plot[i+2].setData(x=line[:, 0], y=line[:, 1])
|
plot[i+2].setData(x=line[:, 0], y=line[:, 1])
|
||||||
|
|
||||||
plot[1].setData(array(list(tg_results.values())))
|
self._tg_value[key].update(tg_results)
|
||||||
self._tg_value[key] = tg_results
|
|
||||||
|
plot[1].setData(array(list(self._tg_value[key].values())))
|
||||||
|
|
||||||
def show_tg_values(self, item):
|
def show_tg_values(self, item):
|
||||||
values = self._tg_value.get(item.data(QtCore.Qt.UserRole))
|
values = self._tg_value.get(item.data(QtCore.Qt.UserRole))
|
||||||
|
|
||||||
if values is not None:
|
if values is not None:
|
||||||
label = '\n'.join((f'{name.capitalize()}: {pos[0]:.2f} K' for name, pos in values.items()))
|
label = '\n'.join((f'{name.capitalize()}: {pos[0]:.2f} K' for name, pos in values.items()))
|
||||||
self.label.setText(label)
|
self.label_3.setText(label)
|
||||||
|
|
||||||
|
fit = self._fit.get(item.data(QtCore.Qt.UserRole))
|
||||||
|
if fit is not None:
|
||||||
|
self.label_5.setText(fit._parameter_string())
|
||||||
|
|
||||||
@QtCore.pyqtSlot(QtWidgets.QListWidgetItem, name='on_listWidget_itemChanged')
|
@QtCore.pyqtSlot(QtWidgets.QListWidgetItem, name='on_listWidget_itemChanged')
|
||||||
def change_visibility(self, item: QtWidgets.QListWidgetItem):
|
def change_visibility(self, item: QtWidgets.QListWidgetItem):
|
||||||
@ -145,18 +157,37 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog):
|
|||||||
|
|
||||||
key = item.data(QtCore.Qt.UserRole)
|
key = item.data(QtCore.Qt.UserRole)
|
||||||
plot = self._plots[key]
|
plot = self._plots[key]
|
||||||
data = self._dsc[key]
|
data, _ = self._dsc[key]
|
||||||
|
|
||||||
cp, tg = data.get_fictive_cp(*baselines)
|
cp, tg = data.get_fictive_cp(*baselines)
|
||||||
|
|
||||||
plot[5].setData(cp.x, cp.y)
|
plot[5].setData(cp.x, cp.y)
|
||||||
|
self._dsc[key] = (data, cp)
|
||||||
|
|
||||||
self._tg_value[key]['fictive'] = (tg, 0)
|
self._tg_value[key]['fictive'] = (tg, 0)
|
||||||
|
|
||||||
plot[1].setData(array(list(self._tg_value[key].values())))
|
plot[1].setData(array(list(self._tg_value[key].values())))
|
||||||
|
|
||||||
res = cp.calculate_tnmh([60, 0.5, 1, 2e5], *baselines, return_fictive=False)
|
@QtCore.pyqtSlot(name='on_pushButton_3_clicked')
|
||||||
print(res.pprint())
|
def make_tnmh(self):
|
||||||
|
baselines = tuple(lim.getRegion() for lim in self.limits)
|
||||||
|
if baselines[0][0] > baselines[1][0]:
|
||||||
|
baselines = baselines[1], baselines[0]
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
res = data.calculate_tnmh([60, 0.5, 1, 2e5], *baselines, return_fictive=False)
|
||||||
|
self._fit[key] = res
|
||||||
plot[-1].setData(res.x, res.y)
|
plot[-1].setData(res.x, res.y)
|
||||||
|
|
||||||
def close(self) -> bool:
|
def close(self) -> bool:
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>842</width>
|
<width>1042</width>
|
||||||
<height>683</height>
|
<height>683</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -14,6 +14,66 @@
|
|||||||
<string>SImba, everything the light touches is our kingdom</string>
|
<string>SImba, everything the light touches is our kingdom</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="0" column="3" rowspan="2">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string><html><head/><body><p><span style=" font-weight:600;">Tg values:</span></p></body></html></string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_4">
|
||||||
|
<property name="text">
|
||||||
|
<string><html><head/><body><p><span style=" font-weight:600;">TNMH parameter:</span></p></body></html></string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_5">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<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>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
<item row="0" column="2">
|
<item row="0" column="2">
|
||||||
<widget class="PlotWidget" name="graphicsView">
|
<widget class="PlotWidget" name="graphicsView">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@ -27,32 +87,6 @@
|
|||||||
<item row="1" column="2">
|
<item row="1" column="2">
|
||||||
<widget class="PlotWidget" name="graphicsView_2"/>
|
<widget class="PlotWidget" name="graphicsView_2"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="2">
|
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="standardButtons">
|
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="2">
|
|
||||||
<widget class="QLabel" name="label">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>sdff</string>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0" rowspan="3">
|
<item row="0" column="0" rowspan="3">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
@ -128,6 +162,16 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="3" column="2" colspan="2">
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
|
Loading…
Reference in New Issue
Block a user