From ac4a4d3b8ee41ce1153b5c742983279ce31efe03 Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Mon, 24 Apr 2023 19:24:23 +0200 Subject: [PATCH] DSC: remove non-finite values due mismatch in beginnings of sample and empty --- src/gui_qt/io/dscreader.py | 6 +++++- src/nmreval/io/dsc.py | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/gui_qt/io/dscreader.py b/src/gui_qt/io/dscreader.py index 33f7938..c9fb6a3 100644 --- a/src/gui_qt/io/dscreader.py +++ b/src/gui_qt/io/dscreader.py @@ -195,7 +195,11 @@ class QDSCReader(QtWidgets.QDialog, Ui_Dialog): @QtCore.pyqtSlot(QtWidgets.QAbstractButton, name='on_buttonGroup_buttonClicked') @QtCore.pyqtSlot(int, name='on_cp_checkBox_stateChanged') def update_plots(self, _=None): - sample_data, raw_sample, empty_data, drift_value, slope, calib_x, calib_y, regions = self.get_data() + res = self.get_data() + if res is None: + return + + sample_data, raw_sample, empty_data, drift_value, slope, calib_x, calib_y, regions = res self.raw_sample.setData(x=raw_sample[0], y=raw_sample[1]) self.drift_sample.setData(x=drift_value[0], y=drift_value[1]) diff --git a/src/nmreval/io/dsc.py b/src/nmreval/io/dsc.py index 797714c..84c024f 100644 --- a/src/nmreval/io/dsc.py +++ b/src/nmreval/io/dsc.py @@ -284,6 +284,7 @@ class DSCCalibrator: sample_data[1] -= empty_y drift_value = sample_data.copy()[(2, 1), :] + sample_data = sample_data[:, np.isfinite(sample_data[1, :])] mean_isotherms = [] for offset in [-1, 1]: @@ -311,6 +312,8 @@ class DSCCalibrator: # calculate mean slope of heat flow from points in the beginning offset = sample_data[1, 200] grad = np.gradient(sample_data[1, :], sample_data[2, :]) + + grad = grad[~np.isnan(grad)] m = grad[(grad < grad.mean()+grad.std()/5)*(grad > grad.mean()-grad.std()/5)].mean() sample_data[1] -= m * (sample_data[2] - sample_data[2, 200]) + offset