12
12
import sys
13
13
import seabreeze .spectrometers as sb
14
14
from pipython import GCSDevice
15
+ import time
15
16
16
17
pg .mkQApp ()
17
18
pg .setConfigOption ('background' , 'w' )
@@ -100,6 +101,18 @@ def estimate_scan_time(self):
100
101
x_step = self .ui .x_step_doubleSpinBox .value ()
101
102
y_step = self .ui .y_step_doubleSpinBox .value ()
102
103
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
+
103
116
y_range = int (np .ceil (y_scan_size / y_step ))
104
117
x_range = int (np .ceil (x_scan_size / x_step ))
105
118
@@ -110,9 +123,10 @@ def estimate_scan_time(self):
110
123
111
124
total_time = total_points * (intg_time_ms * 1e-3 )* (scans_to_avg ) # in seconds
112
125
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" )
114
127
115
128
def x_y_scan (self ):
129
+ start_time = time .time ()
116
130
x_start = self .ui .x_start_doubleSpinBox .value ()
117
131
y_start = self .ui .y_start_doubleSpinBox .value ()
118
132
@@ -151,17 +165,19 @@ def x_y_scan(self):
151
165
k = 0
152
166
for i in range (y_range ):
153
167
for j in range (x_range ):
154
- print (self .pi_device .qPOS (axes = self .axes ))
168
+ # print(self.pi_device.qPOS(axes=self.axes))
155
169
156
170
self ._read_spectrometer ()
157
171
data_array [k ,:] = self .y
158
172
self .ui .plot .plot (self .spec .wavelengths (), self .y , pen = 'r' , clear = True )
173
+ pg .QtGui .QApplication .processEvents ()
159
174
160
175
self .pi_device .MVR (axes = self .axes [0 ], values = [x_step ])
161
176
162
- self .ui .progressBar .setValue (((k + 1 )/ (x_range * y_range )))
177
+ self .ui .progressBar .setValue (100 * ((k + 1 )/ (x_range * y_range )))
163
178
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
165
181
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
166
182
self .pi_device .MVR (axes = self .axes [1 ], values = [y_step ])
167
183
else :
@@ -177,7 +193,7 @@ def x_y_scan(self):
177
193
178
194
pickle .dump (save_dict , open (self .save_folder + "/" + self .ui .lineEdit .text ()+ "_raw_PL_spectra_data.pkl" , "wb" ))
179
195
180
- self .ui .status_textBrowser .setText ("Data saved!" )
196
+ self .ui .status_textBrowser .setText ("Data saved!\n Total time taken:" + str ( np . float16 (( time . time () - start_time ) / 60 )) + " mins " )
181
197
182
198
183
199
0 commit comments