def set_scan_params(self): self.log.info("Setting scan parameters") '''To be called before Experiment.run to set all parameters required for correct data acquisition''' problem_with_params = False # SET CAMERA PARAMETER if not self.camera_controls_group.ttl_scan.isChecked(): problem_with_params = self.camera_controls_group.set_camera_params( ) # SET ACQUISITION PARAMETERS try: # Times as floating point numbers [msec] to compute the CT stage motion self.concert_scan.acq_setup.dead_time = self.camera_controls_group.dead_time self.concert_scan.acq_setup.exp_time = self.camera_controls_group.exp_time # Inner motor and scan intervals self.concert_scan.acq_setup.motor = self.motors[ self.scan_controls_group.inner_motor] if self.scan_controls_group.inner_motor == 'CT stage [deg]': self.concert_scan.acq_setup.units = q.deg self.concert_scan.acq_setup.cont = self.scan_controls_group.inner_cont self.concert_scan.acq_setup.start = self.scan_controls_group.inner_start self.concert_scan.acq_setup.nsteps = self.scan_controls_group.inner_steps self.concert_scan.acq_setup.range = self.scan_controls_group.inner_range self.concert_scan.acq_setup.endp = self.scan_controls_group.inner_endpoint self.concert_scan.acq_setup.calc_step() self.concert_scan.acq_setup.flats_before = self.scan_controls_group.ffc_before self.concert_scan.acq_setup.flats_after = self.scan_controls_group.ffc_after # SET shutter if self.shutter is None: self.concert_scan.ffc_setup.shutter = DummyShutter() else: self.concert_scan.ffc_setup.shutter = self.shutter except: self.log.error("Scan params defined incorrectly. Aborting") info_message( "Select flat field motor and define parameters correctly") problem_with_params = True # SET FFC parameters if self.scan_controls_group.ffc_before or self.scan_controls_group.ffc_after or \ self.scan_controls_group.ffc_before_outer or self.scan_controls_group.ffc_after_outer: try: self.concert_scan.ffc_setup.flat_motor = self.motors[ self.ffc_controls_group.flat_motor] self.concert_scan.ffc_setup.radio_position = self.ffc_controls_group.radio_position * q.mm self.concert_scan.ffc_setup.flat_position = self.ffc_controls_group.flat_position * q.mm self.concert_scan.acq_setup.num_flats = self.ffc_controls_group.num_flats self.concert_scan.acq_setup.num_darks = self.ffc_controls_group.num_darks except: self.log.error( "Flat-field params defined incorrectly. Aborting") error_message( "Select flat field motor and define parameters correctly") problem_with_params = True if problem_with_params: self.number_of_scans = 0 self.end_of_scan()
def CT_reset_func(self): """Reset the stage and move to home.""" if self.CT_motor is None: return else: self.CT_motor.reset() self.CT_mot_pos_move.setValue(0.0) self.CT_move_func() info_message( "Reset finished. Please wait for state motion to stop.")
def num_flats(self): try: tmp = int(self.numflats_entry.text()) except ValueError: error_message('Number of flats must be positive integer number') if tmp < 1: info_message('Number of flats must be larger than 0') self.numflats_entry.setText('10') tmp = 10 return tmp
def num_darks(self): try: tmp = int(self.numdarks_entry.text()) except ValueError: error_message( 'Number of darks must be non-negative integer number') if tmp < 0: info_message('Number of darks must be 0 or larger') self.numdarks_entry.setText('10') tmp = 10 return tmp
def run(self): while self.thread_running: if self.readout_on: # f, fext = self.qfd.getSaveFileName( # None, 'Select dir and enter prefix', self.last_dir, "Image Files (*.tif)") # if f == self.last_dir: # f += "/im-seq-00" # self.last_dir = os.path.dirname(f) self.frames_grabbed_so_far = 0 tmp = time.time() self.abort_transfer = False self.camera.uca.start_readout() wrtr = TiffWriter(self.filename, bytes_per_file=2**37) while not self.abort_transfer: try: wrtr.write(self.camera.grab()) # fname = f + "{:>04d}".format(self.frames_grabbed_so_far)+'.tif' # write_tiff(fname, self.camera.grab()) self.frames_grabbed_so_far += 1 except CameraError: # No more frames self.abort_transfer = True self.camera.uca.stop_readout() wrtr.close() self.readout_over_signal.emit(True) info_message("Saved {0} images in {1} sec".format( self.frames_grabbed_so_far, int(time.time() - tmp))) # Must be signals # self.save_lv_sequence_button.setEnabled(False) # self.abort_transfer_button.setEnabled(False) # self.viewer.show(self.camera.grab()) self.readout_on = False time.sleep(0.05) else: time.sleep(1)