Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

Commit def6b76

Browse files
author
LAKESIDE\LindaT18
committed
lifetime: clear everytime and normalize checkboxes, ui updates
1 parent f2d6d5a commit def6b76

3 files changed

Lines changed: 68 additions & 51 deletions

File tree

PythonGUI_apps/H5_Pkl/h5_view_and_plot_gui.ui

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
<item row="1" column="0" colspan="2">
9494
<widget class="QStackedWidget" name="data_stackedWidget">
9595
<property name="currentIndex">
96-
<number>2</number>
96+
<number>0</number>
9797
</property>
9898
<widget class="QWidget" name="dataplot_page">
9999
<layout class="QGridLayout" name="gridLayout_6">
@@ -102,20 +102,6 @@
102102
</item>
103103
<item row="1" column="0">
104104
<layout class="QGridLayout" name="gridLayout">
105-
<item row="0" column="2">
106-
<widget class="QLabel" name="label_4">
107-
<property name="text">
108-
<string>X end</string>
109-
</property>
110-
</widget>
111-
</item>
112-
<item row="0" column="0">
113-
<widget class="QLabel" name="label_3">
114-
<property name="text">
115-
<string>X start</string>
116-
</property>
117-
</widget>
118-
</item>
119105
<item row="0" column="1">
120106
<widget class="QDoubleSpinBox" name="plotWidget_x_start_spinBox">
121107
<property name="maximumSize">
@@ -132,13 +118,27 @@
132118
</property>
133119
</widget>
134120
</item>
121+
<item row="0" column="0">
122+
<widget class="QLabel" name="label_3">
123+
<property name="text">
124+
<string>X start</string>
125+
</property>
126+
</widget>
127+
</item>
135128
<item row="0" column="3">
136129
<widget class="QDoubleSpinBox" name="plotWidget_x_end_spinBox">
137130
<property name="maximum">
138131
<double>9999999.000000000000000</double>
139132
</property>
140133
</widget>
141134
</item>
135+
<item row="0" column="2">
136+
<widget class="QLabel" name="label_4">
137+
<property name="text">
138+
<string>X end</string>
139+
</property>
140+
</widget>
141+
</item>
142142
</layout>
143143
</item>
144144
</layout>
@@ -152,18 +152,11 @@
152152
<widget class="ImageView" name="data_imageView"/>
153153
</item>
154154
<item row="1" column="0" colspan="2">
155-
<layout class="QGridLayout" name="gridLayout_9">
156-
<item row="0" column="2">
157-
<widget class="QLabel" name="label_5">
158-
<property name="text">
159-
<string>X end</string>
160-
</property>
161-
</widget>
162-
</item>
163-
<item row="0" column="0">
164-
<widget class="QLabel" name="label">
165-
<property name="text">
166-
<string>X start</string>
155+
<layout class="QGridLayout" name="gridLayout_11">
156+
<item row="0" column="3">
157+
<widget class="QDoubleSpinBox" name="imageView_x_end_spinBox">
158+
<property name="maximum">
159+
<double>9999999.000000000000000</double>
167160
</property>
168161
</widget>
169162
</item>
@@ -183,10 +176,17 @@
183176
</property>
184177
</widget>
185178
</item>
186-
<item row="0" column="3">
187-
<widget class="QDoubleSpinBox" name="imageView_x_end_spinBox">
188-
<property name="maximum">
189-
<double>9999999.000000000000000</double>
179+
<item row="0" column="0">
180+
<widget class="QLabel" name="label">
181+
<property name="text">
182+
<string>X start</string>
183+
</property>
184+
</widget>
185+
</item>
186+
<item row="0" column="2">
187+
<widget class="QLabel" name="label_5">
188+
<property name="text">
189+
<string>X end</string>
190190
</property>
191191
</widget>
192192
</item>

PythonGUI_apps/Lifetime_analysis/Lifetime_analysis_gui_layout.ui

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,7 +1118,21 @@ Ready Figure!</string>
11181118
</property>
11191119
</widget>
11201120
</item>
1121-
<item row="3" column="1" colspan="2">
1121+
<item row="2" column="3">
1122+
<widget class="QCheckBox" name="log_checkBox">
1123+
<property name="text">
1124+
<string>Y Axis Log</string>
1125+
</property>
1126+
</widget>
1127+
</item>
1128+
<item row="1" column="1">
1129+
<widget class="QLabel" name="label_15">
1130+
<property name="text">
1131+
<string>Plot color</string>
1132+
</property>
1133+
</widget>
1134+
</item>
1135+
<item row="5" column="1">
11221136
<widget class="QPushButton" name="clear_pushButton">
11231137
<property name="font">
11241138
<font>
@@ -1131,22 +1145,22 @@ Ready Figure!</string>
11311145
</property>
11321146
</widget>
11331147
</item>
1134-
<item row="1" column="1">
1135-
<widget class="QLabel" name="label_15">
1136-
<property name="text">
1137-
<string>Plot color</string>
1138-
</property>
1139-
</widget>
1140-
</item>
1141-
<item row="1" column="2">
1148+
<item row="1" column="3">
11421149
<widget class="QWidget" name="plot_color_button_container" native="true">
11431150
<layout class="QGridLayout" name="gridLayout_13"/>
11441151
</widget>
11451152
</item>
11461153
<item row="2" column="2">
1147-
<widget class="QCheckBox" name="log_checkBox">
1154+
<widget class="QCheckBox" name="normalize_checkBox">
11481155
<property name="text">
1149-
<string>Y Axis Log</string>
1156+
<string>Normalize</string>
1157+
</property>
1158+
</widget>
1159+
</item>
1160+
<item row="5" column="2" colspan="2">
1161+
<widget class="QCheckBox" name="clear_plot_checkBox">
1162+
<property name="text">
1163+
<string>Clear plot everytime</string>
11501164
</property>
11511165
</widget>
11521166
</item>

PythonGUI_apps/Lifetime_analysis/Lifetime_plot_fit.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,10 @@ def acquire_settings(self, mode="data"):# mode --looks whether argument is data
179179
def plot(self):
180180
try:
181181
x,y = self.acquire_settings()
182-
self.ui.plot.plot(x, y, clear=False, pen=pg.mkPen(self.plot_color))
182+
if self.ui.normalize_checkBox.isChecked():
183+
y = y / np.amax(y)
184+
185+
self.ui.plot.plot(x, y, clear=self.ui.clear_plot_checkBox.isChecked(), pen=pg.mkPen(self.plot_color))
183186

184187
try:
185188
self.ui.Result_textBrowser.setText("Integral Counts :\n" "{:.2E}".format(
@@ -215,15 +218,15 @@ def fit_and_plot(self):
215218
TRPL_interp = np.interp(time_fit, t, y)
216219

217220
fit_func = self.ui.FittingFunc_comboBox.currentText()
218-
self.ui.plot.plot(t, y, clear=True, pen=pg.mkPen(self.plot_color))
221+
self.ui.plot.plot(t, y, clear=self.ui.clear_plot_checkBox.isChecked(), pen=pg.mkPen(self.plot_color))
219222

220223
if fit_func == "Stretched Exponential": #stretch exponential tab
221224
tc, beta, a, avg_tau, PL_fit = stretch_exp_fit(TRPL_interp, t)
222225
self.out = np.empty((len(t), 3))
223226
self.out[:,0] = t #time
224227
self.out[:,1] = TRPL_interp #Raw PL
225228
self.out[:,2] = PL_fit # PL fit
226-
self.ui.plot.plot(t, PL_fit, clear=False, pen='k')
229+
self.ui.plot.plot(t, PL_fit, clear=self.ui.clear_plot_checkBox.isChecked(), pen='k')
227230
self.ui.Result_textBrowser.setText("Fit Results:\n\nFit Function: Stretched Exponential"
228231
"\nFit Method: " + "diff_ev" + #TODO : change when diff_ev and fmin_tnc implemented for non-irf
229232
"\nAverage Lifetime = " + str(avg_tau)+ " ns"
@@ -236,7 +239,7 @@ def fit_and_plot(self):
236239
self.out[:,0] = t #time
237240
self.out[:,1] = TRPL_interp #Raw PL
238241
self.out[:,2] = PL_fit # PL fit
239-
self.ui.plot.plot(t, PL_fit, clear=False, pen='k')
242+
self.ui.plot.plot(t, PL_fit, clear=self.ui.clear_plot_checkBox.isChecked(), pen='k')
240243
self.ui.Result_textBrowser.setText("Fit Results:\n\nFit Function: Double Exponential"
241244
"\nFit Method: " + "diff_ev" +
242245
"\nAverage Lifetime = " + str(avg_tau)+ " ns"
@@ -251,7 +254,7 @@ def fit_and_plot(self):
251254
self.out[:,0] = t #time
252255
self.out[:,1] = TRPL_interp #Raw PL
253256
self.out[:,2] = PL_fit # PL fit
254-
self.ui.plot.plot(t, PL_fit, clear=False, pen='k')
257+
self.ui.plot.plot(t, PL_fit, clear=self.ui.clear_plot_checkBox.isChecked(), pen='k')
255258
self.ui.Result_textBrowser.setText("Fit Results:\n\nFit Function: Single Exponential"
256259
"\nFit Method: " + "diff_ev" +
257260
"\nLifetime = " + str(tau)+ " ns"
@@ -287,7 +290,7 @@ def fit_and_plot_with_irf(self):
287290
TRPL_interp = np.interp(time_fit, t, y)
288291

289292
fit_func = self.ui.FittingFunc_comboBox.currentText()
290-
self.ui.plot.plot(t, y, clear=True, pen=pg.mkPen(self.plot_color))
293+
self.ui.plot.plot(t, y, clear=self.ui.clear_plot_checkBox.isChecked(), pen=pg.mkPen(self.plot_color))
291294
if fit_func == "Stretched Exponential": #stretched exponential tab
292295
tc_bounds = (self.ui.str_tc_min_spinBox.value(), self.ui.str_tc_max_spinBox.value()) #(0, 10000)
293296
a_bounds = (self.ui.str_a_min_spinBox.value(), self.ui.str_a_max_spinBox.value())#(0.9, 1.1)
@@ -306,7 +309,7 @@ def fit_and_plot_with_irf(self):
306309
self.out[:,0] = t #time
307310
self.out[:,1] = TRPL_interp #Raw PL
308311
self.out[:,2] = bestfit_model # PL fit
309-
self.ui.plot.plot(t, bestfit_model, clear=False, pen='k')
312+
self.ui.plot.plot(t, bestfit_model, clear=self.ui.clear_plot_checkBox.isChecked(), pen='k')
310313
self.ui.Result_textBrowser.setText("Fit Results:\n\nFit Function: Stretched Exponential"
311314
"\nFit Method: "+ self.ui.FittingMethod_comboBox.currentText() +
312315
"\ntau_avg = %.5f ns"
@@ -335,7 +338,7 @@ def fit_and_plot_with_irf(self):
335338
self.out[:,0] = t #time
336339
self.out[:,1] = TRPL_interp #Raw PL
337340
self.out[:,2] = bestfit_model # PL fit
338-
self.ui.plot.plot(t, bestfit_model, clear=False, pen='k')
341+
self.ui.plot.plot(t, bestfit_model, clear=self.ui.clear_plot_checkBox.isChecked(), pen='k')
339342
self.ui.Result_textBrowser.setText("Fit Results:\n\nFit Function: Double Exponential"
340343
"\nFit Method: "+ self.ui.FittingMethod_comboBox.currentText() +
341344
"\na1 = %.5f"
@@ -359,7 +362,7 @@ def fit_and_plot_with_irf(self):
359362
self.out[:,0] = t #time
360363
self.out[:,1] = TRPL_interp #Raw PL
361364
self.out[:,2] = bestfit_model # PL fit
362-
self.ui.plot.plot(t, bestfit_model, clear=False, pen='k')
365+
self.ui.plot.plot(t, bestfit_model, clear=self.ui.clear_plot_checkBox.isChecked(), pen='k')
363366
self.ui.Result_textBrowser.setText("Fit Results:\n\nFit Function: Single Exponential"
364367
"\nFit Method: "+ self.ui.FittingMethod_comboBox.currentText() +
365368
"\na = %.5f"

0 commit comments

Comments
 (0)