-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot_abundance_vs_time.py
67 lines (55 loc) · 1.69 KB
/
plot_abundance_vs_time.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
import math
import matplotlib.pyplot as plt
filename1 = 'new123_top_only.dat'
filename2 = 'new123_bottom_only.dat'
h3_abundance_list = []
heh_abundance_list = []
temp_list = []
time_list = []
i = 0
with open(filename1, 'r') as f:
next(f)
next(f)
for line in f:
field = line.split()
h3_abundance = field[4].strip()
h3_abundance_list.append(math.log(float(h3_abundance)))
with open(filename2, 'r') as f:
next(f)
next(f)
for line in f:
fields = line.split()
temp = fields[0].strip()
temp_exp = int(temp[-3:])
time = fields[1].strip()
time_exp = int(time[-3:])
heh_abundance = fields[10].strip()
temp_list.append(float(temp_exp))
time_list.append(float(time_exp))
heh_abundance_list.append(math.log(float(heh_abundance)))
print(h3_abundance_list)
print(heh_abundance_list)
print(temp_list)
fig, axs = plt.subplots(2,2)
fig.set_figheight(12)
fig.set_figwidth(10)
axs[0,0].plot(temp_list, heh_abundance_list)
axs[0,0].set_title('HeH abundance vs Temp(T9)')
axs[0,0].set_xlabel('temp_exp')
axs[0,0].set_ylabel('ln(HeH abundance)')
axs[0,0].invert_xaxis()
axs[0,1].plot(temp_list, h3_abundance_list)
axs[0,1].set_title('H3 abundance vs Temp(T9)')
axs[0,1].set_xlabel('temp_exp')
axs[0,1].set_ylabel('ln(H3 abundance)')
axs[0,1].invert_xaxis()
axs[1,0].plot(time_list, heh_abundance_list)
axs[1,0].set_title('HeH abundance vs Time')
axs[1,0].set_xlabel('time_exp')
axs[1,0].set_ylabel('ln(HeH abundance)')
axs[1,1].plot(time_list, h3_abundance_list)
axs[1,1].set_title('H3 abundance vs Time')
axs[1,1].set_xlabel('time_exp')
axs[1,1].set_ylabel('ln(H3 abundance)')
fig.subplots_adjust(hspace=.5)
plt.show()