def print_save_cr_check_info(cr_stats,rep_nr): qt.msleep(1) adpars_lt1 = adwin_lt1.get_remote_tpqi_control_var('par') adpars_lt2 = adwin_lt2.get_remote_tpqi_control_var('par') lt1_cnts_below = adpars_lt1[1][1] lt1_cr_checks = adpars_lt1[0][1] lt2_cnts_below = adpars_lt2[3][1] lt2_cr_checks = adpars_lt2[2][1] TPQI_starts = adpars_lt2[15][1] lt1_repump_cts = adpars_lt1[8][1] lt1_triggers_received= adpars_lt1[11][1] lt1_oks_sent = adpars_lt1[7][1] lt2_repump_cts= adpars_lt2[0][1] lt2_triggers_sent= adpars_lt2[10][1] lt2_oks_received = adpars_lt2[17][1] #print 'lt1 : CR below threshold: ', lt1_cnts_below #print 'lt1 : CR checks: ', lt1_cr_checks #print 'lt2 : CR below threshold: ', lt2_cnts_below #print 'lt2 : CR checks: ', lt2_cr_checks print rep_nr, ': TPQI starts during the cycle = ', TPQI_starts #print ' adwin check-trigger difference:', lt2_triggers_sent - lt1_triggers_received #print ' adwin ok-trigger difference: ', lt1_oks_sent - lt2_oks_received #print '' cr_stats.add_data_point(rep_nr,lt1_cnts_below,lt1_cr_checks, lt2_cnts_below,lt2_cr_checks,TPQI_starts,lt1_repump_cts, lt2_repump_cts,lt1_triggers_received,lt2_triggers_sent, lt1_oks_sent,lt2_oks_received)
def measure(self, measurement_time, noof_reps = 1E6, RAW = False): today = time.strftime('%Y%m%d') curr_time = time.strftime('%H%M%S') self.save_folder = os.path.join(r'D:\measuring\data', today, curr_time+'_HydraHarp_Live') if not(os.path.exists(os.path.split(self.save_folder)[0])): os.mkdir(os.path.split(self.save_folder)[0]) if not(os.path.exists(self.save_folder)): os.mkdir(self.save_folder) self.noof_reps = noof_reps sync_separation = self.sync_rep_rate self.generate_sequence() hharp.start_T3_mode() hharp.calibrate() hharp.set_Binning(8) hharp.StartMeas(int(measurement_time*1e3)) qt.msleep(0.5) awg.start() accumulated_data = self.get_T3_pulsed_events( sync_separation, start_ch0 = 0, start_ch1 = 0, max_pulses = 2, save_raw = RAW, raw_max_len = 1E6, sleep_time = 1000E-3) awg.stop() dts = self.process_accumulated_data(accumulated_data, rawfile = RAW) return accumulated_data, dts
def start_measurement(self,generate_sequence,pulse_dict,lt1=False,ssro_dict={},): # Prepare MW source and counters print 'Setting MW freq to ' print (self.f_drive*1e-9) self.microwaves.set_iq('on') self.microwaves.set_frequency(self.f_drive) self.microwaves.set_pulm('on') self.microwaves.set_power(self.mwpower) self.counters.set_is_running(False) #Generate sequence and send to AWG sequence = generate_sequence(sweep_param,pulse_dict,lt1) self.par['RO_repetitions'] = int(len(self.sweep_param)*self.par['reps_per_datapoint']) self.par['sweep_length'] = int(len(self.sweep_param)) self.par['sequence_wait_time'] = int(np.ceil(sequence["max_seq_time"]/1e3)+2) self.par['min_sweep_par'] = sweep_param.min() self.par['max_sweep_par'] = sweep_param.max() awg.set_runmode('SEQ') awg.start() while awg.get_state() != 'Waiting for trigger': qt.msleep(1) self.microwaves.set_status('on') qt.msleep(1) self.spin_control(lt1,ssro_dict=ssro_dict) self.end_measurement()
def measure_2D_AWG(self): ''' x_vec is sequence in AWG ''' if self.y_set_obj == None: print 'axes parameters not properly set...aborting' return qt.mstart() qt.msleep() #if stop button was pressed by now, abort without creating data files self.mode = 3 #1: 1D, 2: 2D, 3:1D_AWG/2D_AWG self._prepare_measurement_file() if self.show_progress_bar: p = Progress_Bar(len(self.y_vec),name=self.dirname) try: # measurement loop for it in range(len(self.y_vec)): qt.msleep() # better done during measurement (waiting for trigger) self.y_set_obj(self.y_vec[it]) self._append_data(iteration=it) if self.show_progress_bar: p.iterate() finally: self._end_measurement() qt.mend()
def get2trace(self,trace1,trace2): ''' reades 2 traces from znb Input: trace (string) Output: None ''' logging.info(__name__ + ' : start to measure and wait till it is finished') while self._visainstrument.query('*ESR?') != '1': qt.msleep(0.1) else: self._visainstrument.write('calc:parameter:sel "%s"' %(trace1)) dstring=self._visainstrument.query('calculate:Data? Sdata') dstringclean=dstring.split(';')[0] real1,im1= np.reshape(np.array(dstringclean.split(','),dtype=float),(-1,2)).T self._visainstrument.write('calc:parameter:sel "%s"' %(trace2)) dstring=self._visainstrument.query('calculate:Data? Sdata') dstringclean=dstring.split(';')[0] real2,im2= np.reshape(np.array(dstringclean.split(','),dtype=float),(-1,2)).T return real1+im1*1j,real2+im2*1j
def measure_2D(self): if self.x_set_obj == None or self.y_set_obj == None: print 'axes parameters not properly set...aborting' return if self.ReadoutTrace: raise ValueError('ReadoutTrace is currently not supported for 2D measurements') qt.mstart() self.mode = 2 #1: 1D, 2: 2D, 3:1D_AWG/2D_AWG self._prepare_measurement_file() #self._create_dat_plots(mode='2d') if self.show_progress_bar: p = Progress_Bar(len(self.x_vec)*len(self.y_vec),name=self.dirname) try: # measurement loop for x in self.x_vec: self.x_set_obj(x) for y in self.y_vec: qt.msleep() self.y_set_obj(y) qt.msleep() self._append_data() if self.show_progress_bar: p.iterate() self._hdf_amp.next_matrix() self._hdf_pha.next_matrix() finally: self._end_measurement() qt.mend()
def scan_to_voltage(self, voltage, pts=101, dwell_time=0.03): print 'scan red laser to start voltage ...', #print 'current voltage: ' + str(self.get_laser_voltage()) for v in np.linspace(self.get_laser_voltage(), voltage, pts): self.set_laser_voltage(v) qt.msleep(dwell_time) print 'done.'
def iv(self, channel, start=0, stop=3, step=0.2, delay=0.2): ''' Take an IV on channel chan: - start / stop in V - steps ''' biaspar = 'bias%d' % channel vmeaspar = 'vmeas%d' % channel r = self.get_resistance() / 1000.0 # Not sure why this is dividing. Bug? n = (int(abs(stop - start) / step)) + 1 data = qt.Data(name='iv') data.add_coordinate('Vbias', units='V') data.add_value('Vmeas', units='V') data.create_file() for i in range(n): v_out = start + i * step current = v_out/r self.set(biaspar, v_out, check=False) qt.msleep(delay) v_meas = self.get(vmeaspar) print 'v_out, current_out, v_meas: %f, %f, %f' %(v_out, current, v_meas) data.add_data_point(v_out, v_meas) self.set(biaspar, 0) qt.plot(data, name='iv', clear=True) return data
def setup(self, wait_for_awg=True, mw=True): ssro.IntegratedSSRO.setup(self) if mw: self.mwsrc.set_iq('on') self.mwsrc.set_pulm('on') self.mwsrc.set_frequency(self.params['mw_frq']) self.mwsrc.set_power(self.params['mw_power']) self.mwsrc.set_status('on') self.awg.set_runmode('SEQ') self.awg.start() if wait_for_awg: i=0 awg_ready = False while not awg_ready and i<40: if (msvcrt.kbhit() and (msvcrt.getch() == 'x')): raise Exception('User abort while waiting for AWG') try: if self.awg.get_state() == 'Waiting for trigger': awg_ready = True except: print 'waiting for awg: usually means awg is still busy and doesnt respond' print 'waiting', i, '/ 40' i=i+1 qt.msleep(0.5) if not awg_ready: raise Exception('AWG not ready')
def ampratio_optimize(start=0.2,end=4.501,step=0.01,minimum = 0.0,ch2_amp=1.0): AWG.set_ch2amp(ch2_amp) length = len(np.arange(start,end,step)) result = np.zeros((3,length)) temp = 0 for x in np.arange(start,end,step): AWG.set_ch1amp(x) qt.msleep(0.1) result[0][temp] = x/ch2_amp result[1][temp] = MXA.marker_Y_value() if (minimum<result[1][temp]): pass else: minimum = result[1][temp] ratio = result[0][temp] ch1_amp = x temp = temp + 1 result[2][0] = minimum result[2][1] = ratio result[2][2] = ch1_amp AWG.set_ch1amp(ch2_amp*ratio) return result
def _set_position(self, angle): ''' Rotate the stepper motor Input: angle (float) : angle to rotate to. Output: None ''' substeps = 256 angle_per_step = 1.8 steps = int(substeps/angle_per_step*angle) # convert to a valid hexadecimal instruction str = self.convert_to_valid_hex_instr(4, 0, steps) # write to motor self._visains.write(str) pos = self._get_position() if pos is not None: if np.sign(pos*angle) != -1: deltaA = np.abs(pos - angle) else: deltaA = np.abs(pos)+np.abs(angle) sleep_time = deltaA/(self.get_speed()*4.2) else: sleep_time = 360/(self.get_speed()*4.2) qt.msleep(sleep_time) self._position = angle
def start_measurement(self, generate_sequence, pulse_dict, lt1=False, ssro_dict={}): # Prepare MW source and counters print "Setting MW freq to " print (self.f_drive * 1e-9) self.microwaves.set_iq("on") self.microwaves.set_frequency(self.f_drive) self.microwaves.set_pulm("on") self.microwaves.set_power(self.mwpower) self.counters.set_is_running(False) # Generate sequence and send to AWG sequence = generate_sequence(self.par["sweep_par"], pulse_dict, lt1) self.par["RO_repetitions"] = int(len(self.par["sweep_par"]) * self.par["reps_per_datapoint"]) self.par["sweep_length"] = int(len(self.par["sweep_par"])) self.par["sequence_wait_time"] = int(np.ceil(sequence["max_seq_time"] / 1e3) + 2) self.par["min_sweep_par"] = self.par["sweep_par"].min() self.par["max_sweep_par"] = self.par["sweep_par"].max() self.awg.set_runmode("SEQ") self.awg.start() while self.awg.get_state() != "Waiting for trigger": qt.msleep(1) self.microwaves.set_status("on") qt.msleep(1) self.spin_control(lt1, ssro_dict=ssro_dict) self.end_measurement()
def initialize(self): #OK! """ Initialize and Start. The function initializes internal data and starts an event loop for data acquisition. It discovers devices connected to the computer, and connects to the first device that matches the given device ID. (The device ID is an identification number programmed by the user.) The function should be called before any other TDC functions, except TDC_getVersion and TDC_getTimebase . Input: deviceId Identification number of the device to connect. The special value -1 matches all devices. Returns: Error code """ ans = self.qutools_dll.TDC_init(self.dev_nr) qt.msleep(0.02) return self.err_dict[ans]
def optimize(): awg.set_ch4_marker1_low(0) adwin_lt1.set_simple_counting() adwin_lt2.set_simple_counting() ins_green_aom_lt1.set_power(par_opt_lt1_green_power) ins_green_aom_lt2.set_power(par_opt_lt2_green_power) print 'Simple counting' qt.msleep(5) if (adwin_lt1.get_countrates()[1] < par_opt_min_cnts_lt1): print 'optimizing lt1: countrate', adwin_lt1.get_countrates()[1] ins_optimiz0r_lt1.optimize(cnt=2) if (adwin_lt2.get_countrates()[0] < par_opt_min_cnts_lt2): print 'optimizing lt2: countrate', adwin_lt2.get_countrates()[0] ins_optimiz0r_lt2.optimize(cnt=1) #check for bad suppression awg.set_ch4_marker1_low(0.3) if adwin_lt1.get_countrates()[0] > par_zpl_cts_break \ or adwin_lt2.get_countrates()[1] > par_zpl_cts_break: awg.set_ch4_marker1_low(0) return False awg.set_ch4_marker1_low(0) ins_green_aom_lt1.set_power(0) ins_green_aom_lt2.set_power(0) print 'Optimisation step completed' return True
def power_and_mw_ok(self): ret = True max_E_power = self.ins_E_aom.get_cal_a() max_A_power = self.ins_A_aom.get_cal_a() if ( (max_E_power < self.par["Ex_CR_amplitude"]) or (max_E_power < self.par["Ex_SP_amplitude"]) or (max_E_power < self.par["Ex_RO_amplitude"]) ): print "Trying to set too large value for E laser, quiting!" ret = False if ( (max_A_power < self.par["A_CR_amplitude"]) or (max_A_power < self.par["A_SP_amplitude"]) or (max_A_power < self.par["A_RO_amplitude"]) ): print "Trying to set too large value for A laser, quiting" ret = False if self.mwpower > 0: print "MW power > 0 dBm, are you sure you want to continue? Press q to quit, c to continue." idx = 0 max_idx = 5 kb_hit = None while (idx < max_idx) and kb_hit == None: kb_hit = msvcrt.getch() if kb_hit == "q": ret = False if kb_hit == "c": ret = True qt.msleep(1) idx += 1 return ret
def optimize(): NewfocusAOM.set_power(0e-9) MatisseAOM.set_power(0e-9) GreenAOM.set_power(20e-6) qt.msleep(5) optimiz0r.optimize(cnt=1, cycles=2, int_time=30) qt.msleep(5)
def main(): m.generate_sequence() adpar["max_LDE_duration"] = int(m.seq.element_lengths["lde"] * float(m.max_LDE_attempts) * 1e6 + 1.0) for idx in arange(m.measurement_cycles): m.setup(adwin_mdevice_lt2=adwin_mdevice_lt2) print "=============================" print "Starting measurement cycle", idx print "current time:", time.strftime("%H:%M", time.localtime()) print "=============================" ch0, ch1, mrkr = m.measure(adwin_lt2_params=adpar) addata = m.get_adwin_data() m.save(ch0_events=ch0, ch1_events=ch1, markers=mrkr, **addata) if m.measurement_cycles != 0: print "Press q to abort next cycle" qt.msleep(2) if msvcrt.kbhit(): kb_char = msvcrt.getch() if kb_char == "q": break # if idx < m.measurement_cycles-1: m.optimize(lt1 = False, lt2 = True) # if False in m.check_suppression(lt1 = False, lt2 = True): # print 'Bad suppression detected, breaking.' # break m.end() print "Measurement finished!"
def sideband(center_freq,sideband_freq,marker_value,markernum,sideband='up'): center_freq = center_freq*1E9 sideband_freq = sideband_freq*1E9 up_side = center_freq + sideband_freq down_side = center_freq - sideband_freq test = False while (test == False): marker_center = np.abs(marker_value - center_freq) if (sideband == 'up'): marker_sideband = np.abs(marker_value - up_side) if (marker_center > marker_sideband): test = True else: MXA.next_peak_right() qt.msleep(0.1) marker_value = MXA.marker_X_value() if (sideband == 'down'): marker_sideband = np.abs(marker_value - down_side) if (marker_center > marker_sideband): test = True else: MXA.next_peak_left() qt.msleep(0.1) marker_value = MXA.marker_X_value()
def get_trace(self, mode='lin'): ''' Send trigger to device, wait for aquiring the data, and read back the data from the device. ''' qt.mstart() startfreq = self.get_start_freq(query=False) stopfreq = self.get_stop_freq(query=False) numpoints = self.get_numpoints(query=False) if mode=='lin': freqs = numpy.linspace(startfreq,stopfreq,numpoints) elif mode=='log': freqs = numpy.logspace(numpy.log10(startfreq),numpy.log10(stopfreq),numpoints) else: print 'mode needs to be either "lin" or "log"!' return False sweep_time = self.get_sweep_time(query=False) print 'sending trigger to network analyzer, and wait to finish' print 'estimated waiting time: %.2f s' % sweep_time self.send_trigger() qt.msleep(sweep_time) print 'readout network analyzer' reply = self.read() reply = numpy.array(reply) qt.mend() return (freqs, reply)
def calibrate_MBI_fidelity_RO_pulses(name): m = pulsar_msmt.ElectronRabi('MBI_fidelity_RO_pulses_'+name) m.params.from_dict(qt.cfgman['protocols']['AdwinSSRO']) m.params.from_dict(qt.cfgman['protocols']['AdwinSSRO+espin']) funcs.prepare(m) m.params['pts'] = 21 pts = m.params['pts'] m.params['repetitions'] = 5000 m.params['MBI_calibration_RO_pulse_duration'] = 8.3e-6 m.params['MBI_calibration_RO_pulse_amplitude_sweep_vals'] = np.linspace(0.002,0.007,pts) m.params['MBI_calibration_RO_pulse_mod_frqs'] = \ m.params['ms-1_cntr_frq'] - m.params['mw_frq'] + \ np.array([-1,0,+1]) * m.params['N_HF_frq'] m.params['MW_pulse_durations'] = np.ones(pts) * m.params['MBI_calibration_RO_pulse_duration'] m.params['MW_pulse_amplitudes'] = m.params['MBI_calibration_RO_pulse_amplitude_sweep_vals'] m.params['sweep_name'] = 'Pulse amplitudes (V)' m.params['sweep_pts'] = m.params['MW_pulse_amplitudes'] m.params['sequence_wait_time'] = \ int(np.ceil(np.max(m.params['MW_pulse_durations'])*1e6)+10) for i,f in enumerate(m.params['MBI_calibration_RO_pulse_mod_frqs']): m.params['MW_pulse_frequency'] = f m.autoconfig() m.generate_sequence(upload=True) m.run() m.save('line-{}'.format(i)) m.stop_sequence() qt.msleep(1) m.finish()
def start_measurement(self,generate_sequence,pulse_dict,lt1=False,ssro_dict={},send_sequence_AWG=True): # Prepare MW source and counters print 'Setting MW freq to ' print (self.f_drive*1e-9) self.microwaves.set_iq('on') self.microwaves.set_frequency(self.f_drive) self.microwaves.set_pulm('on') self.microwaves.set_power(self.mwpower) self.counters.set_is_running(False) #Generate sequence and send to AWG if send_sequence_AWG: sequence = generate_sequence(self.par['sweep_par'],pulse_dict,lt1) else: sequence=self.sequence #sequence["max_seq_time"]=100000 self.par['RO_repetitions'] = int(len(self.par['sweep_par'])*self.par['reps_per_datapoint']) self.par['sweep_length'] = int(len(self.par['sweep_par'])) print 'seq max time in start meas' print int(np.ceil(sequence["max_seq_time"])+10) self.par['sequence_wait_time'] = int(np.ceil(sequence["max_seq_time"])+10) self.awg.set_runmode('SEQ') self.awg.start() while self.awg.get_state() != 'Waiting for trigger': qt.msleep(1) self.microwaves.set_status('on') qt.msleep(1) self.spin_control(lt1,ssro_dict=ssro_dict) self.end_measurement()
def power_and_mw_ok(): ret = True max_E_power = ins_E_aom.get_cal_a() max_A_power = ins_A_aom.get_cal_a() if (max_E_power < par['Ex_CR_amplitude']) or \ (max_E_power < par['Ex_SP_amplitude']) or \ (max_E_power < par['Ex_RO_amplitude']): print 'Trying to set too large value for E laser, quiting!' ret = False if (max_A_power < par['A_CR_amplitude']) or \ (max_A_power < par['A_SP_amplitude']) or \ (max_A_power < par['A_RO_amplitude']): print 'Trying to set too large value for A laser, quiting' ret = False if mwpower > 0: print 'MW power > 0 dBm, are you sure you want to continue? Press q to quit, c to continue.' idx = 0 max_idx = 5 kb_hit = None while (idx<max_idx) and kb_hit == None: kb_hit = msvcrt.getch() if kb_hit == 'q': ret = False if kb_hit == 'c': ret = True qt.msleep(1) idx += 1 return ret
def measure_2D(self): if self.x_set_obj == None or self.y_set_obj == None: print 'axes parameters not properly set...aborting' return qt.mstart() self._prepare_measurement_dat_file(mode='2d') self._create_dat_plots(mode='2d') p = Progress_Bar(len(self.x_vec)*len(self.y_vec),name=self.dirname) try: # measurement loop for x in self.x_vec: self.x_set_obj(x) if self.save_dat: self.data_raw.new_block() for y in self.y_vec: qt.msleep() # better done during measurement (waiting for trigge self.y_set_obj(y) #sleep(self.tdy) qt.msleep() # better done during measurement (waiting for trigger) self._append_data([x,y],trace=False) self._update_plots() p.iterate() finally: self._safe_plots() self._close_files() qt.mend()
def print_save_cr_check_info(cr_stats,rep_nr): qt.msleep(1) lt1_cnts_below = adwin_lt1.remote_tpqi_control_get_cr_below_threshold_events() lt1_cr_checks = adwin_lt1.remote_tpqi_control_get_noof_cr_checks() lt2_cnts_below = adwin_lt2.remote_tpqi_control_get_cr_below_threshold_events() lt2_cr_checks = adwin_lt2.remote_tpqi_control_get_noof_cr_checks() TPQI_starts = adwin_lt2.remote_tpqi_control_get_noof_tpqi_starts() lt1_repump_cts= adwin_lt1.remote_tpqi_control_get_repump_counts() lt2_repump_cts= adwin_lt2.remote_tpqi_control_get_repump_counts() lt1_triggers_received= adwin_lt1.remote_tpqi_control_get_noof_trigger() lt2_triggers_sent= adwin_lt2.remote_tpqi_control_get_noof_triggers_sent() lt1_oks_sent = adwin_lt1.remote_tpqi_control_get_noof_oks_sent() lt2_oks_received = adwin_lt2.remote_tpqi_control_get_noof_lt1_oks() lt1_succes =100.*( 1.-(float(lt1_cnts_below)/lt1_cr_checks)) lt2_succes = 100.*(1.-(float(lt2_cnts_below)/lt2_cr_checks)) print 'lt1 : CR succes_percentage: ', lt1_succes print 'lt1 : CR checks: ', lt1_cr_checks print 'lt2 : CR succes_percentage: ', lt2_succes print 'lt2 : CR checks: ', lt2_cr_checks print 'tpqi starts: ', TPQI_starts print ' adwin check-trigger difference:', lt2_triggers_sent - lt1_triggers_received print ' adwin ok-trigger difference: ', lt1_oks_sent - lt2_oks_received print '' cr_stats.add_data_point(rep_nr,lt1_succes,lt1_cr_checks, lt2_succes,lt2_cr_checks,TPQI_starts,lt1_repump_cts, lt2_repump_cts,lt1_triggers_received,lt2_triggers_sent, lt1_oks_sent,lt2_oks_received)
def __ask(self, msg): logging.debug('Sending %s', ["0x%02x" % ord(c) for c in msg]) for attempt in range(3): try: serial_connection = serial.Serial(self._serialportno, baudrate=9600, bytesize=8, dsrdtr=False, interCharTimeout=None, parity='N', rtscts=False, stopbits=1, timeout=1., writeTimeout=None) try: serial_connection.write(msg) m = '' while len(m) < 3 or (ord(m[-3]) != self._etx): lastlen = len(m) m += serial_connection.read() if lastlen == len(m): assert False, 'Timeout on serial port read.' finally: serial_connection.close() qt.msleep(.01) except: logging.exception('Attempt %d to communicate with turbo failed', attempt) logging.debug('Got %s', ["0x%02x" % ord(c) for c in m]) return m
def do_set_frequency(self, freq): ''' Set the frequency of the instrument Input: freq (float) : Frequency in MHz Output: None ''' start_frequency = self.get_frequency()/1e6 #print "get_freq"+str(self.get_frequency()) step = self._frequency_step * cmp(freq, start_frequency) step_time = self._frequency_step_time frequency_ramp = [] if not(step == 0): Nramp = int(abs((start_frequency - freq) / step)) #print 'sf'+str(start_frequency) #print 'gf'+str(freq) #print 'step'+str(step) frequency_ramp = [x * step + start_frequency for x in range(Nramp + 1)] frequency_ramp.append(freq) else: frequency_ramp = [start_frequency, freq] for v in frequency_ramp: logging.debug(__name__ + ' : set frequency to %f MHz' % freq) self._visainstrument.write('FREQ:CW %s MHz' % v) qt.msleep(step_time) self.get_frequency() return self.get_frequency()
def do_set_power(self, amp): ''' Set the power of the signal Input: amp (float) : power in dBm Output: None ''' start_power = self.get_power(1) step = self._power_step * cmp(amp, start_power) step_time = self._power_step_time power_ramp = [] if not(step == 0): Nramp = int(abs((start_power - amp) / step)) power_ramp = [x * step + start_power for x in range(Nramp + 1)] power_ramp.append(amp) else: power_ramp = [start_power, amp] for v in power_ramp: logging.debug(__name__ + ' : set power to %f dBm' % amp) self._visainstrument.write('POW:AMPL %s dBm' % v) qt.msleep(step_time) self.get_power() return self.get_power()
def measure_1d_lowpass( self, x_vec, coordname, set_param_func, iterations=1, comment=None, dirname=None, plotLive=True ): """ acquire _averages traces per value in x_vec and store the time-averaged result x_vec - vector of values to pass to set_param_func at the start of each iteration coordname - friendly name of the parameter contained in x_vec set_param_func - parameter values are passed to this function at the start of each iteration comment - comment line in the data file dirname - data is saved in directories named <time>_spec_<dirname> plotLive - plot data during measurement """ qt.mstart() if dirname == None: dirname = coordname data = qt.Data(name="spec_lp_%s" % dirname) if comment: data.add_comment(comment) data.add_coordinate(coordname) data.add_value("ch0") if self._numchannels == 2: data.add_value("ch1") if iterations > 1: data.add_coordinate("iteration") data.create_file() plot_ch0 = qt.Plot2D(data, name="waveform_ch0", coorddim=0, valdim=1, maxtraces=2) if self._numchannels == 2: plot_ch1 = qt.Plot2D(data, name="waveform_ch1", coorddim=0, valdim=2, maxtraces=2) set_param_func(x_vec[0]) # measurement loop for i in range(iterations): data.new_block() for x in x_vec: set_param_func(x) # sleep(td) qt.msleep() # better done during measurement (waiting for trigger) dat_x = [x] dat_mean = numpy.mean(self.acquire(), axis=0) dat = numpy.append(dat_x, dat_mean, axis=0) if iterations > 1: dat = numpy.append(dat, [i], axis=0) data.add_data_point(*dat) plot_ch0.update() if self._numchannels == 2: plot_ch1.update() plot_ch0.update() plot_ch0.save_png() plot_ch0.save_gp() if self._numchannels == 2: plot_ch1.update() plot_ch1.save_png() plot_ch1.save_gp()
def measure_2D_AWG(self): ''' x_vec is sequence in AWG ''' if self.y_set_obj == None: print 'axes parameters not properly set...aborting' return qt.mstart() qt.msleep() #if stop button was pressed by now, abort without creating data files self._prepare_measurement_dat_file(mode='2dAWG') self._create_dat_plots(mode='2dAWG') p = Progress_Bar(len(self.y_vec),name=self.dirname) try: # measurement loop for it in range(len(self.y_vec)): qt.msleep() # better done during measurement (waiting for trigger) self.y_set_obj(self.y_vec[it]) self._append_data([self.y_vec[it]],trace=True,it=it) self._update_plots() p.iterate() #except Exception as e: # print e finally: self._safe_plots() self._generate_avg_data(final=True) self._close_files() qt.mend()
def trigger_average_count_times(self, count=None, autoscale_after_first_sweep=False): ''' Calls single() average_count (or count, if specified) times. Input: None Output: None ''' t0 = time.time() t1 = t0 for i in range(self.get_average_count() if count==None else count): # measure the time it took to complete the loop t0 = t1 t1 = time.time() self.single(block_until_done = False) if i>0: # sleep until the sweep is almost done sleeping = np.max(( 0., (t1 - t0) - 10. )) logging.debug('Sleeping %.2e seconds before asking for OPC.' % sleeping) qt.msleep(sleeping) self.block_until_operation_complete() if i==0 and autoscale_after_first_sweep: for j in range(4): self.autoscale(1+j)
def scan_to_voltage(self, voltage, pts=51, dwell_time=0.05): #print 'scan to voltage ...', #print 'current voltage: ' + str(self.get_laser_voltage()) for v in np.linspace(self.get_laser_voltage(), voltage, pts): self.set_laser_voltage(v) qt.msleep(dwell_time)
def repump_pulse(self): qt.msleep(1) self.set_repump_power(self.repump_power) qt.msleep(self.repump_duration) self.set_repump_power(0) qt.msleep(1)
FET_parts = len(FET) if stop: break if carbon == 2: el_RO_list = ['negative'] for el_RO in el_RO_list: if stop: break for el_after_init in el_after_init_list: if stop: break for ii in range(FET_parts): print '--------------------------------' print 'press q to stop measurement loop' print '--------------------------------' qt.msleep(5) if (msvcrt.kbhit() and (msvcrt.getch() == 'q')): stop = True break GreenAOM.set_power(25e-6) adwin.start_set_dio(dio_no=4, dio_val=0) optimiz0r.optimize(dims=['x', 'y', 'z', 'x', 'y'], int_time=180) adwin.start_set_dio(dio_no=4, dio_val=0) # MBE(SAMPLE + '_'+ el_RO +'_' + str(carbon) +'_el' + el_after_init +'swap', el_RO= el_RO, carbon = carbon, carbon_init_list = [carbon] # ,carbon_init_methods = ['swap'], carbon_init_thresholds = [0]) NuclearT1_2(SAMPLE + '_' + el_RO + '_C' + str(carbon) + '_el' + el_after_init + '_part' + str(ii + 1), el_RO=el_RO, carbon=carbon,
def __init__(self, name, address, reset=False, change_display=False, change_autozero=False): ''' Initializes the SRS_SIM900, and communicates with the wrapper. Input: name (string) : name of the instrument address (string) : VISA address reset (bool) : resets to default values Output: None ''' # Initialize wrapper functions logging.info('Initializing instrument SRS_SIM900') Instrument.__init__(self, name, tags=['physical', 'measure']) # Add some global constants self.__name__ = name self._address = address self._visainstrument = visa.instrument(self._address) if self._visainstrument.interface_type == 4: # serial? self._visainstrument.term_chars = '\r\n' self._visainstrument.baud_rate = 9600 self._visainstrument.clear() cts = int(self._visainstrument.ask('CTCR?')) self.occupied_ports = [] self.bad_ports = [] self.SIM928_modules = [] # list of the ports of the SIM928 modules self.SIM911_modules = [] # list of the ports of the SIM911 modules self.SIM965_modules = [] # list of the ports of the SIM965 modules for i in range(1, 9): if bin(cts)[-(i + 1)] == '1': self.occupied_ports.append(i) print self.occupied_ports if reset: self.reset() self.sleep_time = 0.08 self.installed_modules = [] self.serial_numbers = [] for port in self.occupied_ports: self._visainstrument.write('SNDT %i,"*IDN?"' % port) qt.msleep(self.sleep_time) idn = self._ask('GETN? %i,80' % port) if idn == '': logging.warning('Module in port %i is not responding ' + 'properly and will not be loaded.' % port) self.bad_ports.append(port) else: print idn self.installed_modules.append((port, idn.split(',')[1])) self.serial_numbers.append((port, idn.split(',')[2])) # internal baud_rate # if this is too high, the communication with the modules # can stall self.module_baud_rate = 38400 self.set_modules_baud_rate() for port in self.bad_ports: self.occupied_ports.remove(port) print(self.installed_modules) print(self.serial_numbers) for port, module in self.installed_modules: if module == 'SIM928': self.SIM928_modules.append(port) self.add_parameter( 'port%i_voltage' % port, flags=Instrument.FLAG_GETSET, type=types.FloatType, units='V', minval=-10.0, maxval=10.0, maxstep=0.1, stepdelay=50, format='%.3f', get_func=self.SIM928_get_voltage, set_func=self.SIM928_set_voltage, channel=port, ) self.add_parameter( 'port%i_status' % port, flags=Instrument.FLAG_GETSET, type=types.BooleanType, get_func=self.SIM928_get_status, set_func=self.SIM928_set_status, channel=port, ) self.add_parameter( 'port%i_battery_status' % port, flags=Instrument.FLAG_GET, type=types.StringType, get_func=self.SIM928_get_battery_status, channel=port, ) self.add_parameter( 'port%i_last_pressed_button' % port, flags=Instrument.FLAG_GET, type=types.StringType, get_func=self.SIM928_get_last_pressed_button, channel=port, ) if module == 'SIM911': self.SIM911_modules.append(port) self.add_parameter( 'port%i_gain' % port, flags=Instrument.FLAG_GETSET, type=types.IntType, option_list=(1, 2, 5, 10, 20, 50, 100), get_func=self.SIM911_get_gain, set_func=self.SIM911_set_gain, channel=port, ) self.add_parameter( 'port%i_coupling' % port, flags=Instrument.FLAG_GET, type=types.StringType, option_list=('AC', 'DC'), get_func=self.SIM911_get_coupling, channel=port, ) self.add_parameter( 'port%i_input' % port, flags=Instrument.FLAG_GET, type=types.StringType, option_list=('A', 'A-B', 'GND'), get_func=self.SIM911_get_input, channel=port, ) self.add_parameter( 'port%i_shield' % port, flags=Instrument.FLAG_GET, type=types.StringType, option_list=('FLOATING', 'GROUNDED'), get_func=self.SIM911_get_shield, channel=port, ) if module == 'SIM965': self.SIM965_modules.append(port) self.add_parameter( 'port{0}_filter_frequency'.format(port), flags=Instrument.FLAG_GETSET, type=types.FloatType, units='Hz', minval=1.0, maxval=5.00e5, get_func=self.SIM965_get_filter_frequency, set_func=self.SIM965_set_filter_frequency, channel=port, ) self.add_parameter( 'port{0}_filter_type'.format(port), flags=Instrument.FLAG_GETSET, type=types.StringType, option_list=['butterworth', 'bessel'], get_func=self.SIM965_get_filter_type, set_func=self.SIM965_set_filter_type, channel=port, ) self.add_parameter( 'port{0}_filter_passband'.format(port), flags=Instrument.FLAG_GETSET, type=types.StringType, option_list=['low pass', 'high pass'], get_func=self.SIM965_get_filter_passband, set_func=self.SIM965_set_filter_passband, channel=port, ) self.add_parameter( 'port{0}_filter_slope'.format(port), flags=Instrument.FLAG_GETSET, type=types.IntType, option_list=[12, 24, 36, 48], units='dB/octave', get_func=self.SIM965_get_filter_slope, set_func=self.SIM965_set_filter_slope, channel=port, ) self.add_parameter( 'port{0}_input_coupling'.format(port), flags=Instrument.FLAG_GET, type=types.StringType, option_list=('AC', 'DC'), get_func=self.SIM965_get_input_coupling, channel=port, ) # Housekeeping parameters self.add_parameter( 'external_timebase', flags=Instrument.FLAG_GET, type=types.BooleanType, ) self.add_parameter( 'timebase_vco_voltage', flags=Instrument.FLAG_GET, type=types.IntType, units='mV', ) self.add_parameter( 'primary_voltage', flags=Instrument.FLAG_GET, type=types.FloatType, units='V', ) self.add_parameter( 'primary_current', flags=Instrument.FLAG_GET, type=types.IntType, units='mA', ) self.add_parameter( 'time_since_power_on', flags=Instrument.FLAG_GET, type=types.FloatType, units='s', format='%.0f', ) self.add_function('reset') self.add_function('get_all') self.get_all()
def SIM928_set_status(self, status, channel): if status: self._visainstrument.write('SNDT %i, "OPON"' % channel) else: self._visainstrument.write('SNDT %i, "OPOF"' % channel) qt.msleep(self.sleep_time)
def SIM928_get_status(self, channel): self._visainstrument.write('FLSH %i' % channel) self._visainstrument.write('SNDT %i, "EXON?"' % channel) qt.msleep(self.sleep_time) return bool(int(self._ask('GETN? %i,80' % channel)))
def measurementloop(settings): number_of_traces = 1 for idx in range(settings['number_of_sweeps'] - 1): number_of_traces = number_of_traces * len(vector_array[idx + 1]) print('total number of traces: %d' % (number_of_traces)) total_traces = number_of_traces starttime = time.time() for v1 in vector_array[settings['number_of_sweeps'] - 1]: useinstruments.execute_set( settings, instrument_array[settings['number_of_sweeps'] - 1], v1) if settings['number_of_sweeps'] > 1: for v2 in vector_array[settings['number_of_sweeps'] - 2]: useinstruments.execute_set( settings, instrument_array[settings['number_of_sweeps'] - 2], v2) if settings['number_of_sweeps'] > 2: for v3 in vector_array[settings['number_of_sweeps'] - 3]: useinstruments.execute_set( settings, instrument_array[settings['number_of_sweeps'] - 3], v3) if settings['number_of_sweeps'] > 3: for v4 in vector_array[settings['number_of_sweeps'] - 4]: useinstruments.execute_set( settings, instrument_array[ settings['number_of_sweeps'] - 2], v4) if settings['number_of_sweeps'] > 4: for v5 in vector_array[ settings['number_of_sweeps'] - 5]: useinstruments.execute_set( settings, instrument_array[ settings['number_of_sweeps'] - 5], v5) useinstruments.measure_inputs( settings, I_gain) data.add_data_point( v5, v4, v3, v2, v1, useinstruments.result[0], useinstruments.result[1], useinstruments.result[2]) qt.msleep(float(settings['pause2'])) update_2d_plots(settings) data.new_block() qt.msleep(float(settings['pause1'])) update_3d_plots(settings) totaltime = number_of_traces * ( time.time() - starttime ) / (total_traces - number_of_traces + 1) print( 'Time of measurement left: %d hours, %d minutes and %d seconds' % (floor(totaltime / 3600), floor(fmod(totaltime, 3600) / 60), fmod(totaltime, 60))) number_of_traces = number_of_traces - 1 else: useinstruments.measure_inputs( settings, I_gain) data.add_data_point( v4, v3, v2, v1, useinstruments.result[0], useinstruments.result[1], useinstruments.result[2]) qt.msleep(float(settings['pause2'])) update_2d_plots(settings) if settings['number_of_sweeps'] == 4: data.new_block() qt.msleep(float(settings['pause1'])) update_3d_plots(settings) totaltime = number_of_traces * ( time.time() - starttime) / ( total_traces - number_of_traces + 1) print( 'Time of measurement left: %d hours, %d minutes and %d seconds' % (floor(totaltime / 3600), floor(fmod(totaltime, 3600) / 60), fmod(totaltime, 60))) number_of_traces = number_of_traces - 1 else: useinstruments.measure_inputs(settings, I_gain) data.add_data_point(v3, v2, v1, useinstruments.result[0], useinstruments.result[1], useinstruments.result[2]) qt.msleep(float(settings['pause2'])) update_2d_plots(settings) if settings['number_of_sweeps'] == 3: data.new_block() qt.msleep(float(settings['pause1'])) update_3d_plots(settings) totaltime = number_of_traces * ( time.time() - starttime) / (total_traces - number_of_traces + 1) print( 'Time of measurement left: %d hours, %d minutes and %d seconds' % (floor(totaltime / 3600), floor(fmod(totaltime, 3600) / 60), fmod(totaltime, 60))) number_of_traces = number_of_traces - 1 else: useinstruments.measure_inputs(settings, I_gain) data.add_data_point(v2, v1, useinstruments.result[0], useinstruments.result[1], useinstruments.result[2]) qt.msleep(float(settings['pause2'])) update_2d_plots(settings) if settings['number_of_sweeps'] == 2: data.new_block() qt.msleep(float(settings['pause1'])) update_3d_plots(settings) totaltime = number_of_traces * (time.time() - starttime) / ( total_traces - number_of_traces + 1) print( 'Time of measurement left: %d hours, %d minutes and %d seconds' % (floor(totaltime / 3600), floor(fmod(totaltime, 3600) / 60), fmod(totaltime, 60))) number_of_traces = number_of_traces - 1 else: useinstruments.measure_inputs(settings, I_gain) data.add_data_point(v1, useinstruments.result[0], useinstruments.result[1], useinstruments.result[2]) qt.msleep(float(settings['pause2'])) update_2d_plots(settings) if settings['plot2d'][0] and settings['input'][0] != 0: plot2d1_end = qt.Plot2D(data, name='measure2D_%s_end' % (settings['inputlabel'][0]), coorddim=0, valdim=settings['number_of_sweeps'], maxpoints=1e6, maxtraces=1e3) plot2d1_end.update() if settings['plot2d'][1] and settings['input'][1] != 0: plot2d2_end = qt.Plot2D(data, name='measure2D_%s_end' % (settings['inputlabel'][1]), coorddim=0, valdim=settings['number_of_sweeps'] + 1, maxpoints=1e6, maxtraces=1e3) plot2d2_end.update() if settings['plot2d'][2] and settings['input'][2] != 0: plot2d3_end = qt.Plot2D(data, name='measure2D_%s_end' % (settings['inputlabel'][2]), coorddim=0, valdim=settings['number_of_sweeps'] + 2, maxpoints=1e6, maxtraces=1e3) plot2d3_end.update() # after the measurement ends, you need to close the data file. data.close_file() if settings['plot2d'][0] and settings['input'][0] != 0: plot2d1_end.save_png() if settings['plot2d'][1] and settings['input'][1] != 0: plot2d2_end.save_png() if settings['plot2d'][2] and settings['input'][2] != 0: plot2d3_end.save_png() if settings['plot3d'][0] and settings['input'][0] != 0: plot3d1.save_png() if settings['plot3d'][1] and settings['input'][1] != 0: plot3d2.save_png() if settings['plot3d'][2] and settings['input'][2] != 0: plot3d3.save_png()
ramp(vi, 'Vb', Vb_start, bias_step_init, bias_time) #ready vm vm.get_all() vm.set_trigger_continuous(False) vm.set_mode_volt_dc() vm.set_range(10) vm.set_nplc(1) #set up data directory qt.config.set('datadir', directory) print directory begintime = time() qt.mstart() qt.msleep(5) #T_mc_st=T_mc() #print 'T_mc_start = %i mK'%T_mc_st print 'Starting an IV meas for B = %s T' % B vm.set_autozero(False) vm.set_nplc(1) if vm.get_autozero() == False: print 'Autozeroing is switched off' spyview_process(0, 0, 0, 0, reset=True) append = '_Vb%smV' % Vb_start + '_B%sT' % B data = qt.Data(name=filename + append) tstr = strftime('%H%M%S_', data._localtime) data.add_coordinate('Vg (V)') #parameter to step data.add_coordinate('Vb (mV)') #parameter to sweep data.add_value('I (nA)') #parameter to readout
def run_scan(self, **kw): stabilizing_time = kw.pop('stabilizing_time', 0.01) d = qt.Data(name=self.mprefix+'_'+self.name) d.add_coordinate('Voltage (V)') d.add_coordinate('Frequency (GHz)') d.add_coordinate('Counts [Hz]') d.add_coordinate('Gate Voltage(V)') p = qt.Plot2D(d, 'ro', title='Frq (left) vs Voltage (bottom)', plottitle=self.mprefix, name='Laser Scan', clear=True, coorddim=0, valdim=1, maxtraces=1) p.add(d, 'bo', title='Counts (right) vs Frq (top)', coorddim=1, valdim=2, right=True, top=True) p.set_x2tics(True) p.set_y2tics(True) p.set_x2label('Frequency (GHz)') p.set_y2label('Counts [Hz]') if self.gate_pts>1: p3=qt.Plot3D(d, name='Laser_Scan2D', plottitle=self.mprefix, coorddims=(1,3), valdim=2, clear=True) qt.mstart() ###### HERE THE MEASUREMENT LOOP STARTS ###### for j,gv in enumerate(np.linspace(self.gate_start_voltage, self.gate_stop_voltage, self.gate_pts)): if (msvcrt.kbhit() and (msvcrt.getch() == 'c')): break self.scan_to_voltage(self.start_voltage) if not self.use_repump_during: self.repump_pulse() if self.set_gate_after_repump: self.gate_scan_to_voltage(gv) for i,v in enumerate(np.linspace(self.start_voltage, self.stop_voltage, self.pts)): if msvcrt.kbhit(): chr=msvcrt.getch() if chr=='q': break elif chr =='r': self.repump_pulse() self.set_laser_voltage(v) qt.msleep(stabilizing_time) cts = float(self.get_counts(self.integration_time)[self.counter_channel])/(self.integration_time*1e-3) frq = self.get_frequency(self.wm_channel)*self.frq_factor - self.frq_offset if frq < 0: continue d.add_data_point(v, frq, cts, gv) if np.mod(i,10)==0: p.update() if self.set_gate_after_repump: self.gate_scan_to_voltage(0.) p.update() if self.plot_strain_lines: p.set_maxtraces(2) try: from analysis.lib.nv import nvlevels Ey_line=float(raw_input('Ey line?')) #GHz Ex_line=float(raw_input('Ex line?')) #GHz lx,ly=nvlevels.get_ES_ExEy_plottable(Ex_line,Ey_line,max(d.get_data()[:,2])) tit=str('Frequency (GHz) lines: [%2.2f,%2.2f,%2.2f,%2.2f,%2.2f,%2.2f] ' % tuple(nvlevels.get_ES_ExEy(Ex_line,Ey_line))) p.add(lx,ly,right=True, top=True, title=tit) except ValueError: print 'Could not understand input for lines' pass plotsavename=os.path.splitext(d.get_filepath())[0] + ('_gate_voltage_%2.3f' % gv) + '.png' p.set_plottitle(str(os.path.splitext(d.get_filename())[0])) p.save_png(filepath=plotsavename) d.new_block() if self.gate_pts>1: p3.update() qt.mend() if self.gate_pts>1: p3.reset() qt.msleep(1) p3.save_png() np.savez(os.path.splitext(d.get_filepath())[0]+ '.npz', data=d.get_data()) d.close_file()
def __init__(self, name, DeviceIndex = 0): #2 # Initialize wrapper logging.info(__name__ + ' : Initializing instrument TH260') Instrument.__init__(self, name, tags=['physical']) # Load dll and open connection self._load_dll() sleep(0.01) LibraryVersion = numpy.array([8*' ']) self._TH260.TH260_GetLibraryVersion(LibraryVersion.ctypes.data) self.LibraryVersion = LibraryVersion if LibraryVersion[0][0:3] != LIB_VERSION: logging.warning(__name__ + ' : DLL Library supposed to be ver.'+LIB_VERSION+' but found ' + LibraryVersion[0] + 'instead.') # print ('HydraHarp DLL version %s loaded...'%str(LibraryVersion)) self.add_parameter('Range', flags = Instrument.FLAG_SET, type=types.IntType) self.add_parameter('Offset', flags = Instrument.FLAG_SET, type=types.IntType, minval=OFFSETMIN, maxval=OFFSETMAX) self.add_parameter('SyncDiv', flags = Instrument.FLAG_SET, type=types.IntType, minval=SYNCDIVMIN, maxval=SYNCDIVMAX) self.add_parameter('ResolutionPS', flags = Instrument.FLAG_GET, type=types.FloatType) self.add_parameter('BaseResolutionPS', flags = Instrument.FLAG_GET, type=types.FloatType) self.add_parameter('MaxBinSteps', flags = Instrument.FLAG_GET, type=types.IntType) self.add_parameter('SyncEdgeTrg', flags = Instrument.FLAG_SET, type=types.IntType, minval=DISCRMIN, maxval=DISCRMAX) self.add_parameter('SyncChannelOffset', flags = Instrument.FLAG_SET, type=types.IntType, minval=CHANOFFSMIN, maxval=CHANOFFSMAX) self.add_parameter('InputEdgeTrg', flags = Instrument.FLAG_SET, type=types.IntType, minval=DISCRMIN, maxval=DISCRMAX) self.add_parameter('InputChannelOffset', flags = Instrument.FLAG_SET, type=types.IntType, minval=CHANOFFSMIN, maxval=CHANOFFSMAX) self.add_parameter('HistoLen', flags = Instrument.FLAG_SET, type=types.IntType, minval=0, maxval=MAXLENCODE) self.add_parameter('InputEdgeTrg0', flags = Instrument.FLAG_SET, type=types.IntType) self.add_parameter('InputEdgeTrg1', flags = Instrument.FLAG_SET, type=types.IntType) self.add_parameter('CountRate0', flags = Instrument.FLAG_GET, type=types.IntType) self.add_parameter('CountRate1', flags = Instrument.FLAG_GET, type=types.IntType) self.add_parameter('ElapsedMeasTimePS', flags = Instrument.FLAG_GET, type=types.FloatType) self.add_parameter('DeviceIndex', flags = Instrument.FLAG_SET, type=types.IntType) self.add_parameter('MeasRunning', flags = Instrument.FLAG_GET, type=types.BooleanType) self.add_parameter('Flags', flags = Instrument.FLAG_GET, type=types.IntType) self.add_parameter('Flag_Overflow', flags = Instrument.FLAG_GET, type=types.BooleanType) self.add_parameter('Flag_FifoFull', flags = Instrument.FLAG_GET, type=types.BooleanType) self.add_parameter('Flag_RefLost', flags = Instrument.FLAG_GET, type=types.BooleanType) self.add_parameter('Flag_SyncLost', flags = Instrument.FLAG_GET, type=types.BooleanType) self.add_parameter('Flag_SystemError', flags = Instrument.FLAG_GET, type=types.BooleanType) self.add_parameter('NumOfInputChannels', flags = Instrument.FLAG_GET, type=types.IntType) self.add_parameter('Channel', flags = Instrument.FLAG_SET, type=types.IntType) self.add_parameter('Binning', flags = Instrument.FLAG_SET, type=types.IntType, minval=0, maxval=MAXBINSTEPS-1) self.add_parameter('T2_WRAPAROUND', flags = Instrument.FLAG_GET, type=types.IntType) self.add_parameter('T2_TIMEFACTOR', flags = Instrument.FLAG_GET, type=types.IntType) self.add_parameter('T2_READMAX', flags = Instrument.FLAG_GET, type=types.IntType) self.add_function('start_histogram_mode') self.add_function('start_T2_mode') self.add_function('start_T3_mode') self.add_function('ClearHistMem') self.add_function('StartMeas') self.add_function('StopMeas') self.add_function('OpenDevice') self.add_function('CloseDevice') # self.add_function('get_T3_pulsed_events') self._do_set_DeviceIndex(DeviceIndex) self.OpenDevice() qt.msleep(1) if self.start_histogram_mode(): self.Model = numpy.array([16*' ']) self.PartNo = numpy.array([8*' ']) self.SerialNo = numpy.array([8*' ']) self.Version = numpy.array([16*' ']) success = self._TH260.TH260_GetHardwareInfo(self.DevIdx, self.Model.ctypes.data, self.PartNo.ctypes.data, self.Version.ctypes.data) if success != 0: logging.warning(__name__ + ' : error getting hardware info') self.get_ErrorString(success) # print ('HydraHarp model %s'%self.Model) # print ('HydraHarp part no. %s'%self.PartNo) success = self._TH260.TH260_GetSerialNumber(self.DevIdx, self.SerialNo.ctypes.data) if success != 0: logging.warning(__name__ + ' : error getting serial number') self.get_ErrorString(success) # print ('HydraHarp serial no. %s'%self.SerialNo) self._do_get_NumOfInputChannels() self._do_set_SyncEdgeTrg(200) self._do_set_SyncChannelOffset(0) self._do_set_Channel(0) self._do_set_InputEdgeTrg(200) self._do_set_InputChannelOffset(0) self._do_set_Channel(1) self._do_set_InputEdgeTrg(200) self._do_set_InputChannelOffset(0) self._do_set_SyncDiv(1) self._do_set_Binning(8) self._do_set_HistoLen(MAXLENCODE) self._do_set_Offset(0) self.set_StopOverflow(0,STOPCNTMAX) self._do_get_BaseResolutionPS() self._do_get_MaxBinSteps() self._do_get_ResolutionPS() else: logging.error('TH260 device could not be initialized.') self.CloseDevice()
def spin_control(self, lt1, ssro_dict={}): self.par['green_repump_voltage'] = self.ins_green_aom.power_to_voltage( self.par['green_repump_amplitude']) self.par[ 'green_off_voltage'] = 0.08 #self.ins_green_aom.power_to_voltage(self.par['green_off_amplitude']) self.par['Ex_CR_voltage'] = self.ins_E_aom.power_to_voltage( self.par['Ex_CR_amplitude']) self.par['A_CR_voltage'] = self.ins_A_aom.power_to_voltage( self.par['A_CR_amplitude']) self.par['Ex_SP_voltage'] = self.ins_E_aom.power_to_voltage( self.par['Ex_SP_amplitude']) self.par['A_SP_voltage'] = self.ins_A_aom.power_to_voltage( self.par['A_SP_amplitude']) self.par['Ex_RO_voltage'] = self.ins_E_aom.power_to_voltage( self.par['Ex_RO_amplitude']) self.par['A_RO_voltage'] = self.ins_A_aom.power_to_voltage( self.par['A_RO_amplitude']) if (self.par['SP_duration'] > self.max_SP_bins) or \ (self.par['sweep_length']*self.par['RO_duration'] > self.max_RO_dim): print('Error: maximum dimensions exceeded') return (-1) #print 'SP E amplitude: %s'%self.par['Ex_SP_voltage'] #print 'SP A amplitude: %s'%self.par['A_SP_voltage'] if not (lt1): self.adwin.set_spincontrol_var( set_phase_locking_on=self.set_phase_locking_on) self.adwin.set_spincontrol_var( set_gate_good_phase=self.set_gate_good_phase) print 'seq max time set in ADwin' print self.par['sequence_wait_time'] self.adwin.start_spincontrol( counter_channel=self.par['counter_channel'], green_laser_DAC_channel=self.par['green_laser_DAC_channel'], Ex_laser_DAC_channel=self.par['Ex_laser_DAC_channel'], A_laser_DAC_channel=self.par['A_laser_DAC_channel'], AWG_start_DO_channel=self.par['AWG_start_DO_channel'], AWG_done_DI_channel=self.par['AWG_done_DI_channel'], send_AWG_start=self.par['send_AWG_start'], wait_for_AWG_done=self.par['wait_for_AWG_done'], green_repump_duration=self.par['green_repump_duration'], CR_duration=self.par['CR_duration'], SP_duration=self.par['SP_duration'], SP_filter_duration=self.par['SP_filter_duration'], sequence_wait_time=self.par['sequence_wait_time'], wait_after_pulse_duration=self.par['wait_after_pulse_duration'], CR_preselect=self.par['CR_preselect'], RO_repetitions=self.par['RO_repetitions'], RO_duration=self.par['RO_duration'], sweep_length=self.par['sweep_length'], cycle_duration=self.par['cycle_duration'], green_repump_voltage=self.par['green_repump_voltage'], green_off_voltage=self.par['green_off_voltage'], Ex_CR_voltage=self.par['Ex_CR_voltage'], A_CR_voltage=self.par['A_CR_voltage'], Ex_SP_voltage=self.par['Ex_SP_voltage'], A_SP_voltage=self.par['A_SP_voltage'], Ex_RO_voltage=self.par['Ex_RO_voltage'], A_RO_voltage=self.par['A_RO_voltage']) if lt1: self.adwin_lt2.start_check_trigger_from_lt1() CR_counts = 0 while (self.physical_adwin.Process_Status(9) == 1): reps_completed = self.physical_adwin.Get_Par(73) CR_counts = self.physical_adwin.Get_Par(70) - CR_counts cts = self.physical_adwin.Get_Par(26) trh = self.physical_adwin.Get_Par(25) print('completed %s / %s readout repetitions, %s CR counts/s' % (reps_completed, self.par['RO_repetitions'], CR_counts)) print('threshold: %s cts, last CR check: %s cts' % (trh, cts)) if (msvcrt.kbhit() and (msvcrt.getch() == 'q')): break qt.msleep(2.5) self.physical_adwin.Stop_Process(9) if lt1: self.adwin_lt2.stop_check_trigger_from_lt1() reps_completed = self.physical_adwin.Get_Par(73) print('completed %s / %s readout repetitions' % (reps_completed, self.par['RO_repetitions'])) sweep_length = self.par['sweep_length'] par_long = self.physical_adwin.Get_Data_Long(20, 1, 25) par_float = self.physical_adwin.Get_Data_Float(20, 1, 10) CR_before = self.physical_adwin.Get_Data_Long(22, 1, 1) CR_after = self.physical_adwin.Get_Data_Long(23, 1, 1) SP_hist = self.physical_adwin.Get_Data_Long(24, 1, self.par['SP_duration']) RO_data = self.physical_adwin.Get_Data_Long( 25, 1, sweep_length * self.par['RO_duration']) RO_data = np.reshape(RO_data, (sweep_length, self.par['RO_duration'])) SSRO_data = self.physical_adwin.Get_Data_Long( 27, 1, sweep_length * self.par['RO_duration']) SSRO_data = np.reshape(SSRO_data, (sweep_length, self.par['RO_duration'])) statistics = self.physical_adwin.Get_Data_Long(26, 1, 10) sweep_index = np.arange(sweep_length) sp_time = np.arange( self.par['SP_duration']) * self.par['cycle_duration'] * 3.333 ro_time = np.arange( self.par['RO_duration']) * self.par['cycle_duration'] * 3.333 self.save() savdat = {} savdat['counts'] = CR_after self.save_dataset(name='ChargeRO_after', do_plot=False, data=savdat, idx_increment=False) savdat = {} savdat['time'] = sp_time savdat['counts'] = SP_hist self.save_dataset(name='SP_histogram', do_plot=False, data=savdat, idx_increment=False) savdat = {} savdat['time'] = ro_time savdat['sweep_axis'] = sweep_index savdat['counts'] = RO_data savdat['SSRO_counts'] = SSRO_data self.save_dataset(name='Spin_RO', do_plot=False, data=savdat, idx_increment=False) savdat = {} savdat['par_long'] = par_long savdat['par_float'] = par_float self.save_dataset(name='parameters', do_plot=False, data=savdat, idx_increment=False) ###################### ###statistics file#### ###################### savdat = {} savdat['completed_repetitions'] = (reps_completed / sweep_length) savdat['total_repumps'] = statistics[0] savdat['total_repump_counts'] = statistics[1] savdat['noof_failed_CR_checks'] = statistics[2] savdat['min_pulse_nr'] = self.par['min_sweep_par'] savdat['max_pulse_nr'] = self.par['max_sweep_par'] savdat['min_pulse_amp'] = self.par['min_sweep_par'] savdat['max_pulse_amp'] = self.par['max_sweep_par'] savdat['min_time'] = self.par['min_sweep_par'] savdat['max_time'] = self.par['max_sweep_par'] savdat['min_sweep_par'] = self.par['fe_min'] savdat['max_sweep_par'] = self.par['fe_max'] savdat['sweep_par_name'] = self.par['sweep_par_name'] savdat['sweep_par'] = self.par['sweep_par'] savdat['noof_datapoints'] = self.par['sweep_length'] savdat['fe_max'] = self.par['fe_max'] savdat['fe_min'] = self.par['fe_min'] self.save_dataset(name='statics_and_parameters', do_plot=False, data=savdat, idx_increment=True) self.save_dataset(name='SSRO_calibration', do_plot=False, data=ssro_dict, idx_increment=True) return
error_list['0'] = linspace(0, 0.3, 4) error_list['1'] = linspace(0.4, 0.7, 4) error_list['2'] = linspace(0.8, 1, 3) error_list['3'] = linspace(0.45, 0.45, 1) error_list['4'] = np.array([0, 0.1, 0.2, 0.3]) error_list['5'] = np.array([0.4, 0.45, 0.5, 0.6]) error_list['6'] = np.array([0.7, 0.8, 0.9, 1.]) for state in ['Z', 'mZ']: logic_state = state print '-----------------------------------' print 'press q to stop measurement cleanly' print '-----------------------------------' qt.msleep(2) if (msvcrt.kbhit() and (msvcrt.getch() == 'q')): break if state == 'X' or state == 'mX': RO_list = [6] elif state == 'Y' or state == 'mY': RO_list = [3, 4, 5, 6] elif state == 'Z': RO_list = [6, 0, 1, 2] elif state == 'mZ': RO_list = [6, 0, 1, 2] for RO in RO_list: GreenAOM.set_power(7e-6)
) / 0.23377 + 4.2 #temperature converted to [K] (cal by Vibhor) trace = fsl.get_trace() #FSL measurement summed_trace += trace time_list = x_time * ones(len(trace)) #make list temp_list = y_temp * ones(len(trace)) #make list fstep = span / (len(trace) - 1.0) #calc correct freq. step flist = np.arange(start_frequency, stop_frequency + fstep, fstep) #create freq. list data.new_block() data.add_data_point(flist, temp_list, time_list, trace, list(numpy.array(summed_trace).reshape( -1, ))) #store data spyview_process(data, start_frequency, stop_frequency, x_time) qt.msleep(0.01) #wait 10 usec so save etc run_index = run_index + 1 print run_index, x_time, y_temp print x_time, y_temp #now all the traces are summed into local_trace, now the number of traces summed is run_index + 2 normalization = summed_trace / (run_index + 2) data.close_file() qt.mend() #end of normalization routine print 'end of normalization'
def main(): if not debug_mode: initialize_hh() generate_sequence() # configure measurement repetitions = par_reps hh_measurement_time = int(1e3 * 60 * par_meas_time) #ms qt.mstart() cr_stats = qt.Data(name='Statistics_cr_checks') cr_stats.add_coordinate('repetition nr') cr_stats.add_value('lt1_cr_below threshold') cr_stats.add_value('lt1_cr_checks') cr_stats.add_value('lt2_cr_below_threshold') cr_stats.add_value('lt2_cr_checks') cr_stats.add_value('tpqi_starts') cr_stats.add_value('lt1_repump_cts') cr_stats.add_value('lt2_repump_cts') cr_stats.add_value('lt1_triggers_received') cr_stats.add_value('lt2_triggers_sent') cr_stats.add_value('lt1_oks_sent') cr_stats.add_value('lt2_oks_received') cr_stats.create_file() histogram_summed = zeros((par_range_sync, par_range_g2)) hist_roi_summed = zeros(par_range_g2) for idx in arange(repetitions): skip_opt = False if msvcrt.kbhit(): kb_char = msvcrt.getch() if kb_char == "q": break elif kb_char == "c": skip_opt = True print 'Starting measurement cycle', idx, 'current time:', time.strftime( '%H:%M', time.localtime()) [histogram, hist_ch0, hist_ch1, hist_ch1_long, hist_roi] = measurement_cycle(hh_measurement_time) print_save_cr_check_info(cr_stats, idx) if not debug_mode: histogram_summed += histogram hist_roi_summed += hist_roi print 'Finished measurement cycle', idx, 'start saving' data = qt.Data(name='interference' + "_" + str(idx)) data.add_coordinate('dt') data.add_coordinate('sync') data.add_value('counts') save_and_plot_data(data, histogram, histogram_summed, hist_ch0, hist_ch1, hist_ch1_long, hist_roi, hist_roi_summed) print 'Data saving cycle', idx, 'completed' qt.msleep(1) if not (debug_mode) and not (skip_opt): if not optimize(): break print 'Optimisation step', idx, ' completed' cr_stats.close_file() qt.mend() end_measuring()
if exp_time < 0: exp_time = 60 print power, 'estimated ready at:', localtime( tstart + exp_time)[3], ':', localtime(tstart + exp_time)[4], ':', localtime(tstart + exp_time)[5] smb.set_RF_power(power) smb.set_RF_frequency(cw_frequency / 1e6) pna.sweep() for delta in delta_list: #smb.set_RF_frequency(cw_frequency/1e6+delta) smb.set_RF_frequency(delta) qt.msleep(timestep) qt.msleep(2) tr2 = pna.data_f() data.add_data_point(point_list, list(power * ones(sweep_points)), tr2) data.new_block() spyview_process(data, point_list[0], point_list[-1], power) qt.msleep(0.01) #wait 10 usec so save etc data.close_file() #adwin.set_DAC_2(0) qt.mend() #end of experiment routine print 'ready at', localtime()[3], ':', localtime(
) #for testing! set averaging mode to points (all chanals) sweep is the other option #do a PNA testsweep sweep_time = float(pna.q("SENS1:SWE:TIME?")) #pna.sweep() #qt.msleep(sweep_time+3) ###################################### '''setup the adwin befor measurement(with a test sweep)''' print 'prepare ADwin' adwin.start_process() #starts the DAC program adwin.set_rampspeed(1) #adwin.set_DAC_2(0) adwin.set_DAC_2(float(gate_start) / float(gate_multi)) #set adwin to start value qt.msleep(2) #wait for adwin and equilibrium ########## Print settings ################ print 'Gate points:' + str(gate_pts) print 'step size: ' + str((f1_stop - f1_start) / (f1_pts - 1)) + ' Hz' print 'PNA power: ' + str(pna.get_power()) + ' dBm' print 'bw: ' + str(pna.get_resolution_bandwidth()) + ' Hz' print 'averages of the pna: ' + str(pna.get_averages()) print 'sweeptime per trace (sec): ' + str(sweep_time) ################################################## print 'measurement loop:' tstart = time() prev_time = tstart
def optimize_blobs_position(self, blobs_list, z): e = esr_NV_search.esr_on_blob() local_optimiz0r = NV_search_optimizer('local_optimiz0r', dimension_set='lt3_NV_search') esr_to_check_coordinates = [] nv_coordinates = [] for i in xrange(len(blobs_list)): for j in xrange(len(blobs_list[i])): scan2d.set_x_position(blobs_list[i][j][0]) scan2d.set_y_position(blobs_list[i][j][1]) master_of_space.set_z(z) qt.msleep(5) continue_optimization = False success_last = False print 'x_search=', blobs_list[i][j][0] print 'y_search=', blobs_list[i][j][1] success_first = optimiz0r.optimize(cycles=1, dims=['y', 'x']) success_first = optimiz0r.optimize(cycles=1, dims=['y', 'x']) if (success_first): sigma = opt1d_counts.get_fit_result()[2] sigma_error = opt1d_counts.get_fit_error()[2] if (sigma > 0.08) and (sigma < 0.3) and (sigma_error < 0.02): continue_optimization = True else: scan2d.set_x_position(blobs_list[i][j][0]) scan2d.set_y_position(blobs_list[i][j][1]) qt.msleep(2) success_first = optimiz0r.optimize(cycles=2, dims=['x', 'y']) else: scan2d.set_x_position(blobs_list[i][j][0]) scan2d.set_y_position(blobs_list[i][j][1]) qt.msleep(2) success_first = optimiz0r.optimize(cycles=2, dims=['x', 'y']) if (success_first): sigma = opt1d_counts.get_fit_result()[2] sigma_error = opt1d_counts.get_fit_error()[2] if (sigma > 0.08) and (sigma < 0.3) and (sigma_error < 0.02): continue_optimization = True if (continue_optimization): optimize_SN.optimize_z() qt.msleep(1) success_last = optimiz0r.optimize(cycles=1, dims=['x', 'y']) if (success_last): print 'NV_coordinate_x=', scan2d.get_x_position() print 'NV_coordinate_y=', scan2d.get_y_position() esr_to_check_coordinates.append( ([scan2d.get_x_position(), scan2d.get_y_position()])) name = '_ESR_' + 'x=' + str( scan2d.get_x_position())[:4] + '_y=' + str( scan2d.get_y_position())[:4] success = e.run(name=name) if (success): nv_coordinates.append(([ scan2d.get_x_position(), scan2d.get_y_position() ])) return esr_to_check_coordinates, nv_coordinates
def measurement_cycle(hh_measurement_time): awg.set_runmode('SEQ') awg.start() adwin_lt1.start_remote_tpqi_control( repump_duration=lt1_rempump_duration, probe_duration=lt1_probe_duration, cr_count_threshold_probe=lt1_cnt_threshold_probe, cr_count_threshold_prepare=lt1_cnt_threshold_prepare, counter=lt1_counter, green_aom_voltage=lt1_green_aom_voltage, ex_aom_voltage=lt1_ex_aom_voltage, a_aom_voltage=lt1_a_aom_voltage, ) adwin_lt2.start_remote_tpqi_control( repump_duration=lt2_rempump_duration, probe_duration=lt2_probe_duration, cr_time_limit=time_limit, cr_count_threshold_probe=lt2_cnt_threshold_probe, cr_count_threshold_prepare=lt2_cnt_threshold_prepare, counter=lt2_counter, green_aom_voltage=lt2_green_aom_voltage, green_aom_voltage_zero=lt2_green_aom_voltage_zero, ex_aom_voltage=lt2_ex_aom_voltage, a_aom_voltage=lt2_a_aom_voltage, ) histogram = [] hist_ch0 = [] hist_ch1 = [] hist_ch1_long = [] hist_roi = [] if not debug_mode: if hh_measurement_time > 0: hharp.StartMeas(hh_measurement_time) [histogram, hist_ch0, hist_ch1, hist_ch1_long, hist_roi] = hharp.get_T3_pulsed_g2_2DHistogram_v5( binsize_sync=par_binsize_sync, range_sync=par_range_sync, binsize_g2=par_binsize_g2, range_g2=par_range_g2, max_pulses=par_max_pulses, sync_period=par_sync_period, laser_end_ch0=par_laser_end_ch0, laser_end_ch1=par_laser_end_ch1, tail_roi=par_tail_roi, save_raw=par_raw_path) if debug_mode: qt.msleep(par_meas_time * 60) adwin_lt2.stop_remote_tpqi_control() adwin_lt1.stop_remote_tpqi_control() awg.stop() qt.msleep(0.1) awg.set_runmode('CONT') return histogram, hist_ch0, hist_ch1, hist_ch1_long, hist_roi
def takeZenocurve(evotime_slicer, evotime_arr, msmts, logic_state_list, RO_bases_dict, debug=False, breakstatement=False, last_check=time.time()): ### this function runs a measurement loop ### after two hours of measurement we run check ups: SSRO + optimize the NV position + generation of Teststates. ### Parameters: """ Input: evotime_slicer = tells the function array slicer the maximum length of sweep points (evolution times) evotim_arr = all evolution times we sweep over. msmts = number of zeno measurements logic_state_list = a list of strings, i.e. logic input carbon_init_states RO_bases_dict = is a dictionary which contains a read-out basis for each logical input state (key) breakstatement = if True then we don't do anything last_check = the time when the check of the magnetic field has been performed Output: last_check = the time the last check up has been performed breakstatement = True if the measurement has been aborted. Otherwise False """ Evotime_slicer = evotime_slicer # == number of datapoints taken at once EvoTime_arr = array_slicer(Evotime_slicer, evotime_arr) eRO_list = ['positive', 'negative'] for logic_state in logic_state_list: if breakstatement: break for EvoTime in EvoTime_arr: print EvoTime print '-----------------------------------' print 'press q to stop measurement cleanly' print '-----------------------------------' qt.msleep(2) if (msvcrt.kbhit() and (msvcrt.getch() == 'q')): breakstatement = True break for eRO in eRO_list: Zeno(SAMPLE + eRO + '_logicState_' + logic_state + '_' + str(msmts) + 'msmt_' + '_ROBasis_' + RO_bases_dict[logic_state][0] + RO_bases_dict[logic_state][1], el_RO=eRO, logic_state=logic_state, Tomo_bases=RO_bases_dict[logic_state], free_evolution_time=EvoTime, number_of_zeno_msmnts=msmts, debug=debug) if time.time( ) - last_check > 2 * 60 * 60: #perform a consistency check every two hours if not debug and not breakstatement: print '-----------------------------------' print 'press q to stop measurement cleanly' print '-----------------------------------' qt.msleep(2) if (msvcrt.kbhit() and (msvcrt.getch() == 'q')): breakstatement = True break ssrocalibration(SAMPLE_CFG) GreenAOM.set_power(15e-6) counters.set_is_running(1) optimiz0r.optimize(dims=['x', 'y', 'z']) stools.turn_off_all_lt2_lasers() ssrocalibration(SAMPLE_CFG) Zeno(SAMPLE + 'positive' + '_' + str(1) + 'msmts_TESTSTATE_' + 'Z' + 'Z', el_RO='positive', logic_state='mX', Tomo_bases=['Z', 'Z'], free_evolution_time=[10e-3], number_of_zeno_msmnts=1, debug=False, Repetitions=1000) Zeno(SAMPLE + 'negative' + '_' + str(1) + 'msmts_TESTSTATE_' + 'Z' + 'Z', el_RO='negative', logic_state='mX', Tomo_bases=['Z', 'Z'], free_evolution_time=[10e-3], number_of_zeno_msmnts=1, debug=False, Repetitions=1000) last_check = time.time() else: print 'time to next check: ', 2 * 60 * 60 - time.time( ) + last_check return breakstatement, last_check
def laserscan(ins_laser_scan=ins_laser_scan): ins_laser_scan.set_WavemeterChannel(2) ins_laser_scan.set_CounterChannel(1) ins_laser_scan.set_StartVoltage(start_v) ins_laser_scan.set_StopVoltage(stop_v) ins_laser_scan.set_ScanSteps(steps) ins_laser_scan.set_IntegrationTime(pxtime) ins_running = True step = 0 #_before_voltages = ins_adwin.get_dac_voltages(['green_aom','newfocus_aom']) #FIXME NEED A CONDITION FOR WHEN THE Newfocus IS ONE THE AWG. GreenAOM.set_power(green_before) qt.msleep(1) NewfocusAOM.set_power(red_during) GreenAOM.set_power(green_during) if mw: ins_mw.set_iq('off') ins_mw.set_pulm('off') ins_mw.set_power(mw_power) ins_mw.set_frequency(mw_frq) ins_mw.set_status('on') qt.mstart() qt.Data.set_filename_generator(data.DateTimeGenerator()) d = qt.Data(name=dataname) d.add_coordinate('voltage [V]') d.add_value('frequency [GHz]') d.add_value('counts') d.create_file() p_f = qt.Plot2D(d, 'rO', name='frequency', coorddim=0, valdim=1, clear=True) p_c = qt.Plot2D(d, 'bO', name='counts', coorddim=1, valdim=2, clear=True) # go manually to initial position ins_adwin.set_dac_voltage(('newfocus_frq', start_v)) qt.msleep(1) ins_laser_scan.start_scan() qt.msleep(1) timer_id = gobject.timeout_add(abort_check_time, check_for_abort) while (ins_running): ins_running = not ins_laser_scan.get_TraceFinished() _step = ins_laser_scan.get_CurrentStep() qt.msleep(0.3) if _step > step: _v = ins_laser_scan.get_voltages()[step:_step] _f = ins_laser_scan.get_frequencies()[step:_step] - f_offset _c = ins_laser_scan.get_counts()[step:_step] # print _v,_f,_c if len(_v) == 1: _v = _v[0] _f = _f[0] _c = _c[0] d.add_data_point(_v, _f, _c) step = _step p_f.update() p_c.update() ins_laser_scan.end_scan() gobject.source_remove(timer_id) #ins_adwin.set_dac_voltage(['green_aom',_before_voltages[0]]) #ins_adwin.set_dac_voltage(['newfocus_aom',_before_voltages[1]]) if mw: ins_mw.set_status('off') qt.mend() if do_smooth: basepath = d.get_filepath()[:-4] ds = qt.Data() ds.set_filename_generator(data.IncrementalGenerator(basepath)) ds.add_coordinate('voltage [V]') ds.add_value('smoothed frequency [GHz]') ds.add_value('counts') ds.create_file() p_fs = qt.Plot2D(ds, 'rO', name='frequency smoothed', coorddim=0, valdim=1, clear=True) p_cs = qt.Plot2D(ds, 'bO', name='counts smoothed', coorddim=1, valdim=2, clear=True) ds.add_data_point(d.get_data()[:, 0], rolling_avg(d.get_data()[:, 1]), d.get_data()[:, 2]) ds.close_file() p_fs.save_png() p_cs.save_png() else: p_f.save_png() p_c.save_png() d.close_file() qt.Data.set_filename_generator(data.DateTimeGenerator()) MatisseAOM.set_power(0) NewfocusAOM.set_power(0) GreenAOM.set_power(green_before)
data.add_data_point(ravel(X),ravel(Y),ravel(histogram)) filename=data.get_filepath()[:-4] pqm.savez(filename,dt=dt,sync=sync, counts=histogram) #Plot Data plt = plot3(ravel(X),ravel(Y),ravel(histogram), style='image',palette='hot', title='interference') #data.new_block() plt.set_xlabel('dt [ns]') plt.set_ylabel('delay wrt sync pulse [ns]') plt.save_png(filename)msvcrtmsvcrt.getch() == "q" : break qt.msleep(1) print 't=%d :' % (t+1) print 'lt1 : noof triggers:', adwin_lt1.remote_tpqi_control_get_noof_trigger() print 'lt1 : CR counts: ', adwin_lt1.remote_tpqi_control_get_cr_check_counts() print 'lt1 : below th.: ' , adwin_lt1.remote_tpqi_control_get_cr_below_threshold_events() print 'lt1 : CR checks: ', adwin_lt1.remote_tpqi_control_get_noof_cr_checks() print 'lt1 : repump cts.: ', adwin_lt1.remote_tpqi_control_get_repump_counts() print 'lt2 : CR counts: ', adwin_lt2.remote_tpqi_control_get_cr_check_counts() print 'lt2 : below th.: ', adwin_lt2.remote_tpqi_control_get_cr_below_threshold_events() print 'lt2 : CR checks: ', adwin_lt2.remote_tpqi_control_get_noof_cr_checks() print 'tpqi starts: ', adwin_lt2.remote_tpqi_control_get_noof_tpqi_starts() print 'tpqi stops: ', adwin_lt2.remote_tpqi_control_get_noof_tpqi_stops() print 'lt2 : repump cts.: ', adwin_lt2.remote_tpqi_control_get_repump_counts() print 'lt1 : OKs: ', adwin_lt2.remote_tpqi_control_get_noof_lt1_oks() print ''
while self.awg.get_state() != 'Waiting for trigger': ======= sequence = generate_sequence(sweep_param,pulse_dict,lt1) self.par['RO_repetitions'] = int(len(self.sweep_param)*self.par['reps_per_datapoint']) self.par['sweep_length'] = int(len(self.sweep_param)) self.par['sequence_wait_time'] = int(np.ceil(sequence["max_seq_time"]/1e3)+2) self.par['min_sweep_par'] = sweep_param.min() self.par['max_sweep_par'] = sweep_param.max() awg.set_runmode('SEQ') awg.start() while awg.get_state() != 'Waiting for trigger': >>>>>>> 54c8270ec6ded7035f530c75005cf8bbd74414e7 qt.msleep(1) self.microwaves.set_status('on') qt.msleep(1) self.spin_control(lt1,ssro_dict=ssro_dict) self.end_measurement() def spin_control(self,lt1,ssro_dict={}): self.par['green_repump_voltage'] = self.ins_green_aom.power_to_voltage(self.par['green_repump_amplitude']) self.par['green_off_voltage'] = 0.01#self.ins_green_aom.power_to_voltage(self.par['green_off_amplitude']) self.par['Ex_CR_voltage'] = self.ins_E_aom.power_to_voltage(self.par['Ex_CR_amplitude']) self.par['A_CR_voltage'] = self.ins_A_aom.power_to_voltage(self.par['A_CR_amplitude']) self.par['Ex_SP_voltage'] = self.ins_E_aom.power_to_voltage(self.par['Ex_SP_amplitude']) self.par['A_SP_voltage'] = self.ins_A_aom.power_to_voltage(self.par['A_SP_amplitude'])
def lt3_sequence(self): self.lt3_seq = pulsar.Sequence('TeleportationLT3') mbi_elt = bseq._lt3_mbi_element(self) start_LDE_element = bseq._lt3_start_LDE_element(self) LDE_element = bseq._lt3_LDE_element(self) dummy_element = bseq._lt3_dummy_element(self) adwin_lt3_trigger_element = bseq._lt3_adwin_LT3_trigger_element(self) N_init_element, BSM_CNOT_elt, BSM_UNROT_elt = bseq._lt3_N_init_and_BSM_for_bell(self) N_RO_elt = bseq._lt3_N_RO_elt(self) self.lt3_seq.append(name = 'MBI', trigger_wait = True, wfname = mbi_elt.name, jump_target = 'start_LDE', goto_target = 'MBI') self.lt3_seq.append(name = 'start_LDE', trigger_wait = True, wfname = start_LDE_element.name) self.lt3_seq.append(name = 'LDE_LT3', wfname = (LDE_element.name if DO_LDE_SEQUENCE else dummy_element.name), jump_target = ('N_init' if DO_BSM else 'BSM_dummy'), repetitions = self.params['LDE_attempts_before_CR']) self.lt3_seq.append(name = 'LDE_timeout', wfname = adwin_lt3_trigger_element.name, goto_target = 'MBI') if DO_BSM: self.lt3_seq.append(name = 'N_init', wfname = N_init_element.name) self.lt3_seq.append(name = 'BSM_CNOT', wfname = BSM_CNOT_elt.name) self.lt3_seq.append(name = 'BSM_H_UNROT', wfname = BSM_UNROT_elt.name) self.lt3_seq.append(name = 'sync_before_first_ro', wfname = adwin_lt3_trigger_element.name) for i in range(self.params_lt3['N_RO_repetitions']): self.lt3_seq.append(name = 'N_RO-{}'.format(i+1), trigger_wait = True, wfname = N_RO_elt.name) self.lt3_seq.append(name = 'N_RO-{}_sync'.format(i+1), wfname = adwin_lt3_trigger_element.name, goto_target = 'MBI' if i==(self.params_lt3['N_RO_repetitions']-1) else 'N_RO-{}'.format(i+2) ) else: self.lt3_seq.append(name = 'BSM_dummy', wfname = dummy_element.name) if DO_READOUT: self.lt3_seq.append(name = 'sync_before_first_ro', wfname = adwin_lt3_trigger_element.name) for i in range(self.params_lt3['N_RO_repetitions']): self.lt3_seq.append(name='N_RO-{}'.format(i+1), trigger_wait = True, wfname = N_RO_elt.name) self.lt3_seq.append(name = 'N_RO-{}_sync'.format(i+1), wfname = adwin_lt3_trigger_element.name, goto_target = 'MBI' if i==(self.params_lt3['N_RO_repetitions']-1) else 'N_RO-{}'.format(i+2) ) elements = [] elements.append(mbi_elt) elements.append(adwin_lt3_trigger_element) elements.append(start_LDE_element) elements.append(dummy_element) elements.append(N_RO_elt) if DO_BSM: elements.append(N_init_element) elements.append(BSM_CNOT_elt) elements.append(BSM_UNROT_elt) # if DO_POLARIZE_N: # elements.append(N_pol_element) if DO_LDE_SEQUENCE: elements.append(LDE_element) qt.pulsar_remote.upload(*elements) qt.pulsar_remote.program_sequence(self.lt3_seq) self.awg.set_runmode('SEQ') self.awg.start() i=0 awg_ready = False while not awg_ready and i<40: try: if self.awg.get_state() == 'Waiting for trigger': awg_ready = True except: print 'waiting for awg: usually means awg is still busy and doesnt respond' print 'waiting', i, '/40' i=i+1 qt.msleep(0.5) if not awg_ready: raise Exception('AWG not ready')
tstart = time.time() while True: try: time1 = time.time() tavg = time1 - tstart Ti = temp_control.get_temperatureA() Tb = temp_control.get_temperatureB() temp_control.get_heater_output1() temp_control.get_heater_output2() if magnet_supply is not None: He = magnet_supply.get_He_level() data.add_data_point(tavg, Ti, Tb, He) else: data.add_data_point(tavg, Ti, Tb) for plot in plotlist: plot.update() qt.msleep(timestep) except KeyboardInterrupt: break tend = time.time() print 'Monitoring stopped after %.1fs.' % (tend - tstart) qt.mend() data.close_file() for plot in plotlist: plot.save_png()
def _ask(self, question): response = self._visainstrument.ask(question + '\n') qt.msleep(0.05) return response
def finish_msmnt(): qt.instruments['AWG'].stop() qt.instruments['AWG_lt3'].stop() qt.msleep(1) qt.instruments['AWG'].set_runmode('CONT') qt.instruments['AWG_lt3'].set_runmode('CONT')
def SIM928_get_voltage(self, channel): self._visainstrument.write('FLSH %i' % channel) self._visainstrument.write('SNDT %i, "VOLT?"' % channel) qt.msleep(self.sleep_time) return float(self._ask('GETN? %i,80' % channel))
def SIM928_set_voltage(self, voltage, channel): self._visainstrument.write('SNDT %i, "VOLT %.3f"' % (channel, voltage)) qt.msleep(self.sleep_time)
# optical_power[1:4] *= 2 focus = z_start[jj] # z reference position xsteps = [xpx] * len(zoom) ysteps = [ypx] * len(zoom) pixeltime = [10.] * len(zoom) bleaching_pixeltime = [100.] * len(zoom) j = 0 k = 0 stop_scan = False for i in zoom: print '%s_um' % i master_of_space.set_z(focus + i) qt.msleep(5) if bleaching: AOM.turn_on() setup_controller.set_keyword( 'Hillary_Scan9_highres_focus=%sum_zrel=%s_um' % (np.round(focus, 2), i)) lastline_reached = False #print 'xsteps[j]', xsteps[j] scan2d_flim.set_xsteps(xsteps[j]) scan2d_flim.set_ysteps(ysteps[j]) scan2d_flim.set_pixel_time(bleaching_pixeltime[j]) qt.msleep(5) scan2d_flim.set_is_running(True)
class BellMaster(m2.MultipleAdwinsMeasurement): mprefix = 'Bell' def __init__(self, name): m2.MultipleAdwinsMeasurement.__init__(self, name) self.params_lt3 = m2.MeasurementParameters('LT3Parameters') self.params_lt1 = m2.MeasurementParameters('LT1Parameters') ### setting up def load_settings(self): for k in bparams.params.parameters: self.params[k] = bparams.params[k] for k in bparams.params_lt3.parameters: self.params_lt3[k] = bparams.params_lt3[k] for k in bparams.params_lt1.parameters: self.params_lt1[k] = bparams.params_lt1[k] # self.params_lt3['do_N_polarization'] = 1 if DO_POLARIZE_N else 0 #for the sequencer and saving self.params_lt1['MW_during_LDE'] = 1 if LDE_DO_MW_LT1 else 0 self.params['opt_pi_pulses'] = OPT_PI_PULSES #for saving only self.params_lt3['do_sequences'] = 1 if DO_SEQUENCES else 0 self.params_lt3['do_LDE_sequence'] = 1 if DO_LDE_SEQUENCE else 0 self.params_lt3['use_yellow_lt1'] = YELLOW_lt1 self.params_lt3['use_yellow_lt3'] = YELLOW_lt3 self.params['do_ff'] = DO_FF def update_definitions(self): """ After setting the measurement parameters, execute this function to update pulses, etc. """ bseq.pulse_defs_lt1(self) def autoconfig(self): """ sets/computes parameters (can be from other, user-set params) as required by the specific type of measurement. E.g., compute AOM voltages from desired laser power, or get the correct AOM DAC channel from the specified AOM instrument. """ # LT3 laser configuration self.params_lt3['E_laser_DAC_channel'] = self.adwins['adwin_lt3']['ins'].get_dac_channels()\ [self.E_aom_lt3.get_pri_channel()] self.params_lt3['A_laser_DAC_channel'] = self.adwins['adwin_lt3']['ins'].get_dac_channels()\ [self.A_aom_lt3.get_pri_channel()] self.params_lt3['yellow_laser_DAC_channel'] = self.adwins['adwin_lt3']['ins'].get_dac_channels()\ [self.yellow_aom_lt3.get_pri_channel()] self.params_lt3['green_laser_DAC_channel'] = self.adwins['adwin_lt3']['ins'].get_dac_channels()\ [self.green_aom_lt3.get_pri_channel()] # self.params['gate_DAC_channel'] = self.adwin.get_dac_channels()\ # ['gate'] # self.params_lt3['repump_laser_DAC_channel'] = self.params_lt3['green_laser_DAC_channel'] self.params_lt3['repump_laser_DAC_channel'] = self.params_lt3['yellow_laser_DAC_channel'] self.params_lt3['E_CR_voltage'] = \ self.E_aom_lt3.power_to_voltage( self.params_lt3['E_CR_amplitude']) self.params_lt3['A_CR_voltage'] = \ self.A_aom_lt3.power_to_voltage( self.params_lt3['A_CR_amplitude']) self.params_lt3['E_SP_voltage'] = \ self.E_aom_lt3.power_to_voltage( self.params_lt3['E_SP_amplitude']) self.params_lt3['A_SP_voltage'] = \ self.A_aom_lt3.power_to_voltage( self.params_lt3['A_SP_amplitude']) self.params_lt3['E_RO_voltage'] = \ self.E_aom_lt3.power_to_voltage( self.params_lt3['E_RO_amplitude']) self.params_lt3['A_RO_voltage'] = \ self.A_aom_lt3.power_to_voltage( self.params_lt3['A_RO_amplitude']) self.params_lt3['repump_voltage'] = \ self.repump_aom_lt3.power_to_voltage( self.params_lt3['repump_amplitude']) self.params_lt3['E_off_voltage'] = self.E_aom_lt3.get_pri_V_off() self.params_lt3['A_off_voltage'] = self.A_aom_lt3.get_pri_V_off() self.params_lt3['repump_off_voltage'] = self.repump_aom_lt3.get_pri_V_off() # LT1 laser configuration self.params_lt1['Ey_laser_DAC_channel'] = self.adwins['adwin_lt1']['ins'].get_dac_channels()\ [self.E_aom_lt1.get_pri_channel()] self.params_lt1['A_laser_DAC_channel'] = self.adwins['adwin_lt1']['ins'].get_dac_channels()\ [self.A_aom_lt1.get_pri_channel()] self.params_lt1['green_laser_DAC_channel'] = self.adwins['adwin_lt1']['ins'].get_dac_channels()\ [self.green_aom_lt1.get_pri_channel()] self.params_lt1['yellow_laser_DAC_channel'] = self.adwins['adwin_lt1']['ins'].get_dac_channels()\ [self.yellow_aom_lt1.get_pri_channel()] if YELLOW_lt1: self.params_lt1['repump_laser_DAC_channel'] = self.params_lt1['yellow_laser_DAC_channel'] else: self.params_lt1['repump_laser_DAC_channel'] = self.params_lt1['green_laser_DAC_channel'] self.params_lt1['Ey_CR_voltage'] = \ self.E_aom_lt1.power_to_voltage( self.params_lt1['Ey_CR_amplitude']) self.params_lt1['A_CR_voltage'] = \ self.A_aom_lt1.power_to_voltage( self.params_lt1['A_CR_amplitude']) self.params_lt1['Ey_SP_voltage'] = \ self.E_aom_lt1.power_to_voltage( self.params_lt1['Ey_SP_amplitude']) self.params_lt1['A_SP_voltage'] = \ self.A_aom_lt1.power_to_voltage( self.params_lt1['A_SP_amplitude']) self.params_lt1['Ey_RO_voltage'] = \ self.E_aom_lt1.power_to_voltage( self.params_lt1['Ey_RO_amplitude']) self.params_lt1['A_RO_voltage'] = \ self.A_aom_lt1.power_to_voltage( self.params_lt1['A_RO_amplitude']) self.params_lt1['Ey_off_voltage'] = self.E_aom_lt1.get_pri_V_off() self.params_lt1['A_off_voltage'] = self.A_aom_lt1.get_pri_V_off() self.params_lt1['repump_off_voltage'] = self.repump_aom_lt1.get_pri_V_off() self.params_lt1['repump_voltage'] = \ self.repump_aom_lt1.power_to_voltage( self.params_lt1['repump_amplitude'], controller='pri') # add values from AWG calibrations self.params_lt1['SP_voltage_AWG'] = \ self.A_aom_lt1.power_to_voltage( self.params_lt1['AWG_SP_power'], controller='sec') # add values from AWG calibrations # self.params_lt1['SP_voltage_AWG_yellow'] = \ # self.repump_aom_lt1.power_to_voltage( # self.params_lt1['AWG_yellow_power'], controller='sec') qt.pulsar.set_channel_opt('AOM_Newfocus', 'high', self.params_lt1['SP_voltage_AWG']) # qt.pulsar.set_channel_opt('AOM_Yellow', 'high', self.params_lt1['SP_voltage_AWG_yellow']) def setup(self): """ sets up the hardware such that the msmt can be run (i.e., turn off the lasers, prepare MW src, etc) """ self.yellow_aom_lt3.set_power(0.) self.green_aom_lt3.set_power(0.) self.E_aom_lt3.set_power(0.) self.A_aom_lt3.set_power(0.) self.green_aom_lt3.set_cur_controller('ADWIN') self.E_aom_lt3.set_cur_controller('ADWIN') self.A_aom_lt3.set_cur_controller('ADWIN') self.yellow_aom_lt3.set_cur_controller('ADWIN') self.yellow_aom_lt3.set_power(0.) self.green_aom_lt3.set_power(0.) self.E_aom_lt3.set_power(0.) self.A_aom_lt3.set_power(0.) if DO_SEQUENCES: self.mwsrc_lt3.set_iq('on') self.mwsrc_lt3.set_pulm('on') self.mwsrc_lt3.set_frequency(self.params_lt3['mw_frq']) self.mwsrc_lt3.set_power(self.params_lt3['mw_power']) self.mwsrc_lt3.set_status('on' if (DO_SEQUENCES and LDE_DO_MW_LT3) else 'off') self.green_aom_lt1.set_power(0.) self.E_aom_lt1.set_power(0.) self.A_aom_lt1.set_power(0.) self.yellow_aom_lt1.set_cur_controller('ADWIN') self.green_aom_lt1.set_cur_controller('ADWIN') self.E_aom_lt1.set_cur_controller('ADWIN') self.A_aom_lt1.set_cur_controller('ADWIN') self.green_aom_lt1.set_power(0.) self.E_aom_lt1.set_power(0.) self.A_aom_lt1.set_power(0.) if DO_SEQUENCES: self.mwsrc_lt1.set_iq('on') self.mwsrc_lt1.set_pulm('on') self.mwsrc_lt1.set_frequency(self.params_lt1['mw_frq']) self.mwsrc_lt1.set_power(self.params_lt1['mw_power']) # have different types of sequences we can load. if DO_OPT_RABI_AMP_SWEEP: self.lt1_opt_rabi_sequence() else: self.lt1_sequence() self.mwsrc_lt1.set_status('on' if (DO_SEQUENCES and LDE_DO_MW_LT1) else 'off') if TH: self.tharp.start_T2_mode() self.tharp.calibrate() def lt1_sequence(self): print "Make lt1 sequence... " self.lt1_seq = pulsar.Sequence('TeleportationLT1') dummy_element = bseq._lt1_dummy_element(self) LDE_element = bseq._lt1_LDE_element(self) finished_element = bseq._lt1_sequence_finished_element(self) self.lt1_seq.append(name = 'LDE_LT1', wfname = (LDE_element.name if DO_LDE_SEQUENCE else dummy_element.name), trigger_wait = True, goto_target = 'LDE_LT1', repetitions = self.params['LDE_attempts_before_CR']) self.lt1_seq.append(name = 'LT1_ready_for_RO', wfname = finished_element.name, goto_target = 'LDE_LT1') ### AND ADD READOUT PULSES elements = [] elements.append(dummy_element) if DO_LDE_SEQUENCE: elements.append(LDE_element) qt.pulsar.upload(*elements) qt.pulsar.program_sequence(self.lt1_seq) self.awg_lt1.set_runmode('SEQ') self.awg_lt1.start() i=0 awg_ready = False while not awg_ready and i<40: try: if self.awg_lt1.get_state() == 'Waiting for trigger': awg_ready = True except: print 'waiting for awg: usually means awg is still busy and doesnt respond' print 'waiting', i, '/40' i=i+1 qt.msleep(0.5) if not awg_ready: raise Exception('AWG not ready')