Commit 484df0323a4ce10dffb6fa0eab80bfc54ed0dd08

Authored by Thomas Fitoussi
1 parent 138898c8
Exists in master

Correction on the theta^2 distribution and on the analytic expression of theta vs E

@@ -6,7 +6,7 @@ from Modules.Read import ReadEnergy, ReadTime, ReadExtraFile, ReadProfile @@ -6,7 +6,7 @@ from Modules.Read import ReadEnergy, ReadTime, ReadExtraFile, ReadProfile
6 from Modules.Read import ReadMomentumAngle, ReadPositionAngle, resultDirectory 6 from Modules.Read import ReadMomentumAngle, ReadPositionAngle, resultDirectory
7 from Modules.Spectrum import spectrum 7 from Modules.Spectrum import spectrum
8 from Modules.Map import computeMap 8 from Modules.Map import computeMap
9 -from Modules.Angle import angle_vs_energy 9 +from Modules.Angle import angle_vs_energy, radial
10 from Modules.Timing import timing 10 from Modules.Timing import timing
11 from Modules.Constants import degre 11 from Modules.Constants import degre
12 12
@@ -29,8 +29,9 @@ for fileId in argv[1:]: @@ -29,8 +29,9 @@ for fileId in argv[1:]:
29 energy = ReadEnergy(fileId) 29 energy = ReadEnergy(fileId)
30 weightini, generation, theta_arrival, Esource, dir_source = ReadExtraFile(fileId,[2,3,4,5,6]) 30 weightini, generation, theta_arrival, Esource, dir_source = ReadExtraFile(fileId,[2,3,4,5,6])
31 #weightini, generation, theta_arrival, Esource = ReadExtraFile(fileId,[2,3,4,5]) 31 #weightini, generation, theta_arrival, Esource = ReadExtraFile(fileId,[2,3,4,5])
32 - nbPhotonsEmitted=ReadProfile(fileId,[3])  
33 - weightini /= nbPhotonsEmitted 32 + n_phot, n_lept = ReadProfile(fileId,[3,5])
  33 + ratio = n_phot#/n_lept
  34 + weightini /= ratio
34 theta_arrival*= degre 35 theta_arrival*= degre
35 36
36 thetaDir,phiDir = ReadMomentumAngle(fileId)*degre 37 thetaDir,phiDir = ReadMomentumAngle(fileId)*degre
@@ -68,7 +69,7 @@ for fileId in argv[1:]: @@ -68,7 +69,7 @@ for fileId in argv[1:]:
68 nbBins = 100 69 nbBins = 100
69 # draw source spectrum 70 # draw source spectrum
70 Es=array(list(set(Esource))) 71 Es=array(list(set(Esource)))
71 - Ws= (Es/min(Es))**(1-powerlaw_index) /nbPhotonsEmitted 72 + Ws= (Es/min(Es))**(1-powerlaw_index) / ratio
72 Es,Fs = spectrum(Es,Ws,nbBins=nbBins) 73 Es,Fs = spectrum(Es,Ws,nbBins=nbBins)
73 Es=Es[:,newaxis] 74 Es=Es[:,newaxis]
74 Fs=Fs[:,newaxis] 75 Fs=Fs[:,newaxis]
@@ -92,8 +93,10 @@ for fileId in argv[1:]: @@ -92,8 +93,10 @@ for fileId in argv[1:]:
92 Spectrum = append(Spectrum,flux_0,axis=1) 93 Spectrum = append(Spectrum,flux_0,axis=1)
93 94
94 # IMAGING, RADIAL DISTRIBUTION AND ANGLE VERSUS ENERGY ======================# 95 # IMAGING, RADIAL DISTRIBUTION AND ANGLE VERSUS ENERGY ======================#
95 - nbBins = 60  
96 - theta2,dndtheta2,ener,angle = angle_vs_energy(theta_arrival,energy,weight,nbBins) 96 + nbBins = 50
  97 + cond = energy>1e-3
  98 + ener,angle = angle_vs_energy(theta_arrival[cond],energy[cond],weight[cond],nbBins)
  99 + theta2,dndtheta2 = radial(theta[cond],weight[cond],nbBins)
