Commit ab1642d3d920456597a888bd830409f26547b70c
1 parent
4448ea24
Exists in
master
Add usefull integrand in Constantes.py
Showing
5 changed files
with
34 additions
and
23 deletions
Show diff stats
Angle_distribution.py
@@ -33,8 +33,8 @@ def fit_theta(E,B): | @@ -33,8 +33,8 @@ def fit_theta(E,B): | ||
33 | delta=Dic0/(2*RL0)*((Esource/2)**2 *Eic/E-1) | 33 | delta=Dic0/(2*RL0)*((Esource/2)**2 *Eic/E-1) |
34 | return abs(arcsin(delta_to_theta*sin(delta))*degre) | 34 | return abs(arcsin(delta_to_theta*sin(delta))*degre) |
35 | 35 | ||
36 | -#fig2 = plt.figure() | ||
37 | -#ax2 = fig2.add_subplot(111) | 36 | +fig2 = plt.figure() |
37 | +ax2 = fig2.add_subplot(111) | ||
38 | 38 | ||
39 | fig1 = plt.figure() | 39 | fig1 = plt.figure() |
40 | gs = gridspec.GridSpec(2, 1, height_ratios=[4,1]) | 40 | gs = gridspec.GridSpec(2, 1, height_ratios=[4,1]) |
@@ -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)&(charge==0) | 62 | + cond=(costheta<=1)&(costheta>=-1) |
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] |
@@ -80,26 +80,29 @@ for fileId in argv[2:]: | @@ -80,26 +80,29 @@ for fileId in argv[2:]: | ||
80 | #ax11.plot(energy,theta,'.'+color[ind],label="$10^{-%.0f"%float(fileId)+"}$Gauss - MC") | 80 | #ax11.plot(energy,theta,'.'+color[ind],label="$10^{-%.0f"%float(fileId)+"}$Gauss - MC") |
81 | B=10**(-float(fileId)) | 81 | B=10**(-float(fileId)) |
82 | yfit = fit_theta(enercenter,B) | 82 | yfit = fit_theta(enercenter,B) |
83 | - ax11.plot(enercenter,yfit,'--'+color[ind+1],linewidth=2,label="$10^{-%.0f"%float(fileId)+"}$Gauss - analytic") | 83 | + ax11.plot(enercenter,yfit,'--'+color[ind],linewidth=2,label="$10^{-%.0f"%float(fileId)+"}$Gauss - analytic") |
84 | elif argv[1] == "EBL": | 84 | elif argv[1] == "EBL": |
85 | ax11.plot(enercenter,angle,'.'+color[ind],label=Model[int(fileId)-1]) | 85 | ax11.plot(enercenter,angle,'.'+color[ind],label=Model[int(fileId)-1]) |
86 | if ind==0: | 86 | if ind==0: |
87 | yfit = fit_theta(enercenter,B) | 87 | yfit = fit_theta(enercenter,B) |
88 | - ax11.plot(enercenter,yfit,'--'+color[ind+1],linewidth=2,label="$10^{-15}$Gauss - analytic") | 88 | + ax11.plot(enercenter,yfit,'--'+color[ind],linewidth=2,label="$10^{-15}$Gauss - analytic") |
89 | 89 | ||
90 | error=angle/yfit-1 | 90 | error=angle/yfit-1 |
91 | ax12.plot(enercenter,error,'+'+color[ind]) | 91 | ax12.plot(enercenter,error,'+'+color[ind]) |
92 | 92 | ||
93 | # figure: radial distribution | 93 | # figure: radial distribution |
94 | #============================= | 94 | #============================= |
95 | - #nbBins = 20 | ||
96 | - #theta = log10(theta) | ||
97 | - #nb,angle1=histogram(theta, nbBins, weights=weight) | 95 | + nbBins = 20 |
96 | + theta = theta[theta!=0] | ||
97 | + weight=weight[theta!=0] | ||
98 | + #theta = log10(theta**2) | ||
99 | + nb,angle1=histogram(theta**2,nbBins, range=[0,1],weights=weight) | ||
98 | #angle1=10**angle1 | 100 | #angle1=10**angle1 |
99 | - #anglecenter=(angle1[1:nbBins+1]+angle1[0:nbBins])/2 | ||
100 | - #binSize=angle1[1:nbBins+1]-angle1[0:nbBins] | ||
101 | - #ax2.plot(anglecenter,nb,'-'+color[ind],label="$10^{-%.0f"%float(fileId)+"}$Gauss - MC") | ||
102 | - #ax2.hist(theta, nbBins, weights=weight,log=True, | 101 | + anglecenter=(angle1[1:nbBins+1]+angle1[0:nbBins])/2 |
102 | + binSize=angle1[1:nbBins+1]-angle1[0:nbBins] | ||
103 | + ax2.plot(anglecenter,nb,'-'+color[ind], | ||
104 | + label="$10^{-%.0f"%float(fileId)+"}$Gauss - MC") | ||
105 | + #ax2.hist(theta, nbBins, range=[0,0.5], weights=weight,log=True, | ||
103 | # facecolor=color[ind],alpha=.5,label="$10^{-%.0f"%float(fileId)+"}$Gauss") | 106 | # facecolor=color[ind],alpha=.5,label="$10^{-%.0f"%float(fileId)+"}$Gauss") |
104 | 107 | ||
105 | ind=ind+1 | 108 | ind=ind+1 |
@@ -119,11 +122,11 @@ plt.ylim(min(error)-step, max(error)+step) | @@ -119,11 +122,11 @@ plt.ylim(min(error)-step, max(error)+step) | ||
119 | xticklabels = ax11.get_xticklabels() | 122 | xticklabels = ax11.get_xticklabels() |
120 | plt.setp(xticklabels, visible=False) | 123 | plt.setp(xticklabels, visible=False) |
121 | 124 | ||
122 | -#ax2.legend(loc="best") | 125 | +ax2.legend(loc="best") |
123 | #ax2.set_xscale('log') | 126 | #ax2.set_xscale('log') |
124 | -#ax2.set_yscale('log') | ||
125 | -#ax2.grid(b=True,which='major') | ||
126 | -#ax2.set_xlabel("$\\theta$ [degre]") | ||
127 | -#ax2.set_ylabel("Nb events * weight") | 127 | +ax2.set_yscale('log') |
128 | +ax2.grid(b=True,which='major') | ||
129 | +ax2.set_xlabel("$\\theta^2$ [degre]") | ||
130 | +ax2.set_ylabel("Nb events * weight") | ||
128 | 131 | ||
129 | plt.show() | 132 | plt.show() |
Constantes.py
@@ -64,3 +64,14 @@ Ethreshold_ic = Eic*Dic/RL # GeV | @@ -64,3 +64,14 @@ Ethreshold_ic = Eic*Dic/RL # GeV | ||
64 | # Pair production | 64 | # Pair production |
65 | Ethreshold_gg=(me)**2/Eebl *1e-3 #GeV | 65 | Ethreshold_gg=(me)**2/Eebl *1e-3 #GeV |
66 | lambda_gg=0.8 # (E_gamma/1TeV)^-1 Gpc (from Durrer and Neronov 2013) | 66 | lambda_gg=0.8 # (E_gamma/1TeV)^-1 Gpc (from Durrer and Neronov 2013) |
67 | + | ||
68 | +# usefull integrand | ||
69 | +def comobileTime(z): | ||
70 | + return -1/(H0*(1+z)*sqrt(omegaM*(1+z)**3+omegaK*(1+z)**2+omegaL)) | ||
71 | + | ||
72 | +def distPhoton(z): | ||
73 | + return -c/(H0*a0*sqrt(omegaM*(1+z)**3+omegaK*(1+z)**2+omegaL)) | ||
74 | + | ||
75 | +def distLepton(z,E): | ||
76 | + beta = sqrt(1-m**2*c**4/E**2) | ||
77 | + return -beta*c/(H0*a0*sqrt(omegaM*(1+z)**3+omegaK*(1+z)**2+omegaL)) |
Constantes.pyc
No preview for this file type
Energy_distribution.py
@@ -24,7 +24,7 @@ else: | @@ -24,7 +24,7 @@ else: | ||
24 | 24 | ||
25 | # figure: energy distribution | 25 | # figure: energy distribution |
26 | #============================= | 26 | #============================= |
27 | -nbBins = 70 | 27 | +nbBins = 100 |
28 | convert= 180/np.pi | 28 | convert= 180/np.pi |
29 | color=['b','r','g','c','m','y'] | 29 | color=['b','r','g','c','m','y'] |
30 | 30 | ||
@@ -70,7 +70,7 @@ for fileId in argv[2:]: | @@ -70,7 +70,7 @@ for fileId in argv[2:]: | ||
70 | 70 | ||
71 | def fit(x,a,b,c): | 71 | def fit(x,a,b,c): |
72 | return a* x**b +c | 72 | return a* x**b +c |
73 | -a=1 | 73 | +a=1/2.5 |
74 | b=0.5 | 74 | b=0.5 |
75 | c=0 | 75 | c=0 |
76 | 76 |
Time_distribution.py
@@ -35,10 +35,7 @@ color=['b','r','g','c','m','y'] | @@ -35,10 +35,7 @@ color=['b','r','g','c','m','y'] | ||
35 | fig = plt.figure() | 35 | fig = plt.figure() |
36 | ax = fig.add_subplot(111) | 36 | ax = fig.add_subplot(111) |
37 | 37 | ||
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 | 38 | +tlim = quad(comobileTime,zSource,0)[0]/s_to_yr |
42 | print tlim | 39 | print tlim |
43 | 40 | ||
44 | time= loadtxt(fileName+argv[2]+"/Results_position",unpack=True,usecols=[0]) | 41 | time= loadtxt(fileName+argv[2]+"/Results_position",unpack=True,usecols=[0]) |