-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot_eq_table.py
183 lines (169 loc) · 9.09 KB
/
plot_eq_table.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
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
####################################################
# Plot the table created by gen_equilibrium_table.py
# Might not work with current table format?
####################################################
import matplotlib.pyplot as plt
from matplotlib.colors import LogNorm
from mpl_toolkits.mplot3d import axes3d
import h5py
import numpy as np
d = h5py.File("equilibrium_table_25_027-Zsun_small2.h5")
fields = {}
fields['HI'] = np.array(d['table']['HI']).reshape((25,25))
fields['HII'] = np.array(d['table']['HII']).reshape((25,25))
fields['HeI'] = np.array(d['table']['HeI']).reshape((25,25))
fields['HeII'] = np.array(d['table']['HeII']).reshape((25,25))
fields['HeIII'] = np.array(d['table']['HeIII']).reshape((25,25))
fields['HM'] = np.array(d['table']['HM']).reshape((25,25))
fields['de'] = np.array(d['table']['de']).reshape((25,25))
fields['H2I'] = np.array(d['table']['H2I']).reshape((25,25))
fields['H2II'] = np.array(d['table']['H2II']).reshape((25,25))
dens = np.array(d['indexer']['density'])
temp = np.array(d['indexer']['temperature'])
d.close()
for k,v in fields.items():
m = plt.pcolormesh(dens, temp, v, norm=LogNorm(1e-8,1))
plt.xscale('log')
plt.yscale('log')
plt.colorbar(m)
plt.savefig("eq_table_{}.png".format(k))
plt.clf()
HI_frac = [1.32923912e-07,1.36936510e-07,1.41092321e-07,1.45371544e-07,
1.49742477e-07,1.54202970e-07,1.58814151e-07,1.63495450e-07,
1.68235869e-07,1.73102651e-07,1.78033732e-07,1.82997784e-07,
1.88075852e-07,1.93194870e-07,1.98326876e-07,2.03581192e-07,
2.08826425e-07,2.14127120e-07,2.19474110e-07,2.24806065e-07,
2.30236409e-07,2.35612444e-07,2.41088722e-07,2.46513327e-07,
2.52007253e-07,2.57461143e-07,2.62968413e-07,2.68431762e-07,
2.73948382e-07,2.79400718e-07,2.84922817e-07,2.90342976e-07,
2.95866666e-07,3.01282741e-07,3.06754083e-07,3.12166397e-07,
3.17558412e-07,3.22962799e-07,3.28256640e-07,3.33644313e-07,
3.38924471e-07,3.44182641e-07,3.49444484e-07,3.54592841e-07,
3.59787664e-07,3.64911442e-07,3.69924696e-07,3.75018863e-07,
3.79996564e-07,3.84885572e-07,3.89827060e-07,3.94650592e-07,
3.99382265e-07,4.04162940e-07,4.08824268e-07,4.13366321e-07,
4.17977730e-07,4.22469031e-07,4.26839889e-07,4.31223930e-07,
4.35537753e-07,4.39730153e-07,4.43856033e-07,4.47985457e-07,
4.51992705e-07,4.55878182e-07,4.59770017e-07,4.63586133e-07,
4.67280093e-07,4.70852785e-07,4.74472636e-07,4.77970240e-07,
4.81346280e-07,4.84618565e-07,4.87915952e-07,4.91092110e-07,
4.94147896e-07,4.97089232e-07,5.00063040e-07,5.02917252e-07,
5.05652885e-07,5.08271006e-07,5.10888813e-07,5.13423076e-07,
5.15841148e-07,5.18144246e-07,5.20380414e-07,5.22599219e-07,
5.24704783e-07,5.26698459e-07,5.28581633e-07,5.30447465e-07,
5.32247931e-07,5.33940095e-07,5.35525457e-07,5.37005546e-07,
5.38486272e-07,5.39886964e-07,5.41184976e-07,5.42381922e-07]
HeI_frac = [2.90809534e-06,3.03586883e-06,3.17023784e-06,3.31100297e-06,
3.45772438e-06,3.61049990e-06,3.77059666e-06,3.93660585e-06,
4.10842732e-06,4.28742062e-06,4.47249454e-06,4.66315267e-06,
4.86099123e-06,5.06470137e-06,5.27384992e-06,5.49051741e-06,
5.71233160e-06,5.94055542e-06,6.17504850e-06,6.41477901e-06,
6.66180728e-06,6.91347137e-06,7.17252997e-06,7.43636341e-06,
7.70709922e-06,7.98289142e-06,8.26534272e-06,8.55285381e-06,
8.84702158e-06,9.14598502e-06,9.45182289e-06,9.76195076e-06,
1.00793564e-05,1.04010200e-05,1.07291552e-05,1.10622256e-05,
1.14006803e-05,1.17448932e-05,1.20933762e-05,1.24483421e-05,
1.28075597e-05,1.31718360e-05,1.35413278e-05,1.39149328e-05,
1.42938202e-05,1.46769967e-05,1.50641535e-05,1.54562302e-05,
1.58520446e-05,1.62516653e-05,1.66553617e-05,1.70625006e-05,
1.74730551e-05,1.78868691e-05,1.83037471e-05,1.87236371e-05,
1.91458017e-05,1.95705654e-05,1.99978569e-05,2.04266616e-05,
2.08572027e-05,2.12897036e-05,2.17234821e-05,2.21574602e-05,
2.25927514e-05,2.30292376e-05,2.34647969e-05,2.39002675e-05,
2.43361987e-05,2.47724439e-05,2.52053342e-05,2.56378951e-05,
2.60699723e-05,2.65009746e-05,2.69272660e-05,2.73522336e-05,
2.77757101e-05,2.81973693e-05,2.86122821e-05,2.90248414e-05,
2.94348741e-05,2.98422061e-05,3.02422100e-05,3.06375835e-05,
3.10294065e-05,3.14175087e-05,3.17996530e-05,3.21732762e-05,
3.25423787e-05,3.29068031e-05,3.32663896e-05,3.36162561e-05,
3.39585150e-05,3.42952467e-05,3.46262978e-05,3.49515399e-05,
3.52648267e-05,3.55704633e-05,3.58696620e-05,3.61624029e-05]
rho = [3.10952733e-28,2.72921384e-28,2.41358406e-28,2.14839025e-28,
1.92325254e-28,1.73042197e-28,1.56399195e-28,1.41937889e-28,
1.29297070e-28,1.18188252e-28,1.08378333e-28,9.96770313e-29,
9.19276121e-29,8.49999348e-29,7.87851645e-29,7.31916937e-29,
6.81419628e-29,6.35699535e-29,5.94191945e-29,5.56411605e-29,
5.21939783e-29,4.90413720e-29,4.61517982e-29,4.34977336e-29,
4.10550832e-29,3.88026877e-29,3.67219112e-29,3.47962935e-29,
3.30112574e-29,3.13538602e-29,2.98125818e-29,2.83771446e-29,
2.70383586e-29,2.57879883e-29,2.46186385e-29,2.35236546e-29,
2.24970374e-29,2.15333680e-29,2.06277431e-29,1.97757179e-29,
1.89732566e-29,1.82166888e-29,1.75026710e-29,1.68281529e-29,
1.61903474e-29,1.55867045e-29,1.50148876e-29,1.44727530e-29,
1.39583312e-29,1.34698102e-29,1.30055214e-29,1.25639260e-29,
1.21436033e-29,1.17432402e-29,1.13616216e-29,1.09976220e-29,
1.06501976e-29,1.03183798e-29,1.00012682e-29,9.69802567e-30,
9.40787270e-30,9.13008299e-30,8.86397912e-30,8.60892873e-30,
8.36434100e-30,8.12966348e-30,7.90437914e-30,7.68800374e-30,
7.48008339e-30,7.28019231e-30,7.08793080e-30,6.90292337e-30,
6.72481702e-30,6.55327964e-30,6.38799860e-30,6.22867938e-30,
6.07504435e-30,5.92683162e-30,5.78379402e-30,5.64569810e-30,
5.51232326e-30,5.38346089e-30,5.25891364e-30,5.13849467e-30,
5.02202704e-30,4.90934303e-30,4.80028362e-30,4.69469796e-30,
4.59244286e-30,4.49338233e-30,4.39738717e-30,4.30433455e-30,
4.21410767e-30,4.12659538e-30,4.04169188e-30,3.95929642e-30,
3.87931299e-30,3.80165008e-30,3.72622043e-30,3.65294078e-30]
T = [1287100.83526448,1255079.51780306,1223964.75748198,1193769.6541266 ,
1164509.89571278,1136198.074985 ,1108840.94976927,1082438.47585516,
1056983.87033163,1032464.23453451,1008861.44134012, 986153.10626994,
964313.53673121, 943314.60204073, 923126.49746247, 903718.3942591 ,
885058.97874453, 867116.88926729, 849861.06280304, 833261.0036277 ,
817286.98619354, 801910.20336856, 787102.86995516, 772838.29008166,
759090.89577657, 745836.26285413, 733051.10918829, 720713.27953977,
708801.72032157, 697296.4470325 , 686178.50654175, 675429.9359562 ,
665033.71943211, 654973.74399159, 645234.75515964, 635802.31304137,
626662.74930109, 617803.12537943, 609211.19218508, 600875.35141957,
592784.61863206, 584928.58805359, 577297.39922429, 569881.70539877,
562672.64369521, 555661.80693801, 548841.21713396, 542203.3005144 ,
535740.86407176, 529447.0735165 , 523315.43257983, 517339.76358808,
511514.18923618, 505833.11548957, 500291.2155467 , 494883.41479685,
489604.87671125, 484450.98960859, 479417.35423912, 474499.77213476,
469694.23467569, 464996.91282696, 460404.14750141, 455912.44050823,
451518.44604863, 447218.96272328, 443010.9260178 , 438891.40123539,
434857.57684746, 430906.75823513, 427036.36179642, 423243.90939548,
419527.02313203, 415883.4204104 , 412310.90928922, 408807.38409403,
405370.82127602, 401999.27550177, 398690.87595936, 395443.82286745,
392256.38417501, 389126.89243972, 386053.74187434, 383035.38555087,
380070.33275286, 377157.14646713, 374294.44100656, 371480.87975618,
368715.17303535, 365996.07606922, 363322.38706318, 360692.94537428,
358106.62977414, 355562.35679817, 353059.07917609, 350595.78433934,
348171.49300098, 345785.2578041 , 343436.16203503, 341123.31839765]
# HI
m = plt.pcolormesh(dens, temp, fields['HI'], norm=LogNorm(1e-8,1))
plt.scatter(rho, T, c=HI_frac, norm=LogNorm(1e-8,1), edgecolor='k')
plt.xscale('log')
plt.yscale('log')
plt.xlabel(r'$\mathrm{\rho\ (g/cm^3)}$')
plt.ylabel('T (K)')
c = plt.colorbar(m)
c.set_label('HI frac')
plt.show()
dd, tt = np.meshgrid(np.log10(dens), np.log10(temp))
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.plot_wireframe(dd, tt, np.log10(fields['HI']),
alpha=0.5, color='gray')
ax.plot(np.log10(rho), np.log10(T), np.log10(HI_frac))
plt.xlabel(r'$\mathrm{\log\ \rho/(g/cm^3)}$')
plt.ylabel(r'$\mathrm{\log\ T/K}$')
ax.set_zlabel('log HI frac')
plt.show()
# HeI
m = plt.pcolormesh(dens, temp, fields['HeI'], norm=LogNorm(1e-8,1))
plt.scatter(rho, T, c=HeI_frac, norm=LogNorm(1e-8,1), edgecolor='k')
plt.xscale('log')
plt.yscale('log')
plt.xlabel(r'$\mathrm{\rho\ (g/cm^3)}$')
plt.ylabel('T (K)')
c = plt.colorbar(m)
c.set_label('HeI frac')
plt.show()
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.plot_wireframe(dd, tt, np.log10(fields['HeI']),
alpha=0.5, color='gray')
ax.plot(np.log10(rho), np.log10(T), np.log10(HeI_frac))
plt.xlabel(r'$\mathrm{\log\ \rho/(g/cm^3)}$')
plt.ylabel(r'$\mathrm{\log\ T/K}$')
ax.set_zlabel('log HeI frac')
plt.show()