print 'Autozeroing is switched off' print B_vec #set up datafile append = '_%imK' % T_mc_st + '_Vb%smV' % Vb_stop + '_Vg%sV' % Vg + '_B%sT' % abs( B_stop) + '_dB%smT' % B_step qt.config.set('datadir', directory) data = qt.Data(name=filename + append) tstr = strftime('%H%M%S_', data._localtime) data.add_coordinate('B (T)') #parameter to sweep data.add_coordinate('Vb (mV)') #parameter to sweep data.add_value('I (nA)') #parameter to read out data.create_file(settings_file=False) plot2d = qt.Plot2D(data, coorddim=1, valdim=2, traceofs=0) plot3d = qt.Plot3D(data, coorddims=(0, 1), valdim=2) #initialize & sweep for B in B_vec: ramp(vi, 'Vb', Vb_start, bias_step, bias_time) ramp_B_hold(B) qt.msleep(0.010) for Vb in Vb_vec: ramp(vi, 'Vb', Vb, bias_step, bias_time) qt.msleep(0.025) I = vm.get_readval() / IV_gain * unit data.add_data_point(B, Vb, I) data.new_block() spyview_process(data, Vb_start, Vb_stop, B) plot3d.save_png(filepath=directory + '\\' + tstr + filename + append)
def repeated_red_scans(**kw): pts = 100 m = ScanLT1() spectral_diffusion = kw.pop('spectral_diffusion', False) SMB100_lt1.set_power(-5) SMB100_lt1.set_frequency(2.8265e9) SMB100_lt1.set_iq('off') SMB100_lt1.set_pulm('off') SMB100_lt1.set_status('on') red_data = qt.Data(name = 'LaserScansYellowRepump_LT1_Red') red_data.add_coordinate('Voltage (V)') red_data.add_coordinate('Frequency (GHz)') red_data.add_coordinate('Counts (Hz)') red_data.add_coordinate('index') red_data.add_coordinate('start time') red_data.create_file() yellow_data = qt.Data(name = 'LaserScansYellowRepump_LT1_Yellow') yellow_data.add_coordinate('Voltage (V)') yellow_data.add_coordinate('Frequency (GHz)') yellow_data.add_coordinate('Counts (Hz)') yellow_data.add_coordinate('index') yellow_data.add_coordinate('start time') yellow_data.create_file() plt_red_cts = qt.Plot2D(red_data, 'bO', name='Laserscan_Counts', clear=True, coorddim=1, valdim=2, maxtraces=5, traceofs=5000) plt_red_frq = qt.Plot2D(red_data, 'rO', name='Laserscan_Frequency', clear=True, coorddim=0, valdim=1, maxtraces=1) plot3d_red = qt.Plot3D(red_data, name='Laserscan_Counts_Reps', clear=True, coorddims=(1,3), valdim=2) plt_yellow_cts = qt.Plot2D(yellow_data, 'bO', name='Laserscan_Counts_Y', clear=True, coorddim=1, valdim=2, maxtraces=5, traceofs=5000) plt_yellow_frq = qt.Plot2D(yellow_data, 'rO', name='Laserscan_Frequency_Y', clear=True, coorddim=0, valdim=1, maxtraces=1) plot3d_yellow = qt.Plot3D(yellow_data, name='Laserscan_Counts_Reps_Y', clear=True, coorddims=(1,3), valdim=2) t0 = time.time() for i in range(pts): if (msvcrt.kbhit() and msvcrt.getch()=='x'): break # tpulse = 10 # print "{} seconds of red power...".format(tpulse) # stools.apply_awg_voltage('AWG', 'ch4_marker1', 0.52) # qt.msleep(tpulse) # stools.apply_awg_voltage('AWG', 'ch4_marker1', 0.02) if spectral_diffusion: m.spectral_diffusion(20, 25, 0.2e-9, 58, 65, 0.01, 20, 1e-9, red_data = red_data, yellow_data = yellow_data, data_args=[i, time.time()-t0]) else: m.yellow_red(20, 25, 0.2e-9, 58, 65, 0.01, 20, 1e-9, red_data = red_data, yellow_data = yellow_data, data_args=[i, time.time()-t0]) red_data.new_block() yellow_data.new_block() plot3d_red.update() plot3d_yellow.update() SMB100_lt1.set_status('off') red_data.close_file() yellow_data.close_file() plot3d_red.save_png() plot3d_yellow.save_png()
def repeated_red_scans(**kw): m = Scan() spectral_diffusion = kw.pop('spectral_diffusion', False) gate_scan = kw.pop('gate_scan', False) gate_range = kw.pop('gate_range', None) pts = kw.pop('pts', 100) # m.mw.set_power(-9) # m.mw.set_frequency(2.8265e9) # m.mw.set_iq('off') # m.mw.set_pulm('off') # m.mw.set_status('on') m.newfocus.set_power(1e-9) red_data = qt.Data(name='LaserScansYellowRepump_LT4_Red') red_data.add_coordinate('Voltage (V)') red_data.add_coordinate('Frequency (GHz)') red_data.add_coordinate('Counts (Hz)') if gate_scan: red_data.add_coordinate('Gate voltage (V)') else: red_data.add_coordinate('index') red_data.add_coordinate('start time') red_data.create_file() yellow_data = qt.Data(name='LaserScansYellowRepump_LT4_Yellow') yellow_data.add_coordinate('Voltage (V)') yellow_data.add_coordinate('Frequency (GHz)') yellow_data.add_coordinate('Counts (Hz)') if gate_scan: yellow_data.add_coordinate('Gate voltage (V)') else: yellow_data.add_coordinate('index') yellow_data.add_coordinate('start time') yellow_data.create_file() plt_red_cts = qt.Plot2D(red_data, 'r-', name='Laserscan_Counts', clear=True, coorddim=1, valdim=2, maxtraces=5, traceofs=5000, autoupdate=True) plt_red_frq = qt.Plot2D(red_data, 'rO', name='Laserscan_Frequency', clear=True, coorddim=0, valdim=1, maxtraces=1, autoupdate=True) plot3d_red = qt.Plot3D(red_data, name='Laserscan_Counts_Reps', clear=True, coorddims=(1, 3), valdim=2) plt_yellow_cts = qt.Plot2D(yellow_data, 'b-', name='Laserscan_Counts_Y', clear=True, coorddim=1, valdim=2, maxtraces=5, traceofs=5000, autoupdate=True) plt_yellow_frq = qt.Plot2D(yellow_data, 'bO', name='Laserscan_Frequency_Y', clear=True, coorddim=0, valdim=1, maxtraces=1, autoupdate=True) plot3d_yellow = qt.Plot3D(yellow_data, name='Laserscan_Counts_Reps_Y', clear=True, coorddims=(1, 3), valdim=2, autoupdate=True) if gate_scan: gate_x = np.linspace(gate_range[0], gate_range[1], pts) ret = True t0 = time.time() for i in range(pts): print 'press x to stop' qt.msleep(2.5) if (msvcrt.kbhit() and msvcrt.getch() == 'x'): ret = False break # tpulse = 10 # print "{} seconds of red power...".format(tpulse) # stools.apply_awg_voltage('AWG', 'ch4_marker1', 0.52) # qt.msleep(tpulse) # stools.apply_awg_voltage('AWG', 'ch4_marker1', 0.02) if spectral_diffusion: m.spectral_diffusion(20, 25, 0.2e-9, 58, 65, 0.01, 20, 1e-9, red_data=red_data, yellow_data=yellow_data, data_args=[i, time.time() - t0]) else: ix = i if gate_scan: set_gate_voltage(gate_x[i]) ix = gate_x[i] * 45. / 1000 m.yellow_red(29, 32, 0.008, 50e-9, 54.9, 55.4, 0.004, 20, 0.03e-9, red_data=red_data, yellow_data=yellow_data, data_args=[ix, time.time() - t0]) red_data.new_block() yellow_data.new_block() plot3d_red.update() plot3d_yellow.update() plt_red_cts.update() if gate_scan: set_gate_voltage(0) # m.mw.set_status('off') m.newfocus.set_power(0e-9) red_data.close_file() yellow_data.close_file() plot3d_red.save_png() plot3d_yellow.save_png() return ret
def run_scan(self, **kw): stabilizing_time = kw.pop('stabilizing_time', 0.01) d = qt.Data(name=self.mprefix + '_' + self.name) d.create_file() 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]') d2 = qt.Data(name=self.mprefix + '_' + self.name + '_yellow') d2.create_file() d2.add_coordinate('Voltage (V)') d2.add_coordinate('Frequency (GHz)') d2.add_coordinate('Counts [Hz]') d2.add_coordinate('Gate Voltage(V)') p2 = qt.Plot2D(d2, 'ro', title='Frq (left) vs Voltage (bottom)', plottitle=self.mprefix + '_yellow', name='Laser Scan_yellow', clear=True, coorddim=0, valdim=1, maxtraces=1) p2.add(d2, 'b', title='Counts (right) vs Frq (top)', coorddim=1, valdim=2, right=True, top=True) p2.set_x2tics(True) p2.set_y2tics(True) p2.set_x2label('Frequency (GHz)') p2.set_y2label('Counts [Hz]') if self.plot_3D: p3D = qt.Plot3D(d, name='Laser_Scan2D', plottitle=self.mprefix, coorddims=(1, 3), valdim=2, clear=True) p3D2 = qt.Plot3D(d2, name='Laser_Scan2D_yellow', plottitle=self.mprefix, coorddims=(1, 3), valdim=2, clear=True) d3 = qt.Data(name=self.mprefix + '_' + self.name + '_hene') d3.create_file() d3.add_coordinate('repetition') d3.add_coordinate('Frequency (GHz)') qt.mstart() ################################################ 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 if self.set_gate: self.gate_scan_to_voltage(gv) else: gv = j frq = self.get_frequency(self.wm_channel_hene) d3.add_data_point(j, frq) ####################### RED scan self.set_laser_power(self.laser_power) 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 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: print 'WARNING: WM gives frq', frq continue d.add_data_point(v, frq, cts, gv) if np.mod(i, 10) == 0: p.update() # RED scan back +repump self.set_laser_power(self.red_repump_power) self.scan_to_voltage(self.pump_voltage - 0.2) self.scan_to_voltage(self.pump_voltage + 0.2) self.scan_to_voltage(self.start_voltage) self.set_laser_power(0) if self.set_gate_to_zero_before_repump: self.gate_scan_to_voltage(0.) p.update() 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 and self.plot_3D: p3D.update() ####################### ####################### YELLOW scan self.set_laser_power_yellow(self.laser_power_yellow) for i, v in enumerate( np.linspace(self.start_voltage_yellow, self.stop_voltage_yellow, self.pts_yellow)): if msvcrt.kbhit(): chr = msvcrt.getch() if chr == 'q': break self.set_laser_voltage_yellow(v) qt.msleep(stabilizing_time) cts = float( self.get_counts(self.integration_time_yellow)[ self.counter_channel]) / (self.integration_time * 1e-3) frq = self.get_frequency( self.wm_channel_yellow ) * self.frq_factor_yellow - self.frq_offset_yellow if frq < 0: continue d2.add_data_point(v, frq, cts, gv) if np.mod(i, 10) == 0: p2.update() # YELLOW scan back +repump self.set_laser_power_yellow(self.yellow_repump_power) self.scan_to_voltage_yellow(self.start_voltage_yellow) self.set_laser_power_yellow(0) if self.set_gate_to_zero_before_repump: self.gate_scan_to_voltage(0.) p2.update() plotsavename = os.path.splitext( d2.get_filepath())[0] + ('_gate_voltage_%2.3f' % gv) + '.png' p2.set_plottitle(str(os.path.splitext(d.get_filename())[0])) p2.save_png(filepath=plotsavename) d2.new_block() if self.gate_pts > 1 and self.plot_3D: p3D2.update() ####################### qt.mend() ############################################################## if self.gate_pts > 1 and self.plot_3D: p3D.reset() qt.msleep(1) p3D.save_png() p3D2.reset() qt.msleep(1) p3D2.save_png() np.savez(os.path.splitext(d.get_filepath())[0] + '.npz', data=d.get_data()) np.savez(os.path.splitext(d2.get_filepath())[0] + '.npz', data=d2.get_data()) np.savez(os.path.splitext(d3.get_filepath())[0] + '.npz', data=d3.get_data()) d.close_file() d2.close_file() d3.close_file()
def example2(f_vec, b_vec): ''' This example introduces three new features: 1) setting format and/or precision of data in the datafile. using 'precision' will keep the default scientific notation, 'format' can be anything you like => add_coordinate(precision=<nr>) => add_coordinate(format='<format_string>') 2) specify specific filepath for the data file (in stead of automatic filepath) => create_file(filepath=<filepath>) 3) turn off automatic saving of instrument-settings-file. => create_file(settings_file=False) To run the function type in the terminal: fv=numpy.arange(0,10,0.01) bv=numpy.arange(-5,5,0.1) measure_module.example2(fv, bv) ''' qt.mstart() # this shows how to change format of saved data (per column) data = qt.Data(name='testmeasurement') data.add_coordinate('frequency, mw src 1 [Hz]', precision=3) data.add_coordinate('Bfield, ivvi dac 3 [mV]', format='%.12f') data.add_value('Psw SQUID', format='%.3e') data.create_file() # this shows how to save to a specific path and name, and how # to avoid a settings file to be created. The directory is first # retreived from the previous data object dir = data.get_dir() maxfilepath = os.path.join(dir, 'maxvals.dat') data_max = qt.Data(name='maxvals') data_max.add_coordinate('Bfield, ivvi dac 3 [mV]') data_max.add_value('resonance frequency [Hz]') data_max.create_file( filepath=maxfilepath, settings_file=False) plot2d = qt.Plot2D(data, name='measure2D') plot3d = qt.Plot3D(data, name='measure3D', style='image') plot2dmax = qt.Plot2D(data_max, name='maxvals') for b in b_vec: fake_ivvi_set_dac_3(b) last_trace = [] for f in f_vec: fake_mw_src_set_freq(f) result = fake_readout_psw() data.add_data_point(f, b, result) last_trace.append(result) qt.msleep(0.01) data.new_block() loc_of_max = numpy.argmax(last_trace) freq_at_max = f_vec[loc_of_max] data_max.add_data_point(b, freq_at_max) data.close_file() data_max.close_file() qt.mend()
def sweep_power_measure_trace(xstart=-100, xend=-60, Nx=10, drivefrequency=11, centerfrequency=11, span=2, Nrepeat=1, nplc=1, plotting=True, title=''): #x = RF power of signal generator qt.mstart() filename = 'test' Ny = specana.get_sweep_points() data = qt.Data(name=filename) data.add_coordinate('Frequency (MHz)', size=Ny) data.add_coordinate('RF Power (dBm)', size=Nx) data.add_value('Spectral power (dBm)') data.create_file() x_vec = linspace(xstart, xend, Nx) siggen.switch_on() siggen.set_frequency(drivefrequency) specana.set_center_frequency(centerfrequency) specana.set_span(span) for cnt in range(Nrepeat): for xcnt, x_sweep in enumerate(x_vec): print 'power #%s' % (xcnt + 1) siggen.set_power(x_sweep) sleep(2) Vtrace = specana.get_trace() # value trace xtrace = x_sweep * ones(len(Vtrace)) ytrace = linspace(centerfrequency - span / 2, centerfrequency + span / 2, len(Vtrace)) # frequency trace data.new_block() data.add_data_point(ytrace, xtrace, Vtrace) siggen.switch_off() print 'RFPower from %s dBm to %s dBm at %s MHz in %s steps' % ( xstart, xend, drivefrequency, Nx) if plotting: #plot2d = qt.Plot2D(data, name=filename) plot3d = qt.Plot3D(data, name=filename) if plotting: #plot2d.save_png() plot3d.save_png() data._write_settings_file() data_array = data.get_data() data.close_file() qt.mend()
def stability_diagram(channel1=1, xstart=-100, xend=-60, Nx=10, channel2=2, ystart=-100, yend=-60, Ny=10, Nrepeat=1, plotting=True, title='', returntozero=True): #x = dac channel1 (sweep) #y = dac channel2 (loop1) #where to add general measurement data? qt.mstart() filename = 'test' multiplier1 = ivvi.get_dac_multiplier(channel1) multiplier2 = ivvi.get_dac_multiplier(channel2) data = qt.Data(name=filename) if channel1 == 1: xname = 'Bias voltage (mV)' elif channel1 == 2: xname = 'Gate voltage (mV)' else: xname = 'dac%s' % channel1 data.add_coordinate(xname, size=Nx) if channel2 == 1: yname = 'Bias voltage (mV)' elif channel2 == 2: yname = 'Gate voltage (mV)' else: yname = 'dac%s' % channel2 data.add_coordinate(yname, size=Ny) a = keithley1.get_parameter_options('IVVI_gain') curryes = a['curryes'] if curryes: #is current measured or voltage? data.add_value('Current (pA)') else: data.add_value('Voltage (mV)') data.create_file() x_vec = linspace(xstart, xend, Nx) y_vec = linspace(ystart, yend, Ny) for cnt in range(Nrepeat): for ycnt, y_sweep in enumerate(y_vec): print ycnt ivvi.set('dac%s' % channel2, y_sweep) for xcnt, x_sweep in enumerate(x_vec): ivvi.set('dac%s' % channel1, x_sweep) z_sweep = keithley1.get_readlastval() data.add_data_point(y_sweep, x_sweep, z_sweep) data.new_block() print xname + ' from %s mV to %s mV in %s steps' % (multiplier1 * xstart, multiplier1 * xend, Nx) print yname + ' from %s mV to %s mV in %s steps' % (multiplier2 * ystart, multiplier2 * yend, Ny) if plotting: #plot2d = qt.Plot2D(data, name=filename) plot3d = qt.Plot3D(data, name=filename) if plotting: #plot2d.save_png() plot3d.save_png() data._write_settings_file() data_array = data.get_data() print data_array cnt2 = 0 deltax = (float(xend) - xstart) / (Nx - 1) datastabdiag = qt.Data(name='test2') if channel1 == 1: xname = 'Bias voltage (mV)' elif channel1 == 2: xname = 'Gate voltage (mV)' else: xname = 'dac%s' % channel1 datastabdiag.add_coordinate(xname, size=Nx) if channel2 == 1: yname = 'Bias voltage (mV)' elif channel2 == 2: yname = 'Gate voltage (mV)' else: yname = 'dac%s' % channel2 datastabdiag.add_coordinate(yname, size=Ny) datastabdiag.add_value('dI/dV (pA/mV)') datastabdiag.create_file() #datastabdiag_array=zeros(data_array.shape)+1.5 print type(data) print type(datastabdiag) cnt2 = 0 print deltax for cnt in range(Nrepeat): for ycnt, y_sweep in enumerate(y_vec): for xcnt, x_sweep in enumerate(x_vec): if xcnt != Nx - 1: #stability diagram has same size as original data, with last line double, gnuplot doesn't plot last/first line anyway z_sweep = (data_array[cnt2 + 1][2] - data_array[cnt2][2]) / deltax print xcnt, z_sweep, type(z_sweep) datastabdiag.add_data_point(y_sweep, x_sweep, z_sweep) cnt2 = cnt2 + 1 datastabdiag.new_block() plotstabdiag = qt.Plot3D(datastabdiag, name='test') print datastabdiag.get_data() data.close_file() qt.mend() if returntozero: set_dacs_to_zero()
def example3(x_vec=numpy.linspace(0, 10, 10), y_vec=numpy.linspace(0, 10, 50)): ''' To run the function type in the terminal: measure_module.example3() ''' qt.mstart() data = qt.Data(name='testmeasurement') data.add_coordinate('x') data.add_coordinate('y') data.add_value('z1') data.add_value('z2') data.add_value('z3') data.create_file() plot2d_1 = qt.Plot2D(data, name='2D_1', coorddim=1, valdim=2) plot2d_2 = qt.Plot2D(data, name='2D_2', coorddim=1, valdim=2, maxtraces=1) plot2d_3 = qt.Plot2D(data, name='2D_3', coorddim=1, valdim=2, maxtraces=1) plot2d_3.add_data(data, coorddim=1, valdim=3, maxtraces=1) plot2d_3.add_data(data, coorddim=1, valdim=4, maxtraces=1) plot2d_4 = qt.Plot2D(data, name='2D_4', coorddim=1, valdim=2, mintime=0.3) plot2d_5 = qt.Plot2D(data, name='2D_5', coorddim=1, valdim=2, autoupdate=False) plot3d_1 = qt.Plot3D(data, name='3D_1', style='image') plot3d_2 = qt.Plot3D(data, name='3D_2', style='image', coorddims=(1, 0), valdim=4) for x in x_vec: for y in y_vec: z1 = numpy.sin(x + y) z2 = numpy.cos(x + y) z3 = numpy.sin(x + 2 * y) data.add_data_point(x, y, z1, z2, z3) if z1 > 0: plot2d_5.update() qt.msleep(0.1) data.new_block() plot2d_1.save_png() plot2d_1.save_gp() plot3d_2.save_png() plot3d_2.save_gp() data.close_file() qt.mend()
smb.get_all() #Set up datafile data = qt.Data(name=filename) data.add_coordinate('RF frequency [MHz]') data.add_coordinate('FM Deviation [kHz]') data.add_value('X [pA]') data.add_value('Y [pA]') data.create_file() data.copy_file('FMdevsweep.py') plot2dx = qt.Plot2D(data, name='xcomp', coorddim=0, valdim=2) #plot2dy = qt.Plot2D(data, name='ycomp', coorddim=0, valdim=3) plot3D = qt.Plot3D(data, name='xcomp over deviation', coorddims=(0,1), valdim=2) #Actual sweep spyview_process(reset=True) for dev in arange(FM_dev_start,FM_dev_stop+FM_dev_step,FM_dev_step): smb.set_FM_deviation(dev) qt.msleep(1) for f in arange(RF_start,RF_stop+RF_step,RF_step): smb.set_RF_frequency(f) qt.msleep(.3) x=lockin.get_X() #or Y or R y=lockin.get_Y() x*=-1e5 y*=-1e5 data.add_data_point(f,dev,x,y) data.new_block()