def initH5CellCounter(self): """ Initialization operations for the h5 file. """ t0 = time.time() f = self.app.settings['data_fname_format'].format( app=self.app, measurement=self, timestamp=datetime.fromtimestamp(t0), sample=self.app.settings["sample"] + "_cell_counter", ext='h5') fname = os.path.join(self.app.settings['save_dir'], f) self.h5file_counter = h5_io.h5_base_file(app=self.app, measurement=self, fname=fname) self.h5_group = h5_io.h5_create_measurement_group( measurement=self, h5group=self.h5file_counter) self.h5_mean = self.h5_group.create_dataset(name='t0/c0/mean', shape=(self.N_frames, 1, 1), dtype="int16", chunks=(1, 1, 1)) self.h5_dt = self.h5_group.create_dataset(name='t0/c0/dt', shape=(self.N_frames, 1, 1), dtype="float", chunks=(1, 1, 1)) self.h5_t1 = self.h5_group.create_dataset(name='t0/c0/t1', shape=(self.N_frames, 1, 1), dtype="float", chunks=(1, 1, 1))
def pre_run(self): S = self.settings # create arrays self.x_array = np.linspace(S['x0'], S['x1'], S['n_steps']) self.y_array = np.linspace(S['y0'], S['y1'], S['n_steps']) if S['retrace']: self.x_array = np.concatenate([self.x_array, self.x_array[::-1]]) self.y_array = np.concatenate([self.y_array, self.y_array[::-1]]) self.N = len(self.x_array) self.stage = self.app.hardware['attocube_xy_stage'] # data file self.h5file = h5_io.h5_base_file(self.app, measurement=self) H = self.h5measure = h5_io.h5_create_measurement_group( measurement=self, h5group=self.h5file, group_name=self.name) # Create acquisition arrays if S['collect_apd']: self.apd_counter = self.app.hardware.apd_counter self.apd_countrates = H.create_dataset( 'apd_countrates', self.N, dtype=float) # 'apd_countrate' if S['collect_spectrum']: self.spectra = H.create_dataset('spectra', (self.N, ccd_Nx), dtype=float) # 'apd_countrate' if S['collect_lifetime']: self.picoharp = self.app.hardware.picoharp self.time_traces = H.create_dataset( 'time_traces', (self.N, self.picoharp.settings['histogram_channels']), dtype=int)
def run(self): self.display_update_period = 1 #seconds if self.save_data.val: self.full_optimize_history = [] self.full_optimize_history_time = [] self.t0 = time.time() while not self.interrupt_measurement_called: self.optimize_ii += 1 self.optimize_ii %= self.OPTIMIZE_HISTORY_LEN self.optimize_history_A[ self.optimize_ii] = self.ctrl.settings['T_A'] self.optimize_history_B[ self.optimize_ii] = self.ctrl.settings['T_B'] time.sleep(self.display_update_period) if self.settings['save_data']: try: self.h5_file = h5_io.h5_base_file(self.app, measurement=self) self.h5_file.attrs['time_id'] = self.t0 H = self.h5_meas_group = h5_io.h5_create_measurement_group( self, self.h5_file) #create h5 data arrays H['power_optimze_history'] = self.full_optimize_history H['optimze_history_time'] = self.full_optimize_history_time finally: self.h5_file.close()
def run(self): self.display_update_period = 0.02 #seconds #self.apd_counter_hc = self.gui.apd_counter_hc #self.apd_count_rate = self.apd_counter_hc.apd_count_rate #self.pm_hc = self.gui.thorlabs_powermeter_hc #self.pm_analog_readout_hc = self.gui.thorlabs_powermeter_analog_readout_hc if self.save_data.val: self.full_optimize_history = [] self.full_optimize_history_time = [] self.t0 = time.time() while not self.interrupt_measurement_called: self.optimize_ii += 1 self.optimize_ii %= self.OPTIMIZE_HISTORY_LEN self.oo_spec.interrupt_measurement_called = self.interrupt_measurement_called self.oo_spec.settings['continuous'] = False self.oo_spec.settings['save_h5'] = False # if ~self.oo_spec.activation.val: # self.oo_spec.activation.update_value(True) #self.oo_spec.run() self.start_nested_measure_and_wait(self.oo_spec) spec = self.oo_spec.hw.spectrum.copy() if self.oo_spec.settings['baseline_subtract']: new_value = (spec - self.oo_spec.settings['baseline_val']).sum() else: new_value = self.pow_reading.update_value(spec.sum()) if isnan(new_value): print('spec sum nan', self.optimize_ii) self.pow_reading.update_value( self.optimize_history[self.optimize_ii - 1]) else: print('spec sum', self.optimize_ii, new_value) self.pow_reading.update_value(new_value) self.optimize_history[self.optimize_ii] = self.pow_reading.val time.sleep(self.settings['update_period']) #time.sleep(0.02) if self.settings['save_data']: try: self.h5_file = h5_io.h5_base_file(self.app, measurement=self) self.h5_file.attrs['time_id'] = self.t0 H = self.h5_meas_group = h5_io.h5_create_measurement_group( self, self.h5_file) #create h5 data arrays H['power_optimze_history'] = self.full_optimize_history H['optimze_history_time'] = self.full_optimize_history_time finally: self.h5_file.close()
def save_h5(self): # h5 data file setup self.t0 = time.time() self.h5_file = h5_io.h5_base_file(self.app, measurement=self) self.h5_filename = self.h5_file.filename self.h5_file.attrs['time_id'] = self.t0 H = self.h5_meas_group = h5_io.h5_create_measurement_group(self, self.h5_file) H['V'] = np.array(self.Varray) H['I'] = np.array(self.Iarray) self.h5_file.close()
def initH5(self): """ Initialization operations for the h5 file """ self.create_saving_directory() # file name creation timestamp = time.strftime("%y%m%d_%H%M%S", time.localtime()) sample = self.app.settings['sample'] #sample_name = f'{timestamp}_{self.name}_{sample}.h5' if sample == '': sample_name = '_'.join([timestamp, self.name]) else: sample_name = '_'.join([timestamp, self.name, sample]) fname = os.path.join(self.app.settings['save_dir'], sample_name + '.h5') # file creation self.h5file = h5_io.h5_base_file(app=self.app, measurement=self, fname=fname) self.h5_group = h5_io.h5_create_measurement_group(measurement=self, h5group=self.h5file) img_size = self.im.image[ 0].shape # both image[0] and image[1] are valid, since they have the same shape number_of_channels = len(self.channels) # take as third dimension of the file the total number of images collected in the buffer if self.camera.hamamatsu.last_frame_number < self.camera.hamamatsu.number_image_buffers: length = int((self.camera.hamamatsu.last_frame_number + 1) / number_of_channels) else: length = self.camera.hamamatsu.number_image_buffers / number_of_channels # dataset creation for ch_index in self.channels: name = f't0/c{ch_index}/image' self.image_h5[ch_index] = self.h5_group.create_dataset( name=name, shape=(length, img_size[0], img_size[1]), dtype=self.im.image[0].dtype, chunks=(1, img_size[0], img_size[1])) self.image_h5[ch_index].attrs['element_size_um'] = [ self.settings['zsampling'], self.settings['ysampling'], self.settings['xsampling'] ] self.image_h5[ch_index].attrs['acq_time'] = timestamp self.image_h5[ch_index].attrs['flowrate'] = self.settings[ 'flowrate']
def run(self): cam_hw = self.app.hardware.ascom_camera print(self.name, 'interrupted', self.interrupt_measurement_called) while not self.interrupt_measurement_called: # Blocking version #self.img = cam_hw.acq_single_exposure() # non blocking version cam_hw.ac.StartExposure(cam_hw.settings['exp_time']) t0 = time.time() while not cam_hw.ac.is_image_ready(): if self.interrupt_measurement_called: break time.sleep(0.05) self.settings['progress'] = 100.0 * ( time.time() - t0) / cam_hw.settings['exp_time'] self.img = cam_hw.ac.read_image_data() if not self.settings['continuous']: # save image try: t0 = time.time() fname = os.path.join(self.app.settings['save_dir'], "%i_%s" % (t0, self.name)) print(self.name, 'asdf', self.img.dtype, fname) if self.settings['save_ini']: self.app.settings_save_ini(fname + ".ini") if self.settings['save_png']: scipy.misc.imsave(fname + ".png", self.img) if self.settings['save_tif']: #im = PIL.Image.fromarray(self.img.T) #im.save("%i_%s.tif" % (t0, self.name), compression=6) tif_imsave(fname + ".tif", self.img.T.astype(np.uint16), compress=0) if self.settings['save_h5']: with h5_io.h5_base_file(self.app, fname=fname + ".h5") as H: M = h5_io.h5_create_measurement_group( measurement=self, h5group=H) M.create_dataset('img', data=self.img, compression='gzip') except Exception as e: print('Error saving files!', e) raise e finally: break # end the while loop for non-continuous scans else: pass
def run(self): cam = self.spec_hw.cam print("rois|-->", cam.read_rois()) cam.commit_parameters() while not self.interrupt_measurement_called: self.t0 = time.time() dat = cam.acquire(readout_count=1, readout_timeout=-1) self.roi_data = cam.reshape_frame_data(dat) #print "roi_data shapes", [d.shape for d in self.roi_data] self.spec = spec = np.average(self.roi_data[0], axis=0) px_index = np.arange(self.spec.shape[-1]) self.hbin = self.spec_hw.settings['roi_x_bin'] if 'acton_spectrometer' in self.app.hardware: self.wls = self.app.hardware['acton_spectrometer'].get_wl_calibration(px_index, self.hbin) else: self.wls = self.hbin*px_index + 0.5*(self.hbin-1) self.pixels = self.hbin*px_index + 0.5*(self.hbin-1) self.raw_pixels = px_index self.wave_numbers = 1.0e7/self.wls self.raman_shifts = 1.0e7/self.laser_wl.val - 1.0e7/self.wls self.wls_mean = self.wls.mean() if not self.continuous.val: break if self.settings['save_h5']: self.h5_file = h5_io.h5_base_file(self.app, measurement=self ) self.h5_file.attrs['time_id'] = self.t0 H = self.h5_meas_group = h5_io.h5_create_measurement_group(self, self.h5_file) H['spectrum'] = spec H['wavelength'] = self.wls H['wave_numbers'] = self.wave_numbers H['raman_shifts'] = self.raman_shifts print('saved file') self.h5_file.close()
def save_data(self): t = time.localtime(time.time()) t_string = "{:02d}{:02d}{:02d}_{:02d}{:02d}{:02d}".format( int(str(t[0])[:-2]), t[1], t[2], t[3], t[4], t[5]) fname = os.path.join(self.app.settings['save_dir'], "%s_%s" % (t_string, self.name)) with h5_io.h5_base_file(self.app, fname=fname + ".h5") as H: print("Saving " + fname + ".h5") M = h5_io.h5_create_measurement_group(measurement=self, h5group=H) M.create_dataset('spectrum', data=self.spectrum, compression='gzip') M.create_dataset('wavelengths', data=self.wavelengths, compression='gzip')
def run(self): self.ph_hw = self.app.hardware['picoharp'] self.ph = self.ph_hw.picoharp if self.settings['use_calc_hist_chans']: self.ph_hw.settings[ 'histogram_channels'] = self.ph_hw.calc_num_hist_chans() self.sleep_time = min((max(0.1 * self.ph.Tacq * 1e-3, 0.010), 0.100)) self.t0 = time.time() while not self.interrupt_measurement_called: self.ph.start_histogram() if self.ph.Tacq < 101: time.sleep(self.ph.Tacq * 1e-3 + 5e-3) else: while not self.ph.check_done_scanning(): self.set_progress(100 * (time.time() - self.t0) / self.ph_hw.settings['Tacq']) if self.interrupt_measurement_called: break self.ph.read_histogram_data() self.ph_hw.settings.count_rate0.read_from_hardware() self.ph_hw.settings.count_rate1.read_from_hardware() time.sleep(self.sleep_time) self.ph_hw.settings.count_rate0.read_from_hardware() self.ph_hw.settings.count_rate1.read_from_hardware() self.ph.stop_histogram() self.ph.read_histogram_data() if not self.settings['continuous']: break self.data_slice = slice(0, self.ph_hw.settings['histogram_channels']) histogram_data = self.ph.histogram_data[self.data_slice] time_array = self.ph.time_array[self.data_slice] elapsed_meas_time = self.ph.read_elapsed_meas_time() if self.settings['save_h5']: self.h5_file = h5_io.h5_base_file(self.app, measurement=self) self.h5_file.attrs['time_id'] = self.t0 H = self.h5_meas_group = h5_io.h5_create_measurement_group( self, self.h5_file) H['time_histogram'] = histogram_data H['time_array'] = time_array H['elapsed_meas_time'] = elapsed_meas_time self.h5_file.close()
def init_roi_h5(self): """ Initialization operations for the h5 file """ self.create_saving_directory() # file name creation timestamp = time.strftime("%y%m%d_%H%M%S", time.localtime()) sample = self.app.settings['sample'] #sample_name = f'{timestamp}_{self.name}_{sample}_ROI.h5' sample_name = '_'.join([timestamp, self.name, sample, 'ROI.h5']) fname = os.path.join(self.app.settings['save_dir'], sample_name) # file creation self.h5_roi_file = h5_io.h5_base_file(app=self.app, measurement=self, fname = fname) self.h5_roi_group = h5_io.h5_create_measurement_group(measurement=self, h5group=self.h5_roi_file)
def snap_h5(self): # from ScopeFoundry import h5_io #self.app.hardware['asi_stage'].correct_backlash(0.02) self.h5_file = h5_io.h5_base_file(app=self.app, measurement=self) H = self.h5_meas_group = h5_io.h5_create_measurement_group( self, self.h5_file) im = self.get_rgb_image() im = np.flip(im.swapaxes(0, 1), 0) H['image'] = im self.h5_file.close() print('saved file successfully', im.sum()) return im
def run(self): self.display_ready = False self.hw = hw = self.app.hardware['hydraharp'] Tacq = hw.settings['Tacq'] if self.settings['auto_HistogramBins']: self.hw.update_HistogramBins() self.sleep_time = min((max(0.1*Tacq, 0.010), 0.100)) self.t0 = time.time() while not self.interrupt_measurement_called: hw.start_histogram() if Tacq < 0.1: time.sleep(Tacq+5e-3) else: while not hw.check_done_scanning(): self.set_progress( 100*(time.time() - self.t0)/Tacq ) if self.interrupt_measurement_called: break self.hist_data = hw.read_histogram_data(clear_after=False) time.sleep(self.sleep_time) hw.stop_histogram() self.hist_data = hw.read_histogram_data(clear_after=True) if not self.settings['continuous']: break elapsed_meas_time = hw.settings.ElapsedMeasTime.read_from_hardware() if self.settings['save_h5']: self.h5_file = h5_io.h5_base_file(self.app, measurement=self ) self.h5_file.attrs['time_id'] = self.t0 H = self.h5_meas_group = h5_io.h5_create_measurement_group(self, self.h5_file) H['time_histogram'] = self.hist_data[self.hw.hist_slice] H['time_array'] = self.hw.time_array[self.hw.hist_slice[-1]] H['elapsed_meas_time'] = elapsed_meas_time self.h5_file.close()
def save_image(self): print('thor_cam_capture save_image') S = self.settings t0 = time.time() fname = os.path.join(self.app.settings['save_dir'], "%i_%s" % (t0, self.name)) if S['save_ini']: self.app.settings_save_ini(fname + ".ini") if S['save_png']: self.imview.export(fname + ".png") if S['save_tif']: self.imview.export(fname + ".tif") if S['save_h5']: with h5_io.h5_base_file(app=self.app, measurement=self) as H: M = h5_io.h5_create_measurement_group(measurement=self, h5group=H) M.create_dataset('img', data=self.img, compression='gzip')
def run(self): self.t0 = time.time() #Hardware self.keithley_hw = self.app.hardware['keithley_sourcemeter'] KS = self.keithley_hw.settings self.keithley = self.keithley_hw.keithley KS['output_a_on'] = True time.sleep(0.5) #measure IV self.V_sources = self.voltage_range.sweep_array self.I_array = np.zeros_like(self.V_sources, float) self.V_array = np.zeros_like(self.V_sources, float) for i, Vs in enumerate(self.V_sources): self.ii = i self.set_progress(i / len(self.V_sources) * 100) KS['source_V_a'] = Vs time.sleep(KS['delay_time_a']) self.keithley_hw.settings.I_a.read_from_hardware() self.keithley_hw.settings.V_a.read_from_hardware() self.I_array[i] = KS["I_a"] self.V_array[i] = KS["V_a"] self.collect_Vs(i, Vs, KS["I_a"], KS["V_a"]) KS['output_a_on'] = False if self.settings['save_h5']: self.h5_file = h5_io.h5_base_file(self.app, measurement=self) self.h5_filename = self.h5_file.filename self.h5_file.attrs['time_id'] = self.t0 H = self.h5_meas_group = h5_io.h5_create_measurement_group( self, self.h5_file) H['V_sourced'] = self.V_sources H['V'] = np.array(self.V_array) H['I'] = np.array(self.I_array) self.save_collected() self.h5_file.close()
def run(self): self.display_update_period = 0.02 #seconds #self.apd_counter_hc = self.gui.apd_counter_hc #self.apd_count_rate = self.apd_counter_hc.apd_count_rate #self.pm_hc = self.gui.thorlabs_powermeter_hc #self.pm_analog_readout_hc = self.gui.thorlabs_powermeter_analog_readout_hc if self.save_data.val: self.full_optimize_history = [] self.full_optimize_history_time = [] self.t0 = time.time() while not self.interrupt_measurement_called: self.optimize_ii += 1 self.optimize_ii %= self.OPTIMIZE_HISTORY_LEN pow_reading = self.powermeter.settings.power.read_from_hardware() #pow_reading = self.powermeter.power_meter.measure_power() self.optimize_history[self.optimize_ii] = pow_reading #self.pm_analog_readout_hc.voltage.read_from_hardware() if self.save_data.val: self.full_optimize_history.append(pow_reading) self.full_optimize_history_time.append(time.time() - self.t0) time.sleep(self.settings['update_period']) #time.sleep(0.02) if self.settings['save_data']: try: self.h5_file = h5_io.h5_base_file(self.app, measurement=self) self.h5_file.attrs['time_id'] = self.t0 H = self.h5_meas_group = h5_io.h5_create_measurement_group( self, self.h5_file) #create h5 data arrays H['power_optimze_history'] = self.full_optimize_history H['optimze_history_time'] = self.full_optimize_history_time finally: self.h5_file.close()
def initH5(self): """ Initialization operations for the h5 file. """ self.h5file = h5_io.h5_base_file(app=self.app, measurement=self) self.h5_group = h5_io.h5_create_measurement_group(measurement=self, h5group=self.h5file) img_size = self.image.shape length = self.camera.pixelink.number_frames self.image_h5 = self.h5_group.create_dataset( name='t0/c0/image', shape=(self.camera.pixelink.number_frames, self.eff_img_height, self.eff_img_width), dtype=self.image.dtype) self.image_h5.dims[0].label = "z" self.image_h5.dims[1].label = "y" self.image_h5.dims[2].label = "x" self.image_h5.attrs['element_size_um'] = [1, 1, 1]
def create_h5_file(self): self.create_saving_directory() # file name creation timestamp = time.strftime("%y%m%d_%H%M%S", time.localtime()) sample = self.app.settings['sample'] #sample_name = f'{timestamp}_{self.name}_{sample}.h5' if sample == '': sample_name = '_'.join([timestamp, self.name]) else: sample_name = '_'.join([timestamp, self.name, sample]) fname = os.path.join(self.app.settings['save_dir'], sample_name + '.h5') self.h5file = h5_io.h5_base_file(app=self.app, measurement=self, fname = fname) self.h5_group = h5_io.h5_create_measurement_group(measurement=self, h5group=self.h5file) img_size = self.img.shape dtype=self.img.dtype length = self.image_gen.frame_num.val self.image_h5 = self.h5_group.create_dataset(name = 't0/c0/image', shape = [length, img_size[0], img_size[1]], dtype = dtype) self.image_h5.attrs['element_size_um'] = [self.settings['zsampling'],self.settings['ysampling'],self.settings['xsampling']]
def run(self): self.t0 = time.time() self.spec_readout.settings['continuous'] = False self.spectra = [] self.center_wls = [] #center wls read from spectrometer for center_wl in self.center_wl_range.array: self.spec_center_wl.update_value(center_wl) time.sleep(1) self.start_nested_measure_and_wait(self.spec_readout, polling_time=0.1, start_time=0.1) self.spectra.append(self.spec_readout.spec) self.center_wls.append(self.spec_center_wl.val) self.h5_file = h5_io.h5_base_file(self.app, measurement=self) self.h5_file.attrs['time_id'] = self.t0 H = self.h5_meas_group = h5_io.h5_create_measurement_group( self, self.h5_file) H['spectra'] = np.array(self.spectra) H['center_wls'] = np.array(self.center_wls) self.h5_file.close()
def run(self): # self.winspec_hc.settings['connected'] = False # time.sleep(0.2) # self.winspec_hc.settings['connected'] = True # time.sleep(0.2) # S = self.settings while not self.interrupt_measurement_called: #print("test") try: i_acc = 0 while not self.interrupt_measurement_called and i_acc < S[ 'n_accumulations']: i_acc += 1 self.set_progress(i_acc / S['n_accumulations'] * 100) print("start acq {}".format(i_acc)) hdr, data = self.acquire_data() if hdr is None or data is None: raise IOError( "Failed to acquire Data (probably interrupted)") self.hdr = hdr self.data = data if i_acc == 1: self.spec = np.average(self.data[0, :, :], axis=0) wl_calib = self.settings['wl_calib'] self.pixels = px_index = np.arange(self.data.shape[-1]) if wl_calib == 'winspec': self.wls = self.evaluate_wls_winspec(self.hdr) elif wl_calib == 'acton_spectrometer': hbin = self.hdr.bin_x spec_hw = self.app.hardware['acton_spectrometer'] self.wls = self.evaluate_wls_acton_spectrometer( self.hdr, px_index) elif wl_calib == 'pixels': binning = self.hdr.bin_x self.wls = binned_px = binning * px_index + 0.5 * ( binning - 1) elif wl_calib == 'raw_pixels': self.wls = px_index else: self.wls = px_index self.wls_mean = self.wls.mean() else: self.spec += np.average(self.data[0, :, :], axis=0) print("end acq {}".format(i_acc)) if self.settings['save_h5']: self.t0 = time.time() self.h5_file = h5_io.h5_base_file(self.app, measurement=self) self.h5_file.attrs['time_id'] = self.t0 H = self.h5_meas_group = h5_io.h5_create_measurement_group( self, self.h5_file) #create h5 data arrays H['wls'] = self.wls H['spectrum'] = self.spec self.h5_file.close() finally: if not self.settings['continuous']: break
def run(self): S = self.settings #Hardware # self.apd_counter_hc = self.app.hardware_components['apd_counter'] # self.apd_count_rate = self.apd_counter_hc.apd_count_rate # self.stage = self.app.hardware_components['dummy_xy_stage'] # Data File # H5 # Compute data arrays self.compute_scan_arrays() self.initial_scan_setup_plotting = True self.display_image_map = np.zeros(self.scan_shape, dtype=float) while not self.interrupt_measurement_called: try: # h5 data file setup self.t0 = time.time() if self.settings['save_h5']: self.h5_file = h5_io.h5_base_file(self.app, measurement=self) self.h5_filename = self.h5_file.filename self.h5_file.attrs['time_id'] = self.t0 H = self.h5_meas_group = h5_io.h5_create_measurement_group( self, self.h5_file) #create h5 data arrays H['h_array'] = self.h_array H['v_array'] = self.v_array H['range_extent'] = self.range_extent H['corners'] = self.corners H['imshow_extent'] = self.imshow_extent H['scan_h_positions'] = self.scan_h_positions H['scan_v_positions'] = self.scan_v_positions H['scan_slow_move'] = self.scan_slow_move H['scan_index_array'] = self.scan_index_array # start scan self.pixel_i = 0 self.current_scan_index = self.scan_index_array[0] self.pixel_time = np.zeros(self.scan_shape, dtype=float) if self.settings['save_h5']: self.pixel_time_h5 = H.create_dataset( name='pixel_time', shape=self.scan_shape, dtype=float) self.pre_scan_setup() self.move_position_start(self.scan_h_positions[0], self.scan_v_positions[0]) for self.pixel_i in range(self.Npixels): if self.interrupt_measurement_called: break i = self.pixel_i self.current_scan_index = self.scan_index_array[i] kk, jj, ii = self.current_scan_index h, v = self.scan_h_positions[i], self.scan_v_positions[i] if self.pixel_i == 0: dh = 0 dv = 0 else: dh = self.scan_h_positions[i] - self.scan_h_positions[ i - 1] dv = self.scan_v_positions[i] - self.scan_v_positions[ i - 1] if self.scan_slow_move[i]: self.move_position_slow(h, v, dh, dv) if self.settings['save_h5']: self.h5_file.flush( ) # flush data to file every slow move #self.app.qtapp.ProcessEvents() time.sleep(0.01) else: self.move_position_fast(h, v, dh, dv) self.pos = (h, v) # each pixel: # acquire signal and save to data array pixel_t0 = time.time() self.pixel_time[kk, jj, ii] = pixel_t0 if self.settings['save_h5']: self.pixel_time_h5[kk, jj, ii] = pixel_t0 self.collect_pixel(self.pixel_i, kk, jj, ii) S['progress'] = 100.0 * self.pixel_i / (self.Npixels) finally: self.post_scan_cleanup() if hasattr(self, 'h5_file'): print('h5_file', self.h5_file) try: self.h5_file.close() except ValueError as err: self.log.warning( 'failed to close h5_file: {}'.format(err)) if not self.settings['continuous_scan']: break print(self.name, 'done')