-
Notifications
You must be signed in to change notification settings - Fork 0
/
genplot.py
71 lines (66 loc) · 1.92 KB
/
genplot.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
69
70
71
import matplotlib.pyplot as plt
import sys
def process(fileName):
# read in data from file
history = []
f = open(fileName)
i = 0
curGen = []
for line in f:
data = map(float, line.split())
curGen.append(data)
i += 1
if i == 100:
history.append(curGen)
curGen = []
i = 0
# find averages
averages = [[] for x in range(9)]
for generation in history:
local_sum = [0]*9
# find local sum
for model in generation:
for param in range(9):
local_sum[param] += model[param]
# divide by number of members in population to get average
for param in range(9):
averages[param].append(local_sum[param]/100.0)
# plot the average chi values over generations
plt.figure(1)
# chis
"""
plt.subplot(221)
plt.plot(averages[8])
plt.xlabel('Generation')
plt.ylabel('Average Chi')
plt.title('Chi-Squared (not reduced)')
plt.subplot(223)
plt.plot(averages[6])
plt.xlabel('Generation')
plt.ylabel('Average Chi')
plt.title('SED')
plt.subplot(224)
plt.plot(averages[7])
plt.xlabel('Generation')
plt.ylabel('Average Chi')
plt.title('Visibilities')
"""
# DOES NOT WORK FOR NON-REDUCED
#plt.ylim(-10,100)
labels = ['Inner Radius', 'Outer Radius', 'Grain Size', 'Disk Mass', 'Surface Density', 'Beta']
for i in range(6):
plt.subplot(321+i)
plt.plot(averages[i])
plt.xlabel('Generation')
plt.ylabel('Average ' + labels[i])
plt.title(labels[i])
"""
plt.subplots_adjust(left=None, bottom=None, right=None, top=None,
wspace=None, hspace=None)
"""
# DOES THIS OVERWRITE? IF NO, HANDLE DIFFERENTLY
#plt.savefig('genetic/' + plotFile)
plt.tight_layout()
plt.show()
file_name = sys.argv[1]
process(file_name)