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 # Import the WinNet python plot-routine
5 # Note that you can also just append the path to your .bashrc
6 import sys
7 import os
8 sys.path.append('../../bin')
9 from class_files.winnet_class import winnet
10 
11 fig = plt.figure(figsize=(7,5))
12 ax = fig.gca()
13 
14 
15 # Find all run folders
16 folders = np.array(os.listdir('.'))
17 folder_mask = list(map(lambda x: 'trajectory_' in x, folders))
18 folders = np.array(folders)[folder_mask]
19 single_run = winnet(folders[0])
20 
21 # A large array that covers all possible nuclei
22 A_all = np.arange(260)
23 X_all = np.zeros(260)
24 # Loop over the folders
25 for f in folders:
26  # Plot every single run and in the end an integrated abundance
27  single_run = winnet(f)
28  single_run.read_finab()
29  A,X = single_run.get_final_A_X()
30  X_all[A] += X
31  ax.plot(A,X,color='lightgrey',zorder=1)
32 
33 # Plot the integrated mass fractions
34 ax.plot(A_all,X_all/len(folders),color="tab:orange",zorder=3,label="Integrated mass fractions")
35 # Make the legend and a "fake" plot to get the label
36 ax.plot(np.nan,np.nan,color='lightgrey',zorder=1,label="Individual mass fractions")
37 ax.legend(loc="upper right")
38 
39 # Set up the plot
40 ax.set_xlabel("Mass number")
41 ax.set_ylabel("Mass fraction")
42 ax.set_yscale("log")
43 ax.set_ylim(1e-6,1)
44 ax.set_xlim(49,245)
45 plt.savefig("massfractions_nsm_disc_wu.pdf",bbox_inches="tight")
46 plt.show()