-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathitExtractSymbol.py
More file actions
executable file
·32 lines (28 loc) · 883 Bytes
/
itExtractSymbol.py
File metadata and controls
executable file
·32 lines (28 loc) · 883 Bytes
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
#!/usr/bin/python
from itpp import itload
import sys
Args = sys.argv
f = open("/home/gilbert/Dissertation/libgjm/modulations/OptPsm6.inc","w")
if len(Args) == 2:
try:
Data = itload(Args[1])
Symbol = Data["OptSymbols"]
except:
print "Could not find OptSymbols variable in results file"
exit()
M = len(Symbol)
print M
f.write("ivec labelling("+ str(M) + ");")
f.write("for (int i=0;i<" + str(M) + ";i++) labelling(" + str(M-1) + "-i) = i;\n")
f.write("cvec symbols = \"")
for s in Symbol:
x = s.item(0)
s = "{0:.15f}".format(x)
s = s.replace('j','i') + " "
#s = str(x).replace('(','').replace(')','').replace('j','i') + " "
f.write(s)
else:
print "Syntax: " + Args[0] + " <filename>"
f.write("\";\n")
f.write("Modulator_2D mod(symbols, labelling);\nreturn mod;")
f.close()