diff --git a/app.py b/app.py
index 38ba1d2..861ce5c 100644
--- a/app.py
+++ b/app.py
@@ -94,6 +94,7 @@ class AppWindow(QtWidgets.QMainWindow, Ui_MainWindow):
self.spin_end_time.setDisabled(True)
self.check_custom_end.stateChanged.connect(set_end_time)
+
# Sync up peak detection settings between input locations
self.spin_min_peakheight.valueChanged.connect(lambda x: self.spin_min_peakheight_2.setValue(x))
self.spin_min_peakheight_2.valueChanged.connect(lambda x: self.spin_min_peakheight.setValue(x))
@@ -202,6 +203,7 @@ class AppWindow(QtWidgets.QMainWindow, Ui_MainWindow):
self.spin_shift_over_fit.value(),
self.check_advanced_peak_detection.isChecked()
)
+ mem['shift_over_fit'] = self.spin_shift_over_fit.value()
# print(mem['fit_equations'])
self.peak_fit_viewer.plot()
self.graph_tabs.setCurrentIndex(4)
diff --git a/crds_calc.py b/crds_calc.py
index 179c30d..d9d1298 100644
--- a/crds_calc.py
+++ b/crds_calc.py
@@ -267,8 +267,6 @@ def fit_peaks(
use_advanced: bool
):
- print(f'{use_advanced=}')
-
"""
Returns
-------
@@ -277,8 +275,10 @@ def fit_peaks(
params_guess = (0.0000, a, y0, tau)
equations = []
+ overlayed_peak_indices = []
for peaks_cut in isolated_peaks:
- row = []
+ equation_row = []
+ overlayed_peak_row = []
for peak_data in peaks_cut:
x_data = np.arange(len(peak_data)) # just placeholder indices
if not use_advanced:
@@ -291,7 +291,31 @@ def fit_peaks(
peak_data_target = peak_data[peak_index+shift_over:]
# popt, pcov = curve_fit(exp_func, x_data_target, peak_data_target, bounds=([-np.inf, 0.0, -np.inf, 0.0], np.inf))
popt, pcov = curve_fit(exp_func, x_data_target, peak_data_target, bounds=([-np.inf, 0.0, -np.inf, 0.0], np.inf), p0=params_guess, maxfev=10000000)
- row.append({'popt': popt, 'pcov': pcov})
- equations.append(row)
+ equation_row.append({'popt': popt, 'pcov': pcov})
+ overlayed_peak_row.append(peak_index)
+ equations.append(equation_row)
+ overlayed_peak_indices.append(overlayed_peak_row)
+ mem['overlayed_peak_indices'] = overlayed_peak_indices
- return equations # list linked with isolated_peaks
\ No newline at end of file
+ return equations # list linked with isolated_peaks
+
+
+def get_tau_data(equation_data):
+ """
+ Extracts time constant from all equations (2d array)
+
+ Returns
+ -------
+
+ Tau data in same dimensions as `equation_data`
+ """
+
+ tau_data = []
+ for r in equation_data:
+ row = []
+ for e in r:
+ tau = e['popt'][3]
+ row.append(tau)
+ equation_data.append(row)
+
+ return tau_data
diff --git a/ui/mainwin.ui b/ui/mainwin.ui
index a09ff75..8ad2873 100644
--- a/ui/mainwin.ui
+++ b/ui/mainwin.ui
@@ -39,9 +39,9 @@
0
- 0
+ -158
261
- 812
+ 818
@@ -141,8 +141,8 @@
0
0
- 221
- 108
+ 222
+ 101
@@ -268,8 +268,8 @@
10
160
- 230
- 52
+ 235
+ 53
@@ -371,7 +371,7 @@
9
20
221
- 108
+ 111
@@ -531,7 +531,7 @@
10
90
221
- 106
+ 111
@@ -542,19 +542,6 @@
- -
-
-
-
-
-
- 8
-
-
- 0.000002000000000
-
-
-
-
@@ -582,7 +569,7 @@
6
- 1.000500000000000
+ 0.000500000000000
@@ -603,6 +590,16 @@
+ -
+
+
+ 10000
+
+
+ 150
+
+
+
@@ -641,8 +638,8 @@
10
260
- 221
- 81
+ 222
+ 82
@@ -833,7 +830,7 @@
0
0
279
- 641
+ 633
diff --git a/widgets.py b/widgets.py
index 77fdf35..e98900f 100644
--- a/widgets.py
+++ b/widgets.py
@@ -103,9 +103,10 @@ class FitGraph(BaseGraph):
for g_i in range(len(mem['isolated_peaks'])):
peak = mem['isolated_peaks'][g_i][self.peak_index]
x_data = np.arange(len(peak))
+ x_data_target = x_data[mem['overlayed_peak_indices'][g_i][self.peak_index]+mem['shift_over_fit']:]
popt = mem['fit_equations'][g_i][self.peak_index]['popt']
self.canv.axes.plot(peak)
- self.canv.axes.plot(x_data, exp_func(x_data, *popt), color='red')
+ self.canv.axes.plot(x_data_target, exp_func(x_data_target, *popt), color='red')
class FitsGraphViewer(QtWidgets.QTabWidget):
def __init__(self, x):