-
Notifications
You must be signed in to change notification settings - Fork 5
/
readcsv_gs.py
68 lines (56 loc) · 2.23 KB
/
readcsv_gs.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
import csv
import numpy as np
import pylab
import webbrowser
f = open("CADRE_gs.csv", "rb")
reader = csv.DictReader(f, skipinitialspace=True)
X, Y, Z = [], [], []
for row in reader:
data = [row["pt" + str(i) + ".Data[0][1499]"] for i in xrange(6)]
sumdata = sum([float(i) for i in data if i])
c1 = [row["Constraint ( pt" + str(i) + ".ConCh<=0 )"] for i in xrange(6)]
c2 = [row["Constraint ( pt" + str(i) + ".ConDs<=0 )"] for i in xrange(6)]
c3 = [row["Constraint ( pt" + str(i) + ".ConS0<=0 )"] for i in xrange(6)]
c4 = [row["Constraint ( pt" + str(i) + ".ConS1<=0 )"] for i in xrange(6)]
c5 = [row["Constraint ( pt" + str(i) + ".SOC[0][0]=pt" + str(i) + ".SOC[0][-1] )"]
for i in xrange(6)]
# c1_f = np.all([float(i) < 0 for i in c1 if i])
# c2_f = np.all([float(i) < 0 for i in c2 if i])
# c3_f = np.all([float(i) < 0 for i in c3 if i])
# c4_f = np.all([float(i) < 0 for i in c4 if i])
# c5_f = np.all([float(i) < 0 for i in c4 if i])
c1_f = sum([float(i) for i in c1 if i])
c2_f = sum([float(i) for i in c2 if i])
c3_f = sum([float(i) for i in c3 if i])
c4_f = sum([float(i) for i in c4 if i])
c5_f = sum([float(i) for i in c5 if i])
feasible = [c1_f, c2_f, c3_f, c4_f, c5_f]
X.append(sumdata), Y.append(sum(feasible)), Z.append(feasible)
# print sumdata, sum(feasible), max(feasible) #,[ '%.1f' % i for i in
# feasible]
print sumdata, row["pt0.lat[0]"], row["pt0.lon[0]"], row["Elevation.alt"]
url = "https://maps.google.com/maps?q=%s+%s" % (
row["pt0.lat[0]"], row["pt0.lon[0]"])
webbrowser.open(url)
Z = np.array(Z)
if not len(Z):
print "no data yet..."
quit()
pylab.subplot(311)
pylab.title("total data")
pylab.plot(X, 'b')
pylab.plot([0, len(X)], [3e4, 3e4], 'k--', marker="o")
pylab.subplot(312)
pylab.title("Sum of Constraints")
pylab.plot([0, len(Y)], [0, 0], 'k--', marker="o")
pylab.plot(Y, 'k')
pylab.subplot(313)
pylab.title("Max of Constraints")
pylab.plot([0, len(Z)], [0, 0], 'k--')
pylab.plot(Z[:, 0], marker="o", label="c1")
pylab.plot(Z[:, 1], marker="o", label="c2")
pylab.plot(Z[:, 2], marker="o", label="c3")
pylab.plot(Z[:, 3], marker="o", label="c4")
pylab.plot(Z[:, 4], marker="o", label="c5")
pylab.legend(loc="best")
pylab.show()