-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
70 lines (47 loc) · 1.54 KB
/
main.py
File metadata and controls
70 lines (47 loc) · 1.54 KB
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
#!/usr/bin/env python
import matplotlib.pyplot as plt
import sys, getopt
import numpy as np
from LED import LED
from plotter import Plotter
def parse(infilePath, outfilePath, scale):
with open(infilePath) as infile:
lines = infile.readlines()
w, h = lines[1].strip().split("\t")
lls = lines[3:len(lines)]
leds = []
for ll in lls:
x, y, rho, phi = ll.strip().split("\t")
leds.append(LED(x, y, rho, phi))
plotter = Plotter(leds, float(w), float(h))
colors = np.random.rand(181)
plotter.update_plot(colors)
#plotter.start()
#plotter.plot_cartesian(leds, [], float(w), float(h))
#plotter.plot_polar(leds, [], float(w), float(h))
return
def main(argv):
inputfile = ''
outputfile = ''
scale = 1000
try:
opts, args = getopt.getopt(argv,"hi:o:s:",["ifile=","ofile=","scale="])
except getopt.GetoptError:
print('test.py -i <inputfile> -o <outputfile> -s <scale>')
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
print('test.py -i <inputfile> -o <outputfile> -s <scale>')
sys.exit()
elif opt in ("-i", "--ifile"):
inputfile = arg
elif opt in ("-o", "--ofile"):
outputfile = arg
elif opt in ("-s", "--scale"): # horizontal scale
scale = float(arg)
print('Input file is :', inputfile)
print('Output file is :', outputfile)
print('Scale is :', scale)
parse(inputfile, outputfile, scale)
if __name__ == "__main__":
main(sys.argv[1:])