97 theta2=theta2[:,newaxis] 100 theta2=theta2[:,newaxis]
98 dndtheta2=dndtheta2[:,newaxis] 101 dndtheta2=dndtheta2[:,newaxis]
99 ener=ener[:,newaxis] 102 ener=ener[:,newaxis]
@@ -128,7 +131,7 @@ for fileId in argv[1:]: @@ -128,7 +131,7 @@ for fileId in argv[1:]:
128 Jet_Opening=[180,60,30] # degre (180 <=> isotrop) 131 Jet_Opening=[180,60,30] # degre (180 <=> isotrop)
129 powerlaw_index = 2 132 powerlaw_index = 2
130 Elim = 1e-1 # GeV 133 Elim = 1e-1 # GeV
131 - thetalim = 50 # degre 134 + thetalim = 20 # degre
132 135
133 # apply source spectrum 136 # apply source spectrum
134 weight_source = (Esource/min(Esource))**(1-powerlaw_index) 137 weight_source = (Esource/min(Esource))**(1-powerlaw_index)
@@ -160,7 +163,7 @@ for fileId in argv[1:]: @@ -160,7 +163,7 @@ for fileId in argv[1:]:
160 nbBins = 100 163 nbBins = 100
161 # draw source spectrum 164 # draw source spectrum
162 Es=array(list(set(Esource))) 165 Es=array(list(set(Esource)))
163 - Ws= (Es/min(Es))**(1-powerlaw_index) /nbPhotonsEmitted 166 + Ws= (Es/min(Es))**(1-powerlaw_index) / ratio
164 Es,Fs = spectrum(Es,Ws,nbBins=nbBins) 167 Es,Fs = spectrum(Es,Ws,nbBins=nbBins)
165 Es=Es[:,newaxis] 168 Es=Es[:,newaxis]
166 Fs=Fs[:,newaxis] 169 Fs=Fs[:,newaxis]
@@ -184,9 +187,10 @@ for fileId in argv[1:]: @@ -184,9 +187,10 @@ for fileId in argv[1:]:
184 Spectrum = append(Spectrum,flux_0,axis=1) 187 Spectrum = append(Spectrum,flux_0,axis=1)
185 188
186 # IMAGING, RADIAL DISTRIBUTION AND ANGLE VERSUS ENERGY ======================# 189 # IMAGING, RADIAL DISTRIBUTION AND ANGLE VERSUS ENERGY ======================#
187 - nbBins = 60 190 + nbBins = 50
188 computeMap(theta,phi,weight,energy,fileId,jet_opening_angle,nbBins,borne=[thetalim,thetalim]) 191 computeMap(theta,phi,weight,energy,fileId,jet_opening_angle,nbBins,borne=[thetalim,thetalim])
189 - theta2,dndtheta2,ener,angle = angle_vs_energy(theta_arrival,energy,weight,nbBins) 192 + ener,angle = angle_vs_energy(theta_arrival,energy,weight,nbBins)
  193 + theta2,dndtheta2 = radial(theta_arrival,weight,nbBins)
190 theta2=theta2[:,newaxis] 194 theta2=theta2[:,newaxis]
191 dndtheta2=dndtheta2[:,newaxis] 195 dndtheta2=dndtheta2[:,newaxis]
192 ener=ener[:,newaxis] 196 ener=ener[:,newaxis]
@@ -201,9 +205,7 @@ for fileId in argv[1:]: @@ -201,9 +205,7 @@ for fileId in argv[1:]:
201 Radial = append(Radial,dndtheta2,axis=1) 205 Radial = append(Radial,dndtheta2,axis=1)
202 Angle_Energy = append(Angle_Energy,angle,axis=1) 206 Angle_Energy = append(Angle_Energy,angle,axis=1)
203 207
204 - #=============================================================================#  
205 - # TIME DISTRIBUTION AND TIME DELAY VERSUS ANGLE  
206 - #=============================================================================# 208 + # TIME DISTRIBUTION AND TIME DELAY VERSUS ANGLE =============================#
207 nbBins = 100 209 nbBins = 100
208 delta_t,dNdt = timing(time,weight,nbBins) 210 delta_t,dNdt = timing(time,weight,nbBins)
209 delta_t=delta_t[:,newaxis] 211 delta_t=delta_t[:,newaxis]
Modules/Analytic.py
@@ -16,9 +16,8 @@ def Analytic_theta(E_ic,fileId): @@ -16,9 +16,8 @@ def Analytic_theta(E_ic,fileId):
16 delta_to_theta=lambda_gg(Esource)/Dsource 16 delta_to_theta=lambda_gg(Esource)/Dsource
17 RL0=RL(Esource/2,B) 17 RL0=RL(Esource/2,B)
18 Dic0=Dic(Esource/2) 18 Dic0=Dic(Esource/2)
19 - Ee2= E_ic /Eic(1) #GeV^2  
20 - delta=Dic0/(2*RL0)*((Esource/2)**2 /Ee2 -1)  
21 - return abs(arcsin(delta_to_theta*sin(delta))) 19 + delta=Dic0/(2*RL0)*((Esource/(2*Ee(E_ic)))**2 -1)
  20 + return abs(arcsin(delta_to_theta*sin(delta)))*degre
22 21
23 def Analytic_delay_vs_theta(theta,fileId): 22 def Analytic_delay_vs_theta(theta,fileId):
24 Esource,distSource=ReadProfile(fileId,[0,2]) #GeV #Mpc 23 Esource,distSource=ReadProfile(fileId,[0,2]) #GeV #Mpc
@@ -60,7 +59,7 @@ def Eic(Ee=Ee_default): @@ -60,7 +59,7 @@ def Eic(Ee=Ee_default):
60 return 4*Ecmb*Ee**2/(3*me**2)*1e3 #GeV 59 return 4*Ecmb*Ee**2/(3*me**2)*1e3 #GeV
61 60
62 def Ee(Egamma=Egamma_default): 61 def Ee(Egamma=Egamma_default):
63 - return sqrt((3*me**2)/(4*Ecmb)*1e-3 *Egamma) #GeV 62 + return me*sqrt((3*Egamma*1e-3 )/(4*Ecmb)) #GeV
64 63
65 def tIC(): 64 def tIC():
66 return lambdaIC()/(c*yr/Mpc) #yr 65 return lambdaIC()/(c*yr/Mpc) #yr
@@ -87,4 +86,4 @@ def Ethreshold_gg(): @@ -87,4 +86,4 @@ def Ethreshold_gg():
87 return (me)**2/Eebl *1e-3 #GeV 86 return (me)**2/Eebl *1e-3 #GeV
88 87
89 def lambda_gg(Egamma=1): # Egamma (GeV) 88 def lambda_gg(Egamma=1): # Egamma (GeV)
90 - return 800. /(Egamma)#Mpc (from Durrer and Neronov 2013) 89 + return 800. /(Egamma) *1e3#Mpc (from Durrer and Neronov 2013)
Modules/Analytic.pyc
No preview for this file type
Modules/Angle.py
@@ -19,20 +19,22 @@ def angle_vs_energy(theta,energy,weight,nbBins=50): @@ -19,20 +19,22 @@ def angle_vs_energy(theta,energy,weight,nbBins=50):
19 enercenter = (ener[1:nbBins+1]+ener[0:nbBins])/2 19 enercenter = (ener[1:nbBins+1]+ener[0:nbBins])/2
20 angle /= nb 20 angle /= nb
21 21
22 - # RADIAL DISTRIBUTION ========================================================# 22 + return enercenter, angle
  23 +
  24 +def radial(theta,weight,nbBins=50):
23 cond = theta!=0 25 cond = theta!=0
24 - #theta = 2*log10(theta[cond])  
25 - theta = theta[cond]**2 26 + theta = 2*log10(theta[cond])
26 weight = weight[cond] 27 weight = weight[cond]
27 - #dn,angle2 = histogram(theta,nbBins,range=[2*log10(1e-6),2*log10(90)],weights=weight)  
28 - dn,angle2 = histogram(theta,nbBins,range=[0,20],weights=weight)  
29 - #angle2=10**angle2 28 + dn,angle2 = histogram(theta,nbBins,range=[2*log10(1e-3),2*log10(25)],weights=weight)
  29 + angle2=10**angle2
  30 + #theta = theta**2
  31 + #dn,angle2 = histogram(theta,nbBins,range=[0,25],weights=weight)
30 thetacenter = (angle2[1:nbBins+1]+angle2[0:nbBins])/2 32 thetacenter = (angle2[1:nbBins+1]+angle2[0:nbBins])/2
31 dtheta = angle2[1:nbBins+1]-angle2[0:nbBins] 33 dtheta = angle2[1:nbBins+1]-angle2[0:nbBins]
32 dndtheta = dn/dtheta 34 dndtheta = dn/dtheta
33 dndtheta /= max(dndtheta) 35 dndtheta /= max(dndtheta)
34 36
35 - return thetacenter, dndtheta, enercenter, angle 37 + return thetacenter, dndtheta
36 38
37 def drawRadial(files,all_source_spectrum=False,all_jets=False): 39 def drawRadial(files,all_source_spectrum=False,all_jets=False):
38 ''' 40 '''
@@ -61,15 +63,15 @@ def drawRadial(files,all_source_spectrum=False,all_jets=False): @@ -61,15 +63,15 @@ def drawRadial(files,all_source_spectrum=False,all_jets=False):
61 ax.plot(theta,dndtheta2,drawstyle='steps-mid',label=fileId) 63 ax.plot(theta,dndtheta2,drawstyle='steps-mid',label=fileId)
62 64
63 ax.legend(loc="best") 65 ax.legend(loc="best")
64 - #ax.set_xscale('log') 66 + ax.set_xscale('log')
65 ax.set_yscale('log') 67 ax.set_yscale('log')
66 ax.grid(b=True,which='major') 68 ax.grid(b=True,which='major')
67 ax.set_xlabel("$\\theta^2$ [deg$^2$]") 69 ax.set_xlabel("$\\theta^2$ [deg$^2$]")
68 - ax.set_ylabel("$dN/d\\theta$ [deg$^{-1}$]") 70 + ax.set_ylabel("$dN/d\\theta^2$ [arbitrary]")
69 71
70 show() 72 show()
71 73
72 -def drawAngle_vs_energy(files): 74 +def drawAngle_vs_energy(files,all_source_spectrum=False,all_jets=False,PlotAnalytic=False):
73 ''' 75 '''
74 Plot arrival angle versus energy + analytic expression 76 Plot arrival angle versus energy + analytic expression
75 Input: list of directories 77 Input: list of directories
@@ -79,18 +81,30 @@ def drawAngle_vs_energy(files): @@ -79,18 +81,30 @@ def drawAngle_vs_energy(files):
79 ax1 = fig.add_subplot(111) 81 ax1 = fig.add_subplot(111)
80 82
81 for fileId in files: 83 for fileId in files:
82 - ener,angle = ReadAngleVsEnergy(fileId,[0,1])  
83 - p=ax1.plot(ener,angle,drawstyle='steps-mid',label=fileId) 84 + if all_source_spectrum:
  85 + i=1
  86 + for powerlaw_index in [1,1.5,2,2.5]:
  87 + ener,angle = ReadAngleVsEnergy(fileId,[0,i])
  88 + p=ax1.plot(ener,angle,drawstyle='steps-mid',label="p=%.1f"%powerlaw_index)
  89 + elif all_jets:
  90 + i=5
  91 + for jet_opening in ["isotrop","60 deg","30 deg"]:
  92 + ener,angle = ReadAngleVsEnergy(fileId,[0,i])
  93 + p=ax1.plot(ener,angle,drawstyle='steps-mid',label=jet_opening)
  94 + else:
  95 + ener,angle = ReadAngleVsEnergy(fileId,[0,1])
  96 + p=ax1.plot(ener,angle,drawstyle='steps-mid',label=fileId)
84 97
85 - yfit = Analytic_theta(ener,fileId)  
86 - ax1.plot(ener,yfit,'--',color="m",linewidth=2,label="analytic") 98 + if PlotAnalytic:
  99 + yfit = Analytic_theta(ener,fileId)
  100 + ax1.plot(ener,yfit,'--',color=p[0].get_color(),linewidth=2,label="analytic")
87 101
88 ax1.legend(loc="best") 102 ax1.legend(loc="best")
89 ax1.set_xscale('log') 103 ax1.set_xscale('log')
90 ax1.set_yscale('log') 104 ax1.set_yscale('log')
91 ax1.set_ylim([0,180]) 105 ax1.set_ylim([0,180])
92 ax1.grid(b=True,which='major') 106 ax1.grid(b=True,which='major')
93 - ax1.set_ylabel("$\\theta$ [rad]") 107 + ax1.set_ylabel("$\\theta$ [deg]")
94 ax1.set_xlabel("energy [GeV]") 108 ax1.set_xlabel("energy [GeV]")
95 109
96 show() 110 show()
Modules/Angle.pyc
No preview for this file type