split ficitive cp and tnmh
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
from itertools import cycle
|
||||
|
||||
from numpy import array
|
||||
from numpy import array, nan
|
||||
from pyqtgraph import mkPen, mkBrush
|
||||
|
||||
from nmreval.lib.colors import Tab10
|
||||
@ -22,6 +22,7 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog):
|
||||
self._dsc = {}
|
||||
self._plots = {}
|
||||
self._tg_value = {}
|
||||
self._fit = {}
|
||||
|
||||
self.limits = RegionItem(), RegionItem()
|
||||
for lim in self.limits:
|
||||
@ -43,6 +44,11 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog):
|
||||
self.graphicsView.removeItem(val)
|
||||
self.graphicsView_2.removeItem(val)
|
||||
|
||||
self._dsc = {}
|
||||
self._plots = {}
|
||||
self._tg_value = {}
|
||||
self._fit = {}
|
||||
|
||||
def add_sets(self):
|
||||
min_x = 10_000_000
|
||||
max_x = -10_000_000
|
||||
@ -60,7 +66,7 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog):
|
||||
item.setForeground(mkBrush(c.rgb()))
|
||||
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()))
|
||||
self.graphicsView.addItem(data_plot)
|
||||
@ -88,6 +94,7 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog):
|
||||
self.graphicsView_2.addItem(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:
|
||||
dist = max_x - min_x
|
||||
@ -108,22 +115,27 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog):
|
||||
|
||||
key = item.data(QtCore.Qt.UserRole)
|
||||
plot = self._plots[key]
|
||||
data = self._dsc[key]
|
||||
data, _ = self._dsc[key]
|
||||
|
||||
tg_results, glass, liquid, tangent = data.glass_transition(*baselines)
|
||||
|
||||
for i, line in enumerate((glass, liquid, tangent)):
|
||||
plot[i+2].setData(x=line[:, 0], y=line[:, 1])
|
||||
|
||||
plot[1].setData(array(list(tg_results.values())))
|
||||
self._tg_value[key] = tg_results
|
||||
self._tg_value[key].update(tg_results)
|
||||
|
||||
plot[1].setData(array(list(self._tg_value[key].values())))
|
||||
|
||||
def show_tg_values(self, item):
|
||||
values = self._tg_value.get(item.data(QtCore.Qt.UserRole))
|
||||
|
||||
if values is not None:
|
||||
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')
|
||||
def change_visibility(self, item: QtWidgets.QListWidgetItem):
|
||||
@ -145,18 +157,37 @@ class TgCalculator(QtWidgets.QDialog, Ui_Dialog):
|
||||
|
||||
key = item.data(QtCore.Qt.UserRole)
|
||||
plot = self._plots[key]
|
||||
data = self._dsc[key]
|
||||
data, _ = self._dsc[key]
|
||||
|
||||
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)
|
||||
|
||||
plot[1].setData(array(list(self._tg_value[key].values())))
|
||||
|
||||
res = cp.calculate_tnmh([60, 0.5, 1, 2e5], *baselines, return_fictive=False)
|
||||
print(res.pprint())
|
||||
@QtCore.pyqtSlot(name='on_pushButton_3_clicked')
|
||||
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)
|
||||
|
||||
def close(self) -> bool:
|
||||
|
Reference in New Issue
Block a user