Skip to content

Commit e2b8856

Browse files
update plt while scan, est scan time fix for line scans, fix progress bar update
1 parent 710aa65 commit e2b8856

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

PythonGUI_apps/OceanOptics_acquire/OceanOptics_acquire_plot.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import sys
1313
import seabreeze.spectrometers as sb
1414
from pipython import GCSDevice
15+
import time
1516

1617
pg.mkQApp()
1718
pg.setConfigOption('background', 'w')
@@ -100,6 +101,18 @@ def estimate_scan_time(self):
100101
x_step = self.ui.x_step_doubleSpinBox.value()
101102
y_step = self.ui.y_step_doubleSpinBox.value()
102103

104+
if y_scan_size == 0:
105+
y_scan_size = 1
106+
107+
if x_scan_size == 0:
108+
x_scan_size = 1
109+
110+
if y_step == 0:
111+
y_step = 1
112+
113+
if x_step == 0:
114+
x_step = 1
115+
103116
y_range = int(np.ceil(y_scan_size/y_step))
104117
x_range = int(np.ceil(x_scan_size/x_step))
105118

@@ -110,9 +123,10 @@ def estimate_scan_time(self):
110123

111124
total_time = total_points*(intg_time_ms*1e-3)*(scans_to_avg) # in seconds
112125

113-
self.ui.status_textBrowser.setText("Estimated scan time: "+str(total_time/60)+" mins")
126+
self.ui.status_textBrowser.setText("Estimated scan time: "+str(np.float16(total_time/60))+" mins")
114127

115128
def x_y_scan(self):
129+
start_time = time.time()
116130
x_start = self.ui.x_start_doubleSpinBox.value()
117131
y_start = self.ui.y_start_doubleSpinBox.value()
118132

@@ -151,17 +165,19 @@ def x_y_scan(self):
151165
k = 0
152166
for i in range(y_range):
153167
for j in range(x_range):
154-
print(self.pi_device.qPOS(axes=self.axes))
168+
# print(self.pi_device.qPOS(axes=self.axes))
155169

156170
self._read_spectrometer()
157171
data_array[k,:] = self.y
158172
self.ui.plot.plot(self.spec.wavelengths(), self.y, pen='r', clear=True)
173+
pg.QtGui.QApplication.processEvents()
159174

160175
self.pi_device.MVR(axes=self.axes[0], values=[x_step])
161176

162-
self.ui.progressBar.setValue(((k+1)/(x_range*y_range)))
177+
self.ui.progressBar.setValue(100*((k+1)/(x_range*y_range)))
163178
k+=1
164-
179+
# TODO
180+
# if statement needs to be modified to keep the stage at the finish y-pos for line scans in x, and same for y
165181
if i == y_range-1: # this if statement is there to keep the stage at the finish position (in x) and not bring it back like we were doing during the scan
166182
self.pi_device.MVR(axes=self.axes[1], values=[y_step])
167183
else:
@@ -177,7 +193,7 @@ def x_y_scan(self):
177193

178194
pickle.dump(save_dict, open(self.save_folder+"/"+self.ui.lineEdit.text()+"_raw_PL_spectra_data.pkl", "wb"))
179195

180-
self.ui.status_textBrowser.setText("Data saved!")
196+
self.ui.status_textBrowser.setText("Data saved!\nTotal time taken:"+str(np.float16((time.time()-start_time)/60))+" mins")
181197

182198

183199

0 commit comments

Comments
 (0)