plot_hdf5.py
Go to the documentation of this file.
1 # Author: M. Reichert
2 import h5py
3 import sys
4 import numpy as np
5 import matplotlib.pyplot as plt
6 
7 # This script will only work in case the h5fc compiler was enabled in the makefile.
8 # Otherwise, no hdf5 will be generated.
9 
10 # Read the hdf5 file
11 try:
12  data = h5py.File("WinNet_data.h5","r")
13 except:
14  print("Enable h5fc compiler in the Makefile! No hdf5 file was found!")
15  sys.exit()
16 
17 # Read the time
18 time = data["snapshots/time"][:]
19 
20 # Read mass and proton number
21 A = data["snapshots/A"][:]
22 Z = data["snapshots/Z"][:]
23 
24 # Read abundance
25 Y = data["snapshots/Y"][:,:]
26 
27 # masks for some isotopes
28 ni56 = (A==56) & (Z==28)
29 th232 = (A==232) & (Z==90)
30 u236 = (A==236) & (Z==92)
31 eu151 = (A==151) & (Z==63)
32 eu153 = (A==153) & (Z==63)
33 
34 # Axis scaling
35 plt.yscale("log")
36 plt.xscale("log")
37 
38 # Plotting
39 plt.plot(time,151.0*Y[:,eu151],label="$^{151}$Eu")
40 plt.plot(time,153.0*Y[:,eu153],label="$^{153}$Eu")
41 plt.plot(time,232.0*Y[:,th232],label="$^{232}$Th")
42 plt.plot(time,236.0*Y[:,u236] ,label="$^{236}$U")
43 
44 # Make a legend
45 plt.legend()
46 
47 # Axis labels
48 plt.ylabel("Mass fraction")
49 plt.xlabel("Time [s]")
50 
51 # Axis limits
52 plt.ylim(1e-7,1e-2)
53 plt.xlim(1e-1,1e17)
54 
55 plt.show()