Commit ab1642d3d920456597a888bd830409f26547b70c

Authored by Thomas Fitoussi
1 parent 4448ea24
Exists in master

Add usefull integrand in Constantes.py

Angle_distribution.py
... ... @@ -33,8 +33,8 @@ def fit_theta(E,B):
33 33 delta=Dic0/(2*RL0)*((Esource/2)**2 *Eic/E-1)
34 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 39 fig1 = plt.figure()
40 40 gs = gridspec.GridSpec(2, 1, height_ratios=[4,1])
... ... @@ -59,7 +59,7 @@ for fileId in argv[2:]:
59 59 diry=diry/hyp
60 60 dirz=dirz/hyp
61 61 costheta=dirx*posx+diry*posy+dirz*posz
62   - cond=(costheta<=1)&(costheta>=-1)&(charge==0)
  62 + cond=(costheta<=1)&(costheta>=-1)
63 63 theta = arccos(costheta[cond])*degre
64 64 weight= weight[cond]
65 65 energy= energy[cond]
... ... @@ -80,26 +80,29 @@ for fileId in argv[2:]:
80 80 #ax11.plot(energy,theta,'.'+color[ind],label="$10^{-%.0f"%float(fileId)+"}$Gauss - MC")
81 81 B=10**(-float(fileId))
82 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 84 elif argv[1] == "EBL":
85 85 ax11.plot(enercenter,angle,'.'+color[ind],label=Model[int(fileId)-1])
86 86 if ind==0:
87 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 90 error=angle/yfit-1
91 91 ax12.plot(enercenter,error,'+'+color[ind])
92 92  
93 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 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 106 # facecolor=color[ind],alpha=.5,label="$10^{-%.0f"%float(fileId)+"}$Gauss")
104 107  
105 108 ind=ind+1
... ... @@ -119,11 +122,11 @@ plt.ylim(min(error)-step, max(error)+step)
119 122 xticklabels = ax11.get_xticklabels()
120 123 plt.setp(xticklabels, visible=False)
121 124  
122   -#ax2.legend(loc="best")
  125 +ax2.legend(loc="best")
123 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 132 plt.show()
... ...
Constantes.py
... ... @@ -64,3 +64,14 @@ Ethreshold_ic = Eic*Dic/RL # GeV
64 64 # Pair production
65 65 Ethreshold_gg=(me)**2/Eebl *1e-3 #GeV
66 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 24  
25 25 # figure: energy distribution
26 26 #=============================
27   -nbBins = 70
  27 +nbBins = 100
28 28 convert= 180/np.pi
29 29 color=['b','r','g','c','m','y']
30 30  
... ... @@ -70,7 +70,7 @@ for fileId in argv[2:]:
70 70  
71 71 def fit(x,a,b,c):
72 72 return a* x**b +c
73   -a=1
  73 +a=1/2.5
74 74 b=0.5
75 75 c=0
76 76  
... ...
Time_distribution.py
... ... @@ -35,10 +35,7 @@ color=[&#39;b&#39;,&#39;r&#39;,&#39;g&#39;,&#39;c&#39;,&#39;m&#39;,&#39;y&#39;]
35 35 fig = plt.figure()
36 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 39 print tlim
43 40  
44 41 time= loadtxt(fileName+argv[2]+"/Results_position",unpack=True,usecols=[0])
... ...