def _run(self): try: self.state = 'run' self.apply_parameters() if self.run_time >= self.stop_time: self.state = 'done' return ha.PulseGenerator().Sequence([ (['hmc_trigger'], self.t_pi12_NV), ([], self.time_Hahn), (['hmc_trigger'], self.t_pi_NV), (['mw'], self.t_pi_electrons), ([], self.time_Hahn - self.t_pi_electrons), (['hmc_trigger'], self.t_pi12_NV), (['laser', 'trigger'], self.laser), ([], self.wait) ]) n = len(self.frequency) MW_HMC.setFrequency(self.frequency_NV) MW_HMC.setPower(self.power_NV) MW.setPower(self.power) MW.initSweep(self.frequency, self.power * np.ones(self.frequency.shape)) ha.Counter().configure(n, self.seconds_per_point, DutyCycle=0.8) time.sleep(0.5) while self.run_time < self.stop_time: start_time = time.time() if threading.currentThread().stop_request.isSet(): break ha.Microwave().resetListPos() counts = ha.Counter().run() / 1e3 self.run_time += time.time() - start_time self.counts += counts self.counts_matrix = np.vstack( (counts, self.counts_matrix[:-1, :])) self.trait_property_changed('counts', self.counts) if self.run_time < self.stop_time: self.state = 'idle' else: self.state = 'done' ha.Microwave().setOutput(None, self.frequency_begin) ha.Microwave_HMC().Off() ha.PulseGenerator().Light() ha.Counter().clear() except: logging.getLogger().exception('Error in odmr.') self.state = 'error' finally: ha.Microwave().setOutput(None, self.frequency_begin) ha.Microwave_HMC().Off()
def apply_parameters(self): """Apply the current parameters and decide whether to keep previous data.""" if self.pulsed==False: frequency = np.arange(self.frequency_begin, self.frequency_end+self.frequency_delta, self.frequency_delta) ha.Microwave().setPower(self.power) ha.Microwave().initSweep( self.frequency, self.power*np.ones(self.frequency.shape)) else: frequency = np.arange(self.frequency_beginp, self.frequency_endp+self.frequency_deltap, self.frequency_deltap) ha.Microwave().setPower(self.powerp) ha.Microwave().initSweep( self.frequency, self.powerp*np.ones(self.frequency.shape)) if not self.keep_data or np.any(frequency != self.frequency): self.frequency = frequency self.counts = np.zeros(frequency.shape) self.run_time = 0.0 self.keep_data = True # when job manager stops and starts the job, data should be kept. Only new submission should clear data.
def _run(self): """Acquire data.""" try: # try to run the acquisition from start_up to shut_down self.state = 'run' self.apply_parameters() ha.PulseGenerator().Night() ha.Microwave().setOutput(self.mwA_power, self.mwA_frequency) ha.MicrowaveD().setOutput(self.mwB_power, self.mwB_frequency) tagger = ha.TimeTagger.Pulsed(self.n_bins, int(np.round(self.bin_width * 1000)), 1, 0, 2, 3) tagger.setMaxCounts(self.sweeps_per_point) ha.PulseGenerator().Sequence(self.sequence) ha.RFSource().setMode() while True: if self.thread.stop_request.isSet(): break t_start = time.time() for i, fi in enumerate(self.frequencies): # ESR: #ha.Microwave().setOutput(self.mw_power,fi) ha.RFSource().setOutput(self.rf_power, fi) tagger.clear() while not tagger.ready(): time.sleep(1.1 * self.seconds_per_point) self.count_data[i, :] += tagger.getData()[0] self.trait_property_changed('count_data', self.count_data) self.run_time += time.time() - t_start del tagger ha.PulseGenerator().Light() ha.Microwave().setOutput(None, self.mwA_frequency) ha.MicrowaveD().setOutput(None, self.mwB_frequency) ha.RFSource().setOutput(None, self.rf_begin) finally: # if anything fails, recover self.state = 'idle' ha.PulseGenerator().Light()
def _run(self): try: self.state = 'run' self.apply_parameters() if self.run_time >= self.stop_time: self.state = 'done' return # if pulsed, turn on sequence if self.pulsed: ha.PulseGenerator().Sequence( 100 * [(['laser', 'aom', 'red'], self.laser), ([], self.wait), (['mw'], self.t_pi)]) else: ha.PulseGenerator().Open() n = len(self.frequency) """ ha.Microwave().setOutput( self.power, np.append(self.frequency,self.frequency[0]), self.seconds_per_point) self._prepareCounter(n) """ ha.Microwave().setPower(self.power) ha.Microwave().initSweep( self.frequency, self.power * np.ones(self.frequency.shape)) ha.Counter().configure(n, self.seconds_per_point, DutyCycle=0.8) time.sleep(0.5) while self.run_time < self.stop_time: start_time = time.time() if threading.currentThread().stop_request.isSet(): break ha.Microwave().resetListPos() counts = ha.Counter().run() self.run_time += time.time() - start_time self.counts += counts self.counts_matrix = np.vstack( (counts, self.counts_matrix[:-1, :])) self.trait_property_changed('counts', self.counts) """ ha.Microwave().doSweep() timeout = 3. start_time = time.time() while not self._count_between_markers.ready(): time.sleep(0.1) if time.time() - start_time > timeout: print "count between markers timeout in ODMR" break counts = self._count_between_markers.getData(0) self._count_between_markers.clean() """ if self.run_time < self.stop_time: self.state = 'idle' else: self.state = 'done' ha.Microwave().setOutput(None, self.frequency_begin) ha.PulseGenerator().Light() ha.Counter().clear() except: logging.getLogger().exception('Error in odmr.') self.state = 'error' finally: ha.Microwave().setOutput(None, self.frequency_begin)
def shut_down(self): ha.PulseGenerator().Light() ha.Microwave().setOutput(None, self.mw_frequency) ha.RFSource().setOutput(None, self.rf_frequency)
def start_up(self): ha.PulseGenerator().Night() ha.Microwave().setOutput(self.mw_power, self.mw_frequency) ha.RFSource().setOutput(self.rf_power, self.rf_frequency) ha.RFSource().setMode()
def _run(self): try: self.state = 'run' self.apply_parameters() if self.run_time >= self.stop_time: self.state = 'done' return n = len(self.detuning_mesh) self.red_monitor = ha.LaserRed().check_status() if self.red_monitor == 'off': ha.LaserRed().on() time.sleep(7.0) self.red_monitor = ha.LaserRed().check_status() #ha.LaserRed().set_output(self.current, self.wavelength) ha.Microwave().setOutput(self.mw_power, self.mw_frequency) time.sleep(0.5) if self.switch == 'scan wave': ha.LaserRed().scan(self.scan_begin, self.scan_end, self.scan_rate) self.wavelength_monitor = ha.LaserRed().get_wavelength() self.detuning_monitor = ha.LaserRed().get_detuning() while self.run_time < self.stop_time: start_time = time.time() if threading.currentThread().stop_request.isSet(): break if self.green == 'pulse': if self.mw == 'on': ha.PulseGenerator().Continuous( ['mw', 'mw_x', 'red', 'green']) else: ha.PulseGenerator().Continuous(['red', 'green']) time.sleep(self.green_length) if self.mw == 'on' and self.green == 'on': ha.PulseGenerator().Continuous( ['green', 'mw', 'mw_x', 'red']) elif self.mw == 'off' and self.green == 'on': ha.PulseGenerator().Continuous(['green', 'red']) elif self.mw == 'on' and (self.green == 'off' or self.green == 'pulse'): ha.PulseGenerator().Continuous(['mw', 'mw_x', 'red']) elif self.mw == 'off' and (self.green == 'off' or self.green == 'pulse'): ha.PulseGenerator().Continuous(['red']) if self.lock_box: #voltage = ha.LaserRed()._detuning_to_voltage(self.detuning_end) step = (self.detuning_begin - self.detuning_end) / float( self.number_points) detuning_mesh = np.arange(self.detuning_end, self.detuning_begin, step) counts = ha.LaserRed().piezo_scan(detuning_mesh, self.seconds_per_point) junk = ha.LaserRed().piezo_scan(self.detuning_mesh, self.seconds_per_point) self.single_line_counts = counts self.counts += counts self.trait_property_changed('counts', self.counts) self.counts_matrix = np.vstack( (counts, self.counts_matrix[:-1, :])) time.sleep(0.1) else: counts = ha.LaserRed().piezo_scan(self.detuning_mesh, self.seconds_per_point) #ha.LaserRed().set_detuning(self.detuning_begin) #time.sleep(0.1) self.run_time += time.time() - start_time self.single_line_counts = counts self.counts += counts self.trait_property_changed('counts', self.counts) self.counts_matrix = np.vstack( (counts, self.counts_matrix[:-1, :])) """ return to origin """ voltage = ha.LaserRed()._detuning_to_voltage( self.detuning_end) junks = ha.LaserRed().ni_task.line( np.arange(voltage, -3.0, ha.LaserRed()._detuning_to_voltage(-0.1)), 0.001) ha.LaserRed().ni_task.point(-3.0) voltage = ha.LaserRed()._detuning_to_voltage( self.detuning_begin) if voltage > -2.90: junks = ha.LaserRed().ni_task.line( np.arange(-3.0, voltage, ha.LaserRed()._detuning_to_voltage(0.1)), 0.001) ha.LaserRed().ni_task.point(voltage) time.sleep(0.1) self.wavelength_monitor = ha.LaserRed().get_wavelength() self.detuning_monitor = ha.LaserRed().get_detuning() if self.run_time < self.stop_time: self.state = 'idle' else: self.state = 'done' if self.switch == 'scan wave': ha.LaserRed().stop_scan() ha.LaserRed().set_detuning(self.detuning) #ha.Microwave().setOutput(None, self.mw_frequency) if self.light == 'light': ha.PulseGenerator().Light() ha.Microwave().setOutput(None, self.mw_frequency) elif self.off_red == 'on': if self.off_green == 'on' and self.off_mw == 'on': ha.PulseGenerator().Continuous( ['mw', 'mw_x', 'red', 'green']) elif self.off_green == 'off' and self.off_mw == 'on': ha.PulseGenerator().Continuous(['mw', 'mw_x', 'red']) elif self.off_green == 'on' and self.off_mw == 'off': ha.Microwave().setOutput(None, self.mw_frequency) ha.PulseGenerator().Continuous(['red', 'green']) elif self.off_green == 'off' and self.off_mw == 'off': ha.Microwave().setOutput(None, self.mw_frequency) ha.PulseGenerator().Continuous(['red']) else: ha.Microwave().setOutput(None, self.mw_frequency) ha.PulseGenerator().Night() except: logging.getLogger().exception('Error in PLE.') self.state = 'error'
def _off_mw_control(self): if self.state == 'idle': if self.off_mw == 'on': ha.Microwave().setOutput(self.mw_power, self.mw_frequency) else: ha.Microwave().setOutput(None, self.mw_frequency)