1
0
forked from IPKM/nmreval

plot DSC data and baselines

This commit is contained in:
Dominik Demuth 2023-05-30 17:36:44 +02:00
parent 30750cc4ed
commit a8a7e75501
2 changed files with 47 additions and 2 deletions

View File

@ -71,6 +71,12 @@ class Ui_Dialog(object):
self.lineEdit_4.setSizePolicy(sizePolicy)
self.lineEdit_4.setObjectName("lineEdit_4")
self.formLayout.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.lineEdit_4)
self.pushButton = QtWidgets.QPushButton(Dialog)
self.pushButton.setObjectName("pushButton")
self.formLayout.setWidget(4, QtWidgets.QFormLayout.SpanningRole, self.pushButton)
self.listWidget_2 = QtWidgets.QListWidget(Dialog)
self.listWidget_2.setObjectName("listWidget_2")
self.formLayout.setWidget(5, QtWidgets.QFormLayout.SpanningRole, self.listWidget_2)
self.gridLayout.addLayout(self.formLayout, 0, 1, 1, 1)
self.buttonBox = QtWidgets.QDialogButtonBox(Dialog)
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
@ -98,4 +104,5 @@ class Ui_Dialog(object):
self.label_2.setText(_translate("Dialog", "β"))
self.label_3.setText(_translate("Dialog", "ΔH/R / K"))
self.label_4.setText(_translate("Dialog", "x"))
self.pushButton.setText(_translate("Dialog", "PushButton"))
from pyqtgraph import PlotWidget

View File

@ -13,6 +13,8 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog):
self._management = management
self._plots = {}
self._tg_baselines = {}
self.dsc = []
self.limits = RegionItem(), RegionItem()
for lim in self.limits:
@ -26,18 +28,54 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog):
# s.valuesChanged.connect(self.management.shift_scale)
def clear(self):
self.dsc = []
self.listWidget.clear()
for k, v in self._plots.items():
for v in self._plots.values():
self.graphicsView.removeItem(v)
self._plots = {}
for v in self._tg_baselines.values():
self.graphicsView.removeItem(v)
self._tg_baselines = {}
def add_sets(self):
for key, name in self._management.active_sets:
data = self._management.data[key]
if not isinstance(data.data, DSC):
if isinstance(data.data, DSC):
self.dsc.append(data)
else:
continue
item = QtWidgets.QListWidgetItem(name)
item.setData(QtCore.Qt.UserRole, key)
self.listWidget.addItem(item)
plot = PlotItem(x=data.x, y=data.y)
self.graphicsView.addItem(plot)
self._plots[key] = plot
@QtCore.pyqtSlot(name='on_pushButton_clicked')
def calc_tg(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()):
key = self.listWidget.item(idx).data(QtCore.Qt.UserRole)
tg_results, glass, liquid, tangent = self._management[key].data.glass_transition(*baselines)
lines = []
for line in (glass, liquid, tangent):
plt = PlotItem(line[:, 0], line[:, 1])
self.graphicsView.addItem(plt)
lines.append(plt)
self._tg_baselines[key] = lines
tg_plot = PlotItem(*zip((i for i in tg_results.values())))
self.graphicsView.addItem(tg_plot)
def close(self) -> bool:
self.clear()
return super().close()