Commit 484df0323a4ce10dffb6fa0eab80bfc54ed0dd08
1 parent
138898c8
Exists in
master
Correction on the theta^2 distribution and on the analytic expression of theta vs E
Showing
5 changed files
with
48 additions
and
33 deletions
Show diff stats
Analysis.py
... | ... | @@ -6,7 +6,7 @@ from Modules.Read import ReadEnergy, ReadTime, ReadExtraFile, ReadProfile |
6 | 6 | from Modules.Read import ReadMomentumAngle, ReadPositionAngle, resultDirectory |
7 | 7 | from Modules.Spectrum import spectrum |
8 | 8 | from Modules.Map import computeMap |
9 | -from Modules.Angle import angle_vs_energy | |
9 | +from Modules.Angle import angle_vs_energy, radial | |
10 | 10 | from Modules.Timing import timing |
11 | 11 | from Modules.Constants import degre |
12 | 12 | |
... | ... | @@ -29,8 +29,9 @@ for fileId in argv[1:]: |
29 | 29 | energy = ReadEnergy(fileId) |
30 | 30 | weightini, generation, theta_arrival, Esource, dir_source = ReadExtraFile(fileId,[2,3,4,5,6]) |
31 | 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 | 35 | theta_arrival*= degre |
35 | 36 | |
36 | 37 | thetaDir,phiDir = ReadMomentumAngle(fileId)*degre |
... | ... | @@ -68,7 +69,7 @@ for fileId in argv[1:]: |
68 | 69 | nbBins = 100 |
69 | 70 | # draw source spectrum |
70 | 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 | 73 | Es,Fs = spectrum(Es,Ws,nbBins=nbBins) |
73 | 74 | Es=Es[:,newaxis] |
74 | 75 | Fs=Fs[:,newaxis] |
... | ... | @@ -92,8 +93,10 @@ for fileId in argv[1:]: |
92 | 93 | Spectrum = append(Spectrum,flux_0,axis=1) |
93 | 94 | |
94 | 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 | 100 | theta2=theta2[:,newaxis] |
98 | 101 | dndtheta2=dndtheta2[:,newaxis] |
99 | 102 | ener=ener[:,newaxis] |
... | ... | @@ -128,7 +131,7 @@ for fileId in argv[1:]: |
128 | 131 | Jet_Opening=[180,60,30] # degre (180 <=> isotrop) |
129 | 132 | powerlaw_index = 2 |
130 | 133 | Elim = 1e-1 # GeV |
131 | - thetalim = 50 # degre | |
134 | + thetalim = 20 # degre | |
132 | 135 | |
133 | 136 | # apply source spectrum |
134 | 137 | weight_source = (Esource/min(Esource))**(1-powerlaw_index) |
... | ... | @@ -160,7 +163,7 @@ for fileId in argv[1:]: |
160 | 163 | nbBins = 100 |
161 | 164 | # draw source spectrum |
162 | 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 | 167 | Es,Fs = spectrum(Es,Ws,nbBins=nbBins) |
165 | 168 | Es=Es[:,newaxis] |
166 | 169 | Fs=Fs[:,newaxis] |
... | ... | @@ -184,9 +187,10 @@ for fileId in argv[1:]: |
184 | 187 | Spectrum = append(Spectrum,flux_0,axis=1) |
185 | 188 | |
186 | 189 | # IMAGING, RADIAL DISTRIBUTION AND ANGLE VERSUS ENERGY ======================# |
187 | - nbBins = 60 | |
190 | + nbBins = 50 | |
188 | 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 | 194 | theta2=theta2[:,newaxis] |
191 | 195 | dndtheta2=dndtheta2[:,newaxis] |
192 | 196 | ener=ener[:,newaxis] |
... | ... | @@ -201,9 +205,7 @@ for fileId in argv[1:]: |
201 | 205 | Radial = append(Radial,dndtheta2,axis=1) |
202 | 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 | 209 | nbBins = 100 |
208 | 210 | delta_t,dNdt = timing(time,weight,nbBins) |
209 | 211 | delta_t=delta_t[:,newaxis] | ... | ... |
Modules/Analytic.py
... | ... | @@ -16,9 +16,8 @@ def Analytic_theta(E_ic,fileId): |
16 | 16 | delta_to_theta=lambda_gg(Esource)/Dsource |
17 | 17 | RL0=RL(Esource/2,B) |
18 | 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 | 22 | def Analytic_delay_vs_theta(theta,fileId): |
24 | 23 | Esource,distSource=ReadProfile(fileId,[0,2]) #GeV #Mpc |
... | ... | @@ -60,7 +59,7 @@ def Eic(Ee=Ee_default): |
60 | 59 | return 4*Ecmb*Ee**2/(3*me**2)*1e3 #GeV |
61 | 60 | |
62 | 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 | 64 | def tIC(): |
66 | 65 | return lambdaIC()/(c*yr/Mpc) #yr |
... | ... | @@ -87,4 +86,4 @@ def Ethreshold_gg(): |
87 | 86 | return (me)**2/Eebl *1e-3 #GeV |
88 | 87 | |
89 | 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 | 19 | enercenter = (ener[1:nbBins+1]+ener[0:nbBins])/2 |
20 | 20 | angle /= nb |
21 | 21 | |
22 | - # RADIAL DISTRIBUTION ========================================================# | |
22 | + return enercenter, angle | |
23 | + | |
24 | +def radial(theta,weight,nbBins=50): | |
23 | 25 | cond = theta!=0 |
24 | - #theta = 2*log10(theta[cond]) | |
25 | - theta = theta[cond]**2 | |
26 | + theta = 2*log10(theta[cond]) | |
26 | 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 | 32 | thetacenter = (angle2[1:nbBins+1]+angle2[0:nbBins])/2 |
31 | 33 | dtheta = angle2[1:nbBins+1]-angle2[0:nbBins] |
32 | 34 | dndtheta = dn/dtheta |
33 | 35 | dndtheta /= max(dndtheta) |
34 | 36 | |
35 | - return thetacenter, dndtheta, enercenter, angle | |
37 | + return thetacenter, dndtheta | |
36 | 38 | |
37 | 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 | 63 | ax.plot(theta,dndtheta2,drawstyle='steps-mid',label=fileId) |
62 | 64 | |
63 | 65 | ax.legend(loc="best") |
64 | - #ax.set_xscale('log') | |
66 | + ax.set_xscale('log') | |
65 | 67 | ax.set_yscale('log') |
66 | 68 | ax.grid(b=True,which='major') |
67 | 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 | 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 | 76 | Plot arrival angle versus energy + analytic expression |
75 | 77 | Input: list of directories |
... | ... | @@ -79,18 +81,30 @@ def drawAngle_vs_energy(files): |
79 | 81 | ax1 = fig.add_subplot(111) |
80 | 82 | |
81 | 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 | 102 | ax1.legend(loc="best") |
89 | 103 | ax1.set_xscale('log') |
90 | 104 | ax1.set_yscale('log') |
91 | 105 | ax1.set_ylim([0,180]) |
92 | 106 | ax1.grid(b=True,which='major') |
93 | - ax1.set_ylabel("$\\theta$ [rad]") | |
107 | + ax1.set_ylabel("$\\theta$ [deg]") | |
94 | 108 | ax1.set_xlabel("energy [GeV]") |
95 | 109 | |
96 | 110 | show() | ... | ... |
Modules/Angle.pyc
No preview for this file type