-
Notifications
You must be signed in to change notification settings - Fork 1
/
VNAGsweep.py
173 lines (138 loc) · 4.75 KB
/
VNAGsweep.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
'''
Generic Sweep script
(currently setup for no more than 3 dims)
20/10/2015
- B
'''
# import numpy as np
from time import time, sleep
from parsers import copy_file
from ramp_mod import ramp
from DataStorer import DataStoreSP # , DataStore2Vec, DataStore11Vec
# Drivers
from dummydriver import instrument as dummy
from keithley2000 import instrument as key2000
# from AnritzuSig import instrument as AnSigGen
from SRsim import instrument as sim900c
from Sim928 import instrument as sim928c
from RSZNB20 import instrument as ZNB20
# from Yoko import instrument as yoko
import gc # Garbage memory collection
import os
''' DC and VNA (1KHz IF) -20dB at output sweep S1A1 '''
thisfile = __file__
filen_0 = '2005VNA'
folder = 'data_26Sep\\'
folder = folder + filen_0 + '\\' # in one new folder
if not os.path.exists(folder):
os.makedirs(folder)
sim900 = sim900c('GPIB0::12::INSTR')
# sim900 = dummy('GPIB0::12::INSTR')
vm = key2000('GPIB0::29::INSTR')
VNA = ZNB20('TCPIP::129.16.115.137::INSTR', name='ZNB20',
start=3.5e9, stop=8.5e9, pt=1201, BW=1000, power=0,
sstep=20e-3, stime=0.0, copy_setup=False)
# Sweep equipment setup
nothing = dummy(name='nothing', start=0, stop=1, pt=1, sstep=20e-3, stime=0.0)
vBias = sim928c(sim900, name='V 1Mohm', sloti=4,
start=0.0, stop=0.0, pt=1,
sstep=0.120, stime=0.020)
vMag = sim928c(sim900, name='Magnet V R=22.19KOhm', sloti=3,
start=-4.0, stop=4.0, pt=401,
sstep=0.03, stime=0.020)
# pFlux = AnSigGen('GPIB0::17::INSTR', name='FluxPump',
# start=2.03, stop=0.03, pt=101,
# sstep=10, stime=0)
dim_1 = nothing
dim_1.defval = 0.0
dim_1.UD = False
dim_2 = vMag
dim_2.defval = 0.0
dim_3 = vBias
dim_3.defval = 0.0
def sweep_dim_1(obj, value):
ramp(obj, obj.sweep_par, value, obj.sstep, obj.stime)
def sweep_dim_2(obj, value):
ramp(obj, obj.sweep_par, value, obj.sstep, obj.stime)
def sweep_dim_3(obj, value):
ramp(obj, obj.sweep_par, value, obj.sstep, obj.stime)
# This describes how data is saved
DS = DataStoreSP(folder, filen_0, dim_1, dim_2, dim_3, 'Vx1k')
DS.ask_overwrite()
copy_file(thisfile, filen_0, folder)
VNA.prepare_data_save(folder, filen_0, dim_1, dim_2, dim_3)
def record_data(kk, jj, ii, back):
'''describe how data is to be stored
This function is called with each change in ii,jj,kk
content: what to measure each time
'''
VNA.init_sweep()
vdata = vm.get_val() # aquire voltage data point
sleep(VNA.sweeptime)
VNA.wait()
vnadata = VNA.get_data() # take VNA sweep
if back is True:
return DS.record_data2(vdata, kk, jj, ii)
DS.record_data(vdata, kk, jj, ii)
VNA.record_data(vnadata, kk, jj, ii)
def save_recorded():
'''
Which functions to call to save the recored data
'''
DS.save_data() # save Volt data
VNA.save_data() # save VNA data
# go to default value and activate output
sweep_dim_1(dim_1, dim_1.defval)
sweep_dim_2(dim_2, dim_2.defval)
sweep_dim_3(dim_3, dim_3.defval)
dim_1.output(1)
dim_2.output(1)
dim_3.output(1)
print 'Executing sweep'
texp = (2.0 * dim_3.pt * dim_2.pt * dim_1.pt * (0.032) / 60.0)
# print 'req time (min):'+str(2.0*dim_3.pt*dim_2.pt*dim_1.pt*0.032/60)
print 'req time (min):' + str(texp)
t0 = time()
try:
for kk in range(dim_3.pt):
sweep_dim_3(dim_3, dim_3.lin[kk])
sweep_dim_2(dim_2, dim_2.start)
for jj in range(dim_2.pt):
sweep_dim_2(dim_2, dim_2.lin[jj])
sweep_dim_1(dim_1, dim_1.start)
sleep(0.2)
print 'Up Trace'
for ii in range(dim_1.pt):
sweep_dim_1(dim_1, dim_1.lin[ii])
record_data(kk, jj, ii, False)
# print 'sweep+record ', time()-txx
if dim_1.UD is True:
sweep_dim_1(dim_1, dim_1.stop)
sleep(0.1)
print 'Down Trace'
for ii2 in range((dim_1.pt - 1), -1, -1):
sweep_dim_1(dim_1, dim_1.lin[ii2])
record_data(kk, jj, ii2, True)
runt = time() - t0 # time run so far
avgtime = runt / ((kk + 1) * (jj + 1) * (ii + 1)) # per point
t_rem = avgtime * dim_3.pt * dim_2.pt * dim_1.pt - runt # time left
print 'req time (h):' + str(t_rem / 3600) + ' pt: ' + str(avgtime)
save_recorded()
print 'Measurement Finished'
finally:
print 'Time used min:' + str((time() - t0) / 60)
print 'Sweep back to default'
sweep_dim_1(dim_1, dim_1.defval)
sleep(1)
sweep_dim_2(dim_2, dim_2.defval)
sleep(1)
sweep_dim_3(dim_3, dim_3.defval)
sleep(1)
dim_1.output(0)
sleep(1)
dim_2.output(0)
sleep(1)
dim_3.output(0)
sim900._dconn()
gc.collect()
print 'done'