#############################################################
''' MEASUREMENT'''

# generating gate pattern
pattern = gate_pattern(target_gate=target_gate, mode='double', data_points=gate_points, shift_voltage= shift_voltage )


# Resistance measurement while modulating the gate voltage
count = 0 # couter of step numbers
leakage_current = 0

idstring = sample_name
if save_data:
	colnames = ['step ()','gate voltage (V)','leakage current (nA)','Resistance (k ohm)','phase ()', 'demodulation duration (s)', 'temperature (K)', 'time (s)']
	my_file_2= stlab.newfile(prefix+'_',idstring,autoindex=True,colnames=colnames)



gate_voltage_step = pattern['ramp_pattern'][1]-pattern['ramp_pattern'][0]
ramp_time = np.abs(np.floor(shift_voltage/ramp_speed))

END = False
INI_time = time.time()
TEMPERATURE = np.empty(shape=(0))
RESISTANCE = np.empty(shape=(0))



while (not END) and (low_temp <= mytriton.GetTemperature(8) <= high_temp):
示例#2
0
''' Initialize '''  
pygame.init()
pygame.display.set_mode((100,100))

## Temperature readout
mytriton = TritonWrapper()

try:
    T = mytriton.GetTemperature(8)
except:
    T = -1

## Output setting
idstring = '_at{:.2f}mK'.format(T).replace('.','p')
colnames = ['Vmeas (V)', 'Iset (A)', 'Rmeas (Ohm)', 'Vgate (V)', 'T (mK)', 'Time (s)', 'Ileakage (nA)']
myfile = stlab.newfile(prefix, idstring, colnames, autoindex=True)


Vglist = np.linspace(Vgmax, Vgmin, (Vgmax-Vgmin)/deltaVg+1)
Vg_ini = Vglist[0]
END = False
total_count = Vglist.shape[0]
resistance_array = np.array([])
applied_gate_array = np.array([])
I_leakage_array = np.array([])


##Inititalizing the devices
ivvi = IVVI_DAC(addr='COM5', verb=True)
ivvi.RampAllZero(tt=2.)
示例#3
0
# IO settings
pygame.init()
pygame.display.set_mode((100, 100))

#############################################################
''' MEASUREMENT'''

if save_data:
    colnames = [
        'time (s)', 'temperature (K)', 'gate voltage (V)',
        'leakage current (A)', 'resistance (ohm)'
    ]
    my_file = stlab.newfile(prefix,
                            '_',
                            autoindex=True,
                            colnames=colnames,
                            mypath=path)

END = False
INI_time = time.time()
t0 = INI_time
T0 = 300

TIME = np.empty(shape=(0))
TEMPERATURE = np.empty(shape=(0))
RESISTANCE = np.empty(shape=(0))

## Estimating for the internal resistances
if initial_calibration:
    I_cal_p = 0
示例#4
0
def rcsj(current, damping, prefix=[], fft=False,svpng=False,svvolt=False,saveplot=False,savefile=False,normalized=False,printmessg=True):
    '''
    iv sweep for rcsj model
    - damping: tuple of either 'Q' or 'beta' and respective value
    returns IV curve with options:
    - svpng: save each iteration to png
    - svvolt: save peak detection of voltage to png
    - saveplot: save ivc to .png
    - savefile: save ivc to .dat
    - normalized: returns voltage/Q
    - printmessg: print statusmessage after iteration
    '''

    current = current.tolist()      # makes it faster ?
    voltage = []
    freq = []
    volt_fft = []
    
    t, tsamp = timeparams(damping)
    y0 = (0,0) # always start at zero phase and zero current
    idxstart = int(-tsamp*len(t)) # only sample the last tsamp=1% of evaluated time
    for k,i in enumerate(current):
        
        y = odeint(rcsj_curr, y0, t, args=(i,damping))
        #y0 = (0,max(y[:,1])) 
        y0 = y[-1,:]             # new initial condition based on last iteration
        
        idx = argrelextrema(y[idxstart:,1], np.greater)
        
        if len(idx[0])<2:
            mean = 0
            voltage.append(mean)
        else:
            x1, x2 = idx[0][-2], idx[0][-1]
            mean = np.mean([y[x1+idxstart:x2+idxstart,1]])
            voltage.append(mean)
            
            if svpng:
                path='../plots/voltage/{}={:E}/'.format(damping[0],damping[1])
                ensure_dir(path)
                plt.plot(t[idxstart:],y[idxstart:,1])
                plt.plot([t[x1+idxstart],t[x2+idxstart]],[y[x1+idxstart,1],y[x2+idxstart,1]],'o')
                plt.ylim(0,3*damping[1])
                plt.savefig(path+'i={:2.3f}.png'.format(i))
                plt.close()
        
        if prefix:
            #timedata = {'Time (wp*t)' : t, 'Phase (rad)' : y[:,0], 'AC Voltage (V)' : y[:,1]}
            #ivdata = {'Current (Ic)': i, 'DC Voltage (V)': mean, 'beta ()': Q}
            #idstring = 'beta={:.2f}'.format(ivdata['beta ()'])
            #savedata((k,len(current)),prefix,idstring,timedata,ivdata)
            
            data2save = {'Time (wp*t)' : t, 'Phase (rad)' : y[:,0], 'AC Voltage (V)' : y[:,1]}
            data2save = stlab.stlabdict(data2save)
            data2save.addparcolumn('Current (Ic)',i,last=False)
            data2save.addparcolumn('DC Voltage (V)',mean)
            data2save.addparcolumn('{} ()'.format(damping[0]),damping[1])
            if k == 0:
                idstring = '{}={:2.2f}'.format(damping[0],damping[1])
                ensure_dir(prefix)
                myfile = stlab.newfile(prefix,idstring,data2save.keys(),
                usedate=False,usefolder=False)#,mypath='simresults/')
            stlab.savedict(myfile,data2save)
            if k == len(current):
                myfile.close()
                
               
        if svvolt:
            path='../plots/sols/{}={:E}/'.format(damping[0],damping[1])
            ensure_dir(path)
            fig, ax = plt.subplots(2,sharex=True)
            ax[0].plot(t,y[:,0])
            ax[1].plot(t,y[:,1])
            ax[0].set_ylabel(r'$\phi$')
            ax[1].set_ylabel(r'd$\phi$/dt')
            ax[1].set_xlabel(r'$\tau=t/\tau_c$')
            fig.subplots_adjust(hspace=0)
            plt.savefig(path+'i={:2.3f}.png'.format(i))
            plt.close()
        
        
        if fft:
            F, signal_fft = analyze_fft(t,y[:,1])
            freq.append(F)
            volt_fft.append(abs(signal_fft))
        
            
        if printmessg:
            print('Done: {}={:E}, i={:2.3f}'.format(damping[0],damping[1],i)) 

    current, voltage = np.asarray(current), np.asarray(voltage)
    
    if savefile:
        saveiv(current,voltage,damping,normalized)
        
    if saveplot:
        saveivplot(current,voltage,damping,normalized)

    if normalized:
        voltage = voltage/damping[1]
    
    if not fft:    
        return {'Current': current, 'DC Voltage': voltage}
    else:
        return {'Current': current, 'DC Voltage': voltage, 'Frequency': freq[0], 'FFT': np.asarray(volt_fft)}
示例#5
0
                       mode='double',
                       data_points=gate_points,
                       shift_voltage=shift_voltage)

# Resistance measurement while modulating the gate voltage
count = 0  # couter of step numbers
leakage_current = 0

idstring = sample_name
if save_data:
    colnames = [
        'step ()', 'gate voltage (V)', 'leakage current (nA)',
        'Resistance (k ohm)', 'phase ()', 'demodulation duration (s)'
    ]
    my_file_2 = stlab.newfile(prefix + '_',
                              idstring,
                              autoindex=True,
                              colnames=colnames)

ramp_time = np.abs(np.floor(shift_voltage / ramp_speed))
gate_dev.RampVoltage(shift_voltage, tt=10 * ramp_time, steps=100)

gate_voltage_step = pattern['ramp_pattern'][1] - pattern['ramp_pattern'][0]
# ramp_time = np.abs(np.floor(gate_voltage_step/ramp_speed))
ramp_time = 0.5
plt_Vg = np.array([])
plt_resistance = np.array([])
plt_leak_curr = np.array([])

END = False

for count, gate_voltage in enumerate(
			# plt.title('Phase (°)', backgroundcolor = 'white')


		plt.pause(0.1)


		if save_data:

			# temp = tempdev.GetTemperature()
			data['Power (dBm)'] = VNA.GetPower()
			data['Gate Voltage (V)'] = gate_voltage
			data['Leakage Current (A)'] = leakage_current
			data['Temperature (K)'] = temp

			if count==0:
				Data = stlab.newfile(prefix,'_',data.keys(),autoindex = True, mypath= path)
			stlab.savedict(Data, data)


		for event in pygame.event.get(): # stopping if 's' pressed
			if event.type == QUIT: sys.exit()

			if event.type == KEYDOWN and event.dict['key'] == 115: # corresponding to character "s"
				STOP = True

		if STOP:
			break


		t = time.time()
		print('measured gate steps:', count+1)
示例#7
0
Example script to perform a series of frequency traces on a PNA as a function of input power

"""

import stlab
import numpy as np

prefix = 'M' #prefix for measurement folder name.  Can be anything or empty
idstring = 'Dev1_powersweep' #Additional info included in measurement folder name.  Can be anything or empty

pna = stlab.adi(addr='TCPIP::192.168.1.42::INSTR',reset=False,verb=True) #Initialize device communication and reset

pna.SetRange(4e9,8e9) #Set frequency range in Hz
pna.SetIFBW(300.) #Set IF bandwidth in Hz
pna.SetPoints(1001) #Set number of frequency points

powstart = -45.
powstop = -0.
steps = 5
powers = np.linspace(powstart,powstop,steps) #generate power sweep steps

myfile = stlab.newfile(prefix,idstring,autoindex=True)
for i,rfpower in enumerate(powers):
    pna.SetPower(rfpower) #set pna power
    data = pna.MeasureScreen_pd() #Trigger 2 port measurement and retrieve data in Re,Im format.  Returns OrderedDict
    stlab.saveframe(myfile, data) #Save measured data to file.  Written as a block for spyview.
    #Create metafile for spyview at each measurement step
    stlab.metagen.fromarrays(myfile,data['Frequency (Hz)'],powers[0:i+1],xtitle='Frequency (Hz)',ytitle='Power (dB)',colnames=data.keys())
myfile.close() #Close file

        # temp = tempdev.GetTemperature()
        data['Power (dBm)'] = VNA.GetPower()
        data['Gate Voltage (V)'] = gate_voltage
        data['Leakage Current (A)'] = leakage_current
        data['Temperature (K)'] = temp

        if count == 0:
            colnames = [
                'Vset (V)', 'Imeas (A)', 'R (Ohm)', 'Vgate (V)', 'T (K)',
                'Ileakage (nA)'
            ]

            Data = stlab.newfile(prefix,
                                 '_',
                                 colnames,
                                 autoindex=True,
                                 mypath=path)

        stlab.savedict(Data, data)

    if STOP:
        break

    t = time.time()
    print('measured gate steps:', count + 1)
    time_passed = t - t_in
    time_remain = (time_passed / (count + 1)) * (len(gate_pattern) - count - 1)
    print('ELAPSED TIME: {:.2f} min'.format(time_passed / 60))
    print('REMAINING TIME: {:.2f} min'.format(time_remain / 60))
input_energy = np.array([])
count = 0
destination_current = 0
current = 0
vmeasure_gain = []

if save_data:
    parameters = [
        'time (s)', 'resistance (ohm)', 'current (uA)', 'sum input energy (J)'
        'power (W)'
        'temperature (K)'
    ]

    my_file = stlab.newfile(prefix,
                            '',
                            autoindex=True,
                            colnames=parameters,
                            mypath=path)

print('\n-------------------------------------------------------------------')
print('How to start?'
      '\n "s" : set destination current, currently at:', destination_current,
      'uA'
      '\n "a": adjust current ramp spead, currently is:', current_ramp_spead,
      '[uA/s]'
      '\n "u": step up the current by: +', current_step, '[uA]'
      '\n "d": step down the current by: -', current_step, '[uA]'
      '\n "z": fast return to zero by 10x voltage ramp speed',
      '\n "t": go automatic', '\n "k": show keys',
      '\n "e": stop the experiment')
ramp_zero = False
示例#10
0
numPoints = 1001
startFreq = 2e9
stopFreq = 5e9
power = -10

KEYSIGHT.write('INST:SEL "NA"')  #set mode to Network Analyzer
KEYSIGHT.SinglePort()  #changed this to from twoport to singleport
KEYSIGHT.write("SENS:SWE:POIN " + str(numPoints))
KEYSIGHT.write("SENS:FREQ:START " + str(startFreq))
KEYSIGHT.write("SENS:FREQ:STOP " + str(stopFreq))
KEYSIGHT.SetPower(power)

#device.write("SENS:DIF:BAND " + str(bandwidth)) #this crashes the fieldfox error -113
KEYSIGHT.SetIFBW(100.)

myfile = stlab.newfile(prefix, '_', autoindex=True, mypath=path)

data = KEYSIGHT.MeasureScreen_pd()

stlab.saveframe(
    myfile,
    data)  #Save measured data to file.  Written as a block for spyview.
myfile.close()

stlab.autoplot(myfile,
               'Frequency (Hz)',
               'S11dB (dB)',
               title=prefix,
               caption=caption)
stlab.autoplot(myfile,
               'Frequency (Hz)',
示例#11
0
文件: quickQ.py 项目: yausern/stlab
newstr += 'RFpow = ' + str(measpow) + ' dBm'

ax1 = plt.gca()
plt.text(0.55, 0.15, newstr, fontsize=7, transform=ax1.transAxes)

try:
    tag = sys.argv[1]
except IndexError:
    tag = ''

#Save fitted trace using tag
prefix = 'quickQ'
idstring = tag
myfile = stlab.newfile(prefix,
                       idstring,
                       data.keys(),
                       usedate=True,
                       usefolder=True,
                       autoindex=True)
outfilename = os.path.splitext(myfile.name)[0]
stlab.saveframe(myfile, data)
myfile.close()
plt.show()

#Save figure
fig.savefig(outfilename + '.plot.png')

#Save fit parameters
myfile = open(outfilename + '.fit.dat', 'w')
for q in params:
    myfile.write("{} = {} +- {}\n".format(params[q].name, params[q].value,
                                          params[q].stderr))
示例#12
0
span = 10e7 # Hz
npoints = 4001
power = -20 # dBm

#Setup PNA sweep parameters
mypna.SetIFBW(ifbw)
mypna.SetCenterSpan(f0,span)
mypna.SetPoints(npoints)
mypna.SetPower(power)

#Setup SMB frequency
mysg.setCWfrequency(sgf0)
#mypna.write('ROSC:SOUR EXT')

for i,P in enumerate(sgpow): #Loop over desired SMB powers
    mysg.setCWpower(P) #Set the power to current loop value
    mysg.RFon() #Activate RF power on SMB
    data = mypna.Measure2ports() #Execute PNA sweep and return data
    data['Power (dBm)'] = np.full(npoints, power-20.)
    #Add some data columns to measured data
    data['SMBPower (dBm)'] = np.full(npoints, P)
    data['S11dB (dB)'] = 20.*np.log10( [ np.sqrt(np.power(a,2.)+np.power(b,2.)) for a,b in zip(data['S11re ()'],data['S11im ()'])] )
    data['S21dB (dB)'] = 20.*np.log10( [ np.sqrt(np.power(a,2.)+np.power(b,2.)) for a,b in zip(data['S21re ()'],data['S21im ()'])] )
    if i==0: #if on first measurement, create new measurement file and folder using titles extracted from measurement
        myfile,fullfilename,_ = stlab.newfile(prefix,idstring,data.keys())
    stlab.savedict(myfile, data) #Save measured data to file.  Written as a block for spyview.
    #Create metafile for spyview at each measurement step
    stlab.metagen.fromarrays(fullfilename,data['Frequency (Hz)'],sgpow[0:i+1],xtitle='Frequency (Hz)',ytitle='SMBPower (dB)',colnames=data.keys())    
myfile.close()

示例#13
0
ax1 = plt.gca()
plt.text(0.55,0.15,newstr,fontsize=7,transform=ax1.transAxes)



try:
    tag = sys.argv[1]
    tag = os.path.splitext(os.path.basename(tag))[0]
except IndexError:
    tag = ''

#Save fitted trace using tag
prefix = 'quickQ'
idstring = tag
print(idstring,prefix)
myfile = stlab.newfile(prefix,idstring,data.keys(),usedate=False,usefolder=True,autoindex=True)
outfilename = os.path.splitext(myfile.name)[0]
stlab.saveframe(myfile,data)
myfile.close()


#Save figure
fig.savefig(outfilename + '.plot.png')
plt.show()

#Save fit parameters
myfile = open(outfilename + '.fit.dat','w')
for q in params:
    myfile.write("{} = {} +- {}\n".format(params[q].name,params[q].value,params[q].stderr) )
myfile.close()
示例#14
0
#mypna.write('ROSC:SOUR EXT')

for i, P in enumerate(sgpow):  #Loop over desired SMB powers
    mysg.setCWpower(P)  #Set the power to current loop value
    mysg.RFon()  #Activate RF power on SMB
    data = mypna.Measure2ports()  #Execute PNA sweep and return data
    data['Power (dBm)'] = np.full(npoints, power - 20.)
    #Add some data columns to measured data
    data['SMBPower (dBm)'] = np.full(npoints, P)
    data['S11dB (dB)'] = 20. * np.log10([
        np.sqrt(np.power(a, 2.) + np.power(b, 2.))
        for a, b in zip(data['S11re ()'], data['S11im ()'])
    ])
    data['S21dB (dB)'] = 20. * np.log10([
        np.sqrt(np.power(a, 2.) + np.power(b, 2.))
        for a, b in zip(data['S21re ()'], data['S21im ()'])
    ])
    if i == 0:  #if on first measurement, create new measurement file and folder using titles extracted from measurement
        myfile = stlab.newfile(prefix, idstring, data.keys())
    stlab.savedict(
        myfile,
        data)  #Save measured data to file.  Written as a block for spyview.
    #Create metafile for spyview at each measurement step
    stlab.metagen.fromarrays(myfile,
                             data['Frequency (Hz)'],
                             sgpow[0:i + 1],
                             xtitle='Frequency (Hz)',
                             ytitle='SMBPower (dB)',
                             colnames=data.keys())
myfile.close()
示例#15
0
span = 10e7 # Hz
npoints = 4001
power = -20 # dBm

#Setup PNA sweep parameters
mypna.SetIFBW(ifbw)
mypna.SetCenterSpan(f0,span)
mypna.SetPoints(npoints)
mypna.SetPower(power)

#Setup SMB frequency
mysg.setCWfrequency(sgf0)
#mypna.write('ROSC:SOUR EXT')

for i,P in enumerate(sgpow): #Loop over desired SMB powers
    mysg.setCWpower(P) #Set the power to current loop value
    mysg.RFon() #Activate RF power on SMB
    data = mypna.Measure2ports() #Execute PNA sweep and return data
    data['Power (dBm)'] = np.full(npoints, power-20.)
    #Add some data columns to measured data
    data['SMBPower (dBm)'] = np.full(npoints, P)
    data['S11dB (dB)'] = 20.*np.log10( [ np.sqrt(np.power(a,2.)+np.power(b,2.)) for a,b in zip(data['S11re ()'],data['S11im ()'])] )
    data['S21dB (dB)'] = 20.*np.log10( [ np.sqrt(np.power(a,2.)+np.power(b,2.)) for a,b in zip(data['S21re ()'],data['S21im ()'])] )
    if i==0: #if on first measurement, create new measurement file and folder using titles extracted from measurement
        myfile = stlab.newfile(prefix,idstring,data.keys())
    stlab.savedict(myfile, data) #Save measured data to file.  Written as a block for spyview.
    #Create metafile for spyview at each measurement step
    stlab.metagen.fromarrays(myfile,data['Frequency (Hz)'],sgpow[0:i+1],xtitle='Frequency (Hz)',ytitle='SMBPower (dB)',colnames=data.keys())    
myfile.close()