Plot_me.py
Go to the documentation of this file.
1 # Author: M. Reichert
2 import matplotlib.pyplot as plt
3 import numpy as np
4 import os
5 
6 # Plot idea from https://wmap.gsfc.nasa.gov/universe/bb_tests_ele.html
7 
8 # Create Figure
9 fig = plt.figure(figsize=(5,5))
10 
11 # Find all run folders
12 folders = np.array(os.listdir('.'))
13 folder_mask = list(map(lambda x: 'bbn_' in x, folders))
14 folders = np.array(folders)[folder_mask]
15 
16 # Create and sort different baryon to photon ratios
17 etas = np.array(list(map(lambda x: float(x.replace('bbn_','')), folders)))
18 key = np.argsort(etas)
19 
20 folders = folders[key]
21 etas = etas[key]
22 
23 # Prepare lists to store the final abundances for each run
24 he_list = []
25 hydrogren_list = []
26 d_list = []
27 he3_list = []
28 li7_list = []
29 for f in folders:
30  path = f
31  # 1:A 2:Z 3:N 4:Yi 5:Xi
32  A,Z,N,Y,X = np.loadtxt(path+'/finab.dat',unpack=True)
33 
34  # Store the abundances
35  hydrogen = Y[(A==1) & (Z==1)][0]
36  he = Y[(A==4) & (Z==2)][0]
37  try:
38  d = Y[(A==2) & (Z==1)][0]
39  except:
40  d = 0
41 
42  he3 = Y[(A==3) & (Z==2)][0]
43  li7 = Y[(A==7) & (Z==3)][0]
44  try:
45  be7 = Y[(A==7) & (Z==4)][0]
46  except:
47  be7 = 0
48  hydrogren_list.append(hydrogen)
49  he_list.append(he/hydrogen)
50  d_list.append(d/hydrogen)
51  he3_list.append(he3/hydrogen)
52  li7_list.append((li7+be7)/hydrogen)
53 
54 
55 # Plot the Planck Satellite
56 plt.axvspan(5.96e-10,6.22e-10,alpha=0.5,color='k')
57 plt.text(5.5e-10,1e-6,'Planck Satellite',color='k',ha='center',va='top',rotation=90)
58 
59 # Plotting properties
60 alpha=0.3
61 
62 # Deuterium
63 # Cooke, R.~J., Pettini, M., \& Steidel, C.~C.\ 2018, \apj, 855, 102. doi:10.3847/1538-4357/aaab53
64 plt.axhspan( (2.527- 0.03) * 10**(-5), (2.527+ 0.03) * 10**(-5),color = 'tab:orange',alpha=alpha)
65 plt.text(1.58e-10,1e-3,'D',color='tab:orange',ha='center')
66 
67 # Helium 3
68 # Bania, T.~M., Rood, R.~T., \& Balser, D.~S.\ 2002, \nat, 415, 54. doi:10.1038/415054a
69 plt.axhspan((1.1-0.2)*10**(-5),(1.1+0.2)*10**(-5),color = 'tab:green',alpha=alpha)
70 plt.text(6e-12,3e-4,'He 3',color='tab:green',ha='center')
71 
72 
73 # Helium 4
74 # Aver, E., Olive, K. A., and Skillman, E. D. A new approach to systematic uncertainties and self-consistency in helium abundance determinations. JCAP 2010, 05 (2010), 003.
75 hydrogren_list = np.array(hydrogren_list)
76 ind = np.argmin(abs(etas - 6.275e-11))
77 h = hydrogren_list[ind]
78 plt.axhspan((0.2561-0.0108)/4./h,(0.2561+0.0108)/4./h,color = 'tab:blue',alpha=alpha)
79 plt.text(1.6e-8,0.24,'He 4',color='tab:blue',ha='center')
80 
81 # Lithium + Berillium
82 plt.axhspan((1.23-0.32)*1e-10,(1.23+0.68)*1e-10,color = 'tab:red',alpha=alpha)
83 plt.text(2.8e-11,5e-9,'Li 7 + Be 7',color='r',ha='center')
84 
85 # Plot the calculated final abundances
86 plt.plot(etas,he_list,lw=2)
87 plt.plot(etas,d_list,lw=2)
88 plt.plot(etas,he3_list,lw=2)
89 plt.plot(etas,li7_list,lw=2)
90 
91 # Set the scale and limits of the axes
92 plt.xscale('log')
93 plt.yscale('log')
94 plt.ylim(1e-11,1)
95 plt.xlim(1e-12,1e-7)
96 
97 # Set the labels
98 plt.xlabel('$\eta$')
99 plt.ylabel('Abundance relative to hydrogen')
100 
101 # Save and show the figure
102 plt.savefig('different_etas.pdf',bbox_inches='tight')
103 plt.show()