graphs.py
3.01 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
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
import matplotlib.pyplot as plt
import sys
op = ''
if(int(sys.argv[1]) == 1):
op = 'WS'
elif(int(sys.argv[1]) == 2):
op = 'WR'
elif(int(sys.argv[1]) == 3):
op = 'SR'
Colors = {'Ec':'darkred', 'Pb':'cornflowerblue',
'Ct':'green', 'Sb':'purple',
'Qr':'darkgoldenrod','Rp':'orange','No':'gray'}
fig = plt.figure(figsize=(8,10))
ax = plt.gca()
ax.set_facecolor('lightgray')
#plt.plot([-25000, -25001], [165000, 165001], lw=15, c=Colors['Ec'], label='Ec')
#plt.plot([-25000, -25001], [165000, 165001], lw=15, c=Colors['Pb'], label='Pb')
#plt.plot([-25000, -25001], [165000, 165001], lw=15, c=Colors['Ct'], label='Ct')
#plt.plot([-25000, -25001], [165000, 165001], lw=15, c=Colors['Sb'], label='Sb')
#plt.plot([-25000, -25001], [165000, 165001], lw=15, c=Colors['Qr'], label='Qr')
#plt.plot([-25000, -25001], [165000, 165001], lw=15, c=Colors['Rp'], label='Rp')
#plt.plot([-25000, -25001], [165000, 165001], lw=17, c='lightgray')
#plt.legend()
Range = range(2020,2070)
fy= open("Paredes"+op+"/GraphInputFileW.txt", "r")
lines=fy.readlines()
ProdMAD = {'Ct':[], 'Ec':[], 'Pb':[], 'Qr':[], 'Sb':[], 'Rp':[]}
for year in range(2020, 2070):
sumE = 0
sumC = 0
sumP = 0
sumQ = 0
sumS = 0
sumR = 0
for line in lines:
a = line.split(',')
if(int(a[1]) == year):
if(a[2] == 'Ec'):
sumE += int(a[3][:-1])
elif(a[2] == 'Ct'):
sumC += int(a[3][:-1])
elif(a[2] == 'Pb'):
sumP += int(a[3][:-1])
elif(a[2] == 'Qr'):
sumQ += int(a[3][:-1])
elif(a[2] == 'Sb'):
sumS += int(a[3][:-1])
elif(a[2] == 'Rp'):
sumR += int(a[3][:-1])
ProdMAD['Ec'].append(sumE)
ProdMAD['Ct'].append(sumC)
ProdMAD['Pb'].append(sumP)
ProdMAD['Qr'].append(sumQ)
ProdMAD['Sb'].append(sumS)
ProdMAD['Rp'].append(sumR)
plt.stackplot(Range, ProdMAD['Ct'], ProdMAD['Ec'], ProdMAD['Pb'], ProdMAD['Qr'], ProdMAD['Sb'], ProdMAD['Rp'],
labels = ['Ct', 'Ec', 'Pb', 'Qr', 'Sb','Rp'],
colors= [Colors['Ct'],Colors['Ec'],Colors['Pb'],Colors['Qr'],Colors['Sb'], Colors['Rp']] )
plt.grid()
plt.legend(loc='upper left')
plt.xlabel('Year')
plt.ylabel('WoodYield')
#plt.show()
plt.savefig('Paredes'+op+'/Map/GraphWood',dpi=100)
fs= open("Paredes"+op+"/GraphInputFileS.txt", "r")
lines=fs.readlines()
soils = []
for year in range(2020, 2070):
soilSum = 0
for line in lines:
a = line.split(',')
if(int(a[0]) == year):
soilSum += float(a[1][:-1])
soils.append(soilSum)
fig7 = plt.figure(figsize=(10,4))
plt.plot(Range, soils, '-o', c="darkgreen")
plt.xlabel('Year')
plt.ylabel('SoilLoss')
plt.savefig('Paredes'+op+'/Map/GraphSoilLoss',dpi=100)
fr= open("Paredes"+op+"/GraphInputFileR.txt", "r")
lines=fr.readlines()
rpercentile = []
for year in range(2020, 2070):
riskSum = 0
for line in lines:
a = line.split(',')
if(int(a[0]) == year):
riskSum += float(a[1][:-1])
rpercentile.append(riskSum)
fig8 = plt.figure(figsize=(10,4))
plt.plot(Range, rpercentile, '-o', c="red")
plt.xlabel('Year')
plt.ylabel('RiskPercentiles')
plt.savefig('Paredes'+op+'/Map/GraphRiskPercentile',dpi=100)