Commit 4448ea24ac7838ad3cb055ce3b6832aafd4eda5a
1 parent
d33c0beb
Exists in
master
Time distribution
add a comparison between different precision on zlim Add a test on generation and charge in all scripts
Showing
5 changed files
with
55 additions
and
30 deletions
Show diff stats
Angle_distribution.py
@@ -48,7 +48,7 @@ ind = 0 | @@ -48,7 +48,7 @@ ind = 0 | ||
48 | for fileId in argv[2:]: | 48 | for fileId in argv[2:]: |
49 | energy,dirx,diry,dirz = loadtxt(fileName+fileId+"/Results_momentum",unpack=True,usecols=[0,1,2,3]) | 49 | energy,dirx,diry,dirz = loadtxt(fileName+fileId+"/Results_momentum",unpack=True,usecols=[0,1,2,3]) |
50 | posx,posy,posz = loadtxt(fileName+fileId+"/Results_position",unpack=True,usecols=[1,2,3]) | 50 | posx,posy,posz = loadtxt(fileName+fileId+"/Results_position",unpack=True,usecols=[1,2,3]) |
51 | - weight,gen=loadtxt(fileName+fileId+"/Results_extra",unpack=True,usecols=[2,3]) | 51 | + charge,weight,gen=loadtxt(fileName+fileId+"/Results_extra",unpack=True,usecols=[0,2,3]) |
52 | 52 | ||
53 | hyp=sqrt(posx**2+posy**2+posz**2) | 53 | hyp=sqrt(posx**2+posy**2+posz**2) |
54 | posx=posx/hyp | 54 | posx=posx/hyp |
@@ -59,7 +59,7 @@ for fileId in argv[2:]: | @@ -59,7 +59,7 @@ for fileId in argv[2:]: | ||
59 | diry=diry/hyp | 59 | diry=diry/hyp |
60 | dirz=dirz/hyp | 60 | dirz=dirz/hyp |
61 | costheta=dirx*posx+diry*posy+dirz*posz | 61 | costheta=dirx*posx+diry*posy+dirz*posz |
62 | - cond=(costheta<=1)&(costheta>=-1)&(gen==2) | 62 | + cond=(costheta<=1)&(costheta>=-1)&(charge==0) |
63 | theta = arccos(costheta[cond])*degre | 63 | theta = arccos(costheta[cond])*degre |
64 | weight= weight[cond] | 64 | weight= weight[cond] |
65 | energy= energy[cond] | 65 | energy= energy[cond] |
Arrival_direction.py
Energy_distribution.py
@@ -39,7 +39,11 @@ Emin = min(Edata) | @@ -39,7 +39,11 @@ Emin = min(Edata) | ||
39 | ind = 0 | 39 | ind = 0 |
40 | for fileId in argv[2:]: | 40 | for fileId in argv[2:]: |
41 | energy= np.loadtxt(fileName+fileId+"/Results_momentum",unpack=True,usecols=[0]) | 41 | energy= np.loadtxt(fileName+fileId+"/Results_momentum",unpack=True,usecols=[0]) |
42 | - weight= np.loadtxt(fileName+fileId+"/Results_extra",unpack=True,usecols=[2]) | 42 | + charge,weight=np.loadtxt(fileName+fileId+"/Results_extra",unpack=True,usecols=[0,2]) |
43 | + | ||
44 | + cond= (charge==0) | ||
45 | + energy=energy[cond] | ||
46 | + weight=weight[cond] | ||
43 | print "data shape:", np.shape(energy) | 47 | print "data shape:", np.shape(energy) |
44 | 48 | ||
45 | Edata =np.log10(energy) | 49 | Edata =np.log10(energy) |
@@ -54,14 +58,13 @@ for fileId in argv[2:]: | @@ -54,14 +58,13 @@ for fileId in argv[2:]: | ||
54 | label="$J_\gamma$ $10^{-%.0f"%float(fileId)+"}$Gauss") | 58 | label="$J_\gamma$ $10^{-%.0f"%float(fileId)+"}$Gauss") |
55 | elif argv[1] == "EBL": | 59 | elif argv[1] == "EBL": |
56 | ax.plot(enercenter,flux[:]/max(flux),"."+color[ind],label=Model[int(fileId)-1]) | 60 | ax.plot(enercenter,flux[:]/max(flux),"."+color[ind],label=Model[int(fileId)-1]) |
57 | - | ||
58 | - # Results from Elmag | ||
59 | - Elmag=fileName+fileId+"/spec_diff_test" | ||
60 | - if os.path.isfile(Elmag): | ||
61 | - energy,fluxGamma,fluxLepton = np.loadtxt(Elmag,unpack=True,usecols=[0,1,2]) | ||
62 | - energy=energy*10**(-9) | ||
63 | - flux=fluxGamma+fluxLepton | ||
64 | - ax.plot(energy,flux/max(flux),"-"+color[ind],label="Elmag - "+Model[int(fileId)-1]) | 61 | + # Results from Elmag |
62 | + Elmag=fileName+fileId+"/spec_diff_test" | ||
63 | + if os.path.isfile(Elmag): | ||
64 | + energy,fluxGamma,fluxLepton = np.loadtxt(Elmag,unpack=True,usecols=[0,1,2]) | ||
65 | + energy=energy*10**(-9) | ||
66 | + flux=fluxGamma+fluxLepton | ||
67 | + ax.plot(energy,flux/max(flux),"-"+color[ind],label="Elmag - "+Model[int(fileId)-1]) | ||
65 | 68 | ||
66 | ind=ind+1 | 69 | ind=ind+1 |
67 | 70 |
Generation_distribution.py
@@ -10,7 +10,7 @@ if len(argv)<2: | @@ -10,7 +10,7 @@ if len(argv)<2: | ||
10 | 10 | ||
11 | # figure: energy distribution | 11 | # figure: energy distribution |
12 | #============================= | 12 | #============================= |
13 | -nbBins = 8 | 13 | +nbBins = 7 |
14 | color=['b','g','r','c','m','y'] | 14 | color=['b','g','r','c','m','y'] |
15 | 15 | ||
16 | fig = plt.figure() | 16 | fig = plt.figure() |
@@ -20,7 +20,7 @@ ind = 0 | @@ -20,7 +20,7 @@ ind = 0 | ||
20 | for fileId in argv[1:]: | 20 | for fileId in argv[1:]: |
21 | weight,nbGen=np.loadtxt("Results_EGMF"+fileId+"/Results_extra",unpack=True,usecols=[2,3]) | 21 | weight,nbGen=np.loadtxt("Results_EGMF"+fileId+"/Results_extra",unpack=True,usecols=[2,3]) |
22 | 22 | ||
23 | - plt.hist(nbGen,nbBins, weights=weight,range=[1,9],log=1,facecolor=color[ind],alpha=.5, | 23 | + plt.hist(nbGen,nbBins,range=[2,9],log=1,facecolor=color[ind],alpha=.5, weights=weight, |
24 | label="$10^{-%.0f"%float(fileId)+"}$Gauss") | 24 | label="$10^{-%.0f"%float(fileId)+"}$Gauss") |
25 | ind=ind+1 | 25 | ind=ind+1 |
26 | 26 |
Time_distribution.py
@@ -2,10 +2,9 @@ | @@ -2,10 +2,9 @@ | ||
2 | 2 | ||
3 | from sys import argv | 3 | from sys import argv |
4 | import os.path | 4 | import os.path |
5 | -import numpy as np | ||
6 | -from scipy.optimize import curve_fit | ||
7 | import matplotlib.pyplot as plt | 5 | import matplotlib.pyplot as plt |
8 | -from Constantes import s_to_yr | 6 | +from Constantes import * |
7 | +from scipy.integrate import quad | ||
9 | 8 | ||
10 | if argv[1] == "EGMF": | 9 | if argv[1] == "EGMF": |
11 | fileName="Results_EGMF" | 10 | fileName="Results_EGMF" |
@@ -14,6 +13,9 @@ elif argv[1] == "EBL": | @@ -14,6 +13,9 @@ elif argv[1] == "EBL": | ||
14 | B=10**(-15) | 13 | B=10**(-15) |
15 | Model=["Kneiske and Doll - 'best fit'","Kneiske and Doll - 'lower limit'", | 14 | Model=["Kneiske and Doll - 'best fit'","Kneiske and Doll - 'lower limit'", |
16 | "Franceschini","Finke and Al","Gilmore and Al","Dominguez and Al"] | 15 | "Franceschini","Finke and Al","Gilmore and Al","Dominguez and Al"] |
16 | +elif argv[1] == "prec": | ||
17 | + fileName="Results_prec" | ||
18 | + B=10**(-17) | ||
17 | else: | 19 | else: |
18 | print "Used: ./Energy_distribution.py arg1 ind1 ind2 ..." | 20 | print "Used: ./Energy_distribution.py arg1 ind1 ind2 ..." |
19 | print " arg1 = EGMF or EBL " | 21 | print " arg1 = EGMF or EBL " |
@@ -25,39 +27,57 @@ else: | @@ -25,39 +27,57 @@ else: | ||
25 | 27 | ||
26 | # figure: energy distribution | 28 | # figure: energy distribution |
27 | #============================= | 29 | #============================= |
28 | -nbBins = 200 | ||
29 | -convert= 180/np.pi | 30 | +zSource = 0.0308 |
31 | +nbBins = 100 | ||
32 | +convert= 180/pi | ||
30 | color=['b','r','g','c','m','y'] | 33 | color=['b','r','g','c','m','y'] |
31 | 34 | ||
32 | fig = plt.figure() | 35 | fig = plt.figure() |
33 | ax = fig.add_subplot(111) | 36 | ax = fig.add_subplot(111) |
34 | 37 | ||
35 | -time= np.loadtxt(fileName+argv[2]+"/Results_position",unpack=True,usecols=[0]) | 38 | +def properTime(z): |
39 | + return -1/(H0*(1+z)*sqrt(omegaM*(1+z)**3+omegaK*(1+z)**2+omegaL)) | ||
40 | + | ||
41 | +tlim = quad(properTime,zSource,0)[0]/s_to_yr | ||
42 | +print tlim | ||
43 | + | ||
44 | +time= loadtxt(fileName+argv[2]+"/Results_position",unpack=True,usecols=[0]) | ||
45 | +time=time[time>0] | ||
46 | +time=time/tlim | ||
36 | tmax = max(time) | 47 | tmax = max(time) |
37 | tmin = min(time) | 48 | tmin = min(time) |
38 | print tmin, tmax | 49 | print tmin, tmax |
39 | 50 | ||
40 | ind = 0 | 51 | ind = 0 |
41 | for fileId in argv[2:]: | 52 | for fileId in argv[2:]: |
42 | - time= np.loadtxt(fileName+fileId+"/Results_position",unpack=True,usecols=[0]) | ||
43 | - weight,gen=np.loadtxt(fileName+fileId+"/Results_extra",unpack=True,usecols=[2,3]) | 53 | + time= loadtxt(fileName+fileId+"/Results_position",unpack=True,usecols=[0]) |
54 | + charge,weight,gen=loadtxt(fileName+fileId+"/Results_extra",unpack=True,usecols=[0,2,3]) | ||
55 | + time=time/tlim | ||
56 | + | ||
57 | + prop = float(shape(time[time<0])[0])/shape(time)[0] | ||
58 | + print "data shape",fileName+fileId,":", shape(time), "negative time:", shape(time[time<0]), "~", prop | ||
44 | 59 | ||
45 | - cond=(gen<8) | 60 | + cond= (gen<10) & (time>0) & (charge==0) |
46 | time=time[cond] | 61 | time=time[cond] |
47 | weight=weight[cond] | 62 | weight=weight[cond] |
63 | + time=log10(time) | ||
48 | 64 | ||
49 | - print "data shape",fileName+fileId,":", np.shape(time) | ||
50 | - | ||
51 | - dN,dt=np.histogram(time,nbBins,range=(tmin,tmax),weights=weight) | 65 | + dN,dt=histogram(time,nbBins,range=(log10(tmin),log10(tmax)),weights=weight) |
66 | + #time=10**time | ||
52 | timecenter=(dt[1:nbBins+1]+dt[0:nbBins])/2 | 67 | timecenter=(dt[1:nbBins+1]+dt[0:nbBins])/2 |
53 | binSize=dt[1:nbBins+1]-dt[0:nbBins] | 68 | binSize=dt[1:nbBins+1]-dt[0:nbBins] |
54 | dNdt=dN/binSize | 69 | dNdt=dN/binSize |
55 | 70 | ||
56 | if argv[1] == "EGMF": | 71 | if argv[1] == "EGMF": |
57 | - #ax.hist(time,nbBins,weights=weight,range=(tmin,tmax),log=1,facecolor=color[ind],alpha=.5, | ||
58 | - # label="$10^{-%.0f"%float(fileId)+"}$Gauss") | 72 | + ax.hist(time,nbBins,weights=weight,range=(log10(tmin),log10(tmax)),log=1,facecolor=color[ind], |
73 | + alpha=.5, label="$10^{-%.0f"%float(fileId)+"}$Gauss") | ||
59 | ax.plot(timecenter[dNdt!=0],dNdt[dNdt!=0],"-"+color[ind], | 74 | ax.plot(timecenter[dNdt!=0],dNdt[dNdt!=0],"-"+color[ind], |
60 | label="$10^{-%.0f"%float(fileId)+"}$Gauss") | 75 | label="$10^{-%.0f"%float(fileId)+"}$Gauss") |
76 | + elif argv[1] == "prec": | ||
77 | + ax.hist(time,nbBins,weights=weight,range=(log10(tmin),log10(tmax)),log=1,facecolor=color[ind], | ||
78 | + alpha=.5)#, label="prec = $10^{-%.0f"%float(fileId)+"}$") | ||
79 | + ax.plot(timecenter[dNdt!=0],dNdt[dNdt!=0],"-"+color[ind], | ||
80 | + label="prec = $10^{-%.0f"%float(fileId)+"}$") | ||
61 | elif argv[1] == "EBL": | 81 | elif argv[1] == "EBL": |
62 | #plt.hist(time,nbBins,weights=weight,range=(tmin,tmax),log=1,facecolor=color[ind],alpha=.5, | 82 | #plt.hist(time,nbBins,weights=weight,range=(tmin,tmax),log=1,facecolor=color[ind],alpha=.5, |
63 | ax.plot(timecenter,dNdt,"."+color[ind], | 83 | ax.plot(timecenter,dNdt,"."+color[ind], |
@@ -69,7 +89,9 @@ for fileId in argv[2:]: | @@ -69,7 +89,9 @@ for fileId in argv[2:]: | ||
69 | #ax.set_yscale('log') | 89 | #ax.set_yscale('log') |
70 | ax.grid(b=True,which='major') | 90 | ax.grid(b=True,which='major') |
71 | ax.legend(loc="best") | 91 | ax.legend(loc="best") |
72 | -ax.set_xlabel("Time [yr]") | ||
73 | -ax.set_ylabel("$dN/dt$ [yr$^{-1}$]") | 92 | +if argv[1]=="prec": |
93 | + ax.legend(loc="best",title="$10^{-17}$Gauss") | ||
94 | +ax.set_xlabel("Time [$\Delta t / t$ log scale]") | ||
95 | +ax.set_ylabel("$t\ dN/dt$") | ||
74 | 96 | ||
75 | plt.show() | 97 | plt.show() |