-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcreate_mmcm_conf.py
49 lines (43 loc) · 1.2 KB
/
create_mmcm_conf.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
import ConfigParser
cp = ConfigParser.ConfigParser()
fn = "/home/gbt/etc/config/vegas.conf"
cp.read(fn)
#info = []
info = {}
modes = range(1,31)
for m in modes:
mstr = "MODE%s" % m
if cp.has_section(mstr):
bof = cp.get(mstr, "bof_file")
frq = cp.getfloat(mstr, "frequency")
#info.append((m, bof, frq))
if not info.has_key((bof, frq)):
info[(bof, frq)] = [m]
else:
info[(bof, frq)].append(m)
print info
# now create a cnf file for it
rn = "test" #"srbsr2-1"
fn2 = "%s-mmcm.conf" % rn
cp = ConfigParser.ConfigParser()
#cp.read(fn2)
sec = "MMCM"
cp.add_section(sec)
keys = sorted(info.keys())
for i, key in enumerate(keys):
#for i in range(len(info)):
bof, frq = key
modes = info[(bof, frq)]
opt = "mode[%d]" % i
cp.set(sec, opt, value = ",".join([str(x) for x in modes]))
opt = "boff[%d]" % i
cp.set(sec, opt, value = bof)
opt = "freq[%d]" % i
cp.set(sec, opt, value = frq)
opt = "adc0[%d]" % i
cp.set(sec, opt, value = 0)
opt = "adc1[%d]" % i
cp.set(sec, opt, value = 0)
# Writing our configuration file to 'example.cfg'
with open(fn2, 'wb') as configfile:
cp.write(configfile)