-
Notifications
You must be signed in to change notification settings - Fork 4
/
kev_plot.py
42 lines (35 loc) · 983 Bytes
/
kev_plot.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
import numpy as np
import matplotlib.pyplot as plt
import sys
ME = 9.1093897e-28
CL = 2.99792458e10
HPL = 6.6260755e-27
LSUN = 3.827e33
KEV = 1000.*1.6021772e-12
fnam = 'spectrum.dat'
if len(sys.argv) == 2:
fnam = sys.argv[1]
data = np.loadtxt(fnam)
#nu = 10.**(data[:,0])*ME*CL**2/HPL
nu = data[:,0]
kev = HPL*nu/KEV
NVAR = 1
nbin = (len(data[0])-1)//NVAR
print(nbin)
nuLnu = np.zeros([nbin, len(nu)])
for n in range(nbin):
nuLnu[n,:] = data[:,NVAR*n+1]
ax = plt.subplot(1,1,1)
for n in range(nbin):
ax.step(kev, nuLnu[n], where='mid')
#ax.step(nu, nuLnu[n], where='mid')
#ax.step(nu, nuLnu.mean(axis=0), where='mid', color='k')
#ax.step(nu, nuLnu[-1], where='mid', color='k', linewidth=2)
ax.set_xscale('log'); ax.set_yscale('log')
ax.set_xlim([1.e-2, 1.e3])
#ax.axvline(1000.*ME*CL**2/HPL, color='k', linestyle='--')
nuLnu_max = nuLnu.max()
#ax.set_ylim([1.e28, 1.e37])
#ax.set_ylim([1.e-10*nuLnu_max, 1.e1*nuLnu_max])
#ax.set_xlim([1.e10, 1.e22])
plt.show()