Skip to content

Commit 440dd45

Browse files
FIX: reading error for files with single trace
1 parent 69931ef commit 440dd45

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

PythonGUI_apps/Lifetime_analysis/Lifetime_plot_fit.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ def open_with_skip_rows_window(self):
129129
skip_rows = self.skip_rows_window.ui.skip_rows_spinBox.value()
130130
if ".txt" in self.filename[0]:
131131
self.file = np.loadtxt(self.filename[0], skiprows=skip_rows)
132+
133+
if self.file.ndim == 1: # if there is only one trace, reshape to 2D
134+
self.file = self.file.reshape(self.file.shape[0], 1)
135+
132136
elif ".csv" in self.filename[0]:
133137
self.file = np.genfromtxt(self.filename[0], skip_header=skip_rows, delimiter=",")
134138

@@ -149,6 +153,10 @@ def open_irf_with_skip_rows_window(self):
149153
irf_skip_rows = self.irf_skip_rows_window.ui.skip_rows_spinBox.value()
150154
if ".txt" in self.irf_filename[0]:
151155
self.irf_file = np.loadtxt(self.irf_filename[0], skiprows=irf_skip_rows)
156+
157+
if self.irf_file.ndim == 1: # if there is only one trace, reshape to 2d array
158+
self.irf_file = self.irf_file.reshape(self.irf_file.shape[0], 1)
159+
152160
elif ".csv" in self.irf_filename[0]:
153161
self.irf_file = np.genfrontxt(self.irf_filename[0], skip_header=irf_skip_rows, delimiter=",")
154162

0 commit comments

Comments
 (0)