Plot_me.py
Go to the documentation of this file.
1 # Author: M. Reichert
2 import numpy as np
3 import matplotlib.pyplot as plt
4 
5 
6 # We note that small differences between the result here and
7 # in Cescutti et al. 2018 can originate from different reaction
8 # rate input.
9 
10 
11 def sum_over(A,Y):
12  """
13  Function to sum up mass fractions or abundances over equal A.
14  """
15  A = A.astype(int)
16  max_A = max(A)
17  # second_dimension = len(Y[0,:])
18  Y_new = np.zeros([max_A+1,])
19  for i in range(len(A)):
20  Y_new[int(A[i])] += Y[i]
21  return np.array(range(max_A+1)),Y_new
22 
23 
24 # Get the result of WinNet and plot it
25 A,Y,X = np.loadtxt('trajectory_C13pocket/finabsum.dat',unpack=True)
26 plt.plot(A,X,label="WinNet")
27 
28 # Read and plot the result from Cescutti et al. 2018
29 A,Yfinal,Yseed = np.loadtxt('final_abundances_C13pocket.out',unpack=True,usecols=[3,4,6])
30 Xfinal = Yfinal*A
31 Asum,Xsum = sum_over(A,Xfinal)
32 plt.plot(Asum,Xsum,label="Cescutti et al. 2018")
33 
34 # Plot the initial mass fractions
35 Xseed = Yseed*A
36 Asum,Xsum = sum_over(A,Xseed)
37 plt.plot(Asum,Xsum,label="Initial mass fractions")
38 
39 # Also plot the result of the thermal pulse
40 A,Y,X = np.loadtxt('trajectory_TP/finabsum.dat',unpack=True)
41 plt.plot(A,X,label="WinNet (after thermal pulse)")
42 
43 # Give labels to the plot
44 plt.ylabel("Mass fractions")
45 plt.xlabel("Mass number")
46 
47 # Make it more beautiful
48 plt.yscale("log")
49 plt.ylim(1e-11,1)
50 plt.xlim(0,215)
51 plt.legend()
52 
53 # Save and show the plot
54 plt.savefig("main_s_process.pdf",bbox_inches="tight")
55 plt.show()
Plot_me.sum_over
def sum_over(A, Y)
Definition: Plot_me.py:11