Commit f42463907fb1bec9c6dc7d526d4c07d3220ead49
1 parent
e6f5876a
Exists in
master
Improve angular distribution (plot in log-log)
Showing
16 changed files
with
269 additions
and
49 deletions
Show diff stats
Analysis.py
Modules/Analytic.py
1 | 1 | from Constants import * |
2 | -from numpy import sqrt, abs, sin, arcsin | |
2 | +from numpy import sqrt, abs, cos, sin, arcsin | |
3 | 3 | from Read import ReadE_source, ReadD_source, ReadEGMF |
4 | 4 | |
5 | 5 | # Value for analytic expression |
... | ... | @@ -21,6 +21,13 @@ def Analytic_theta(E_ic,fileId): |
21 | 21 | delta=Dic0/(2*RL0)*((Esource/2)**2 /Ee2 -1) |
22 | 22 | return abs(arcsin(delta_to_theta*sin(delta))*degre) |
23 | 23 | |
24 | +def Analytic_delay(theta, E0_source, distSource): | |
25 | + delta_ic = arcsin(lambda_gg(E0_source)/distSource*theta/degre) | |
26 | + #c_delta_t = lambda_gg(E0_source)*(1-cos(delta_ic))-distSource*(1-cos(theta)) | |
27 | + #return abs(c_delta_t*Mpc/c) | |
28 | + coef = lambda_gg(E0_source)/(2*c/Mpc) | |
29 | + return coef*delta_ic#**2 | |
30 | + | |
24 | 31 | # Compton accumulation |
25 | 32 | def ECompton_threshold(Compton_threshold = 0.005): |
26 | 33 | return Compton_threshold/(4/3*Ecmb/me*1e-3) *me*1e-6 #GeV | ... | ... |
Modules/Analytic.pyc
No preview for this file type
Modules/Angle.py
... | ... | @@ -3,12 +3,18 @@ from matplotlib.pyplot import figure, show, ylim, setp |
3 | 3 | from matplotlib import gridspec |
4 | 4 | from Read import ReadMomentum, ReadPosition, ReadEnergy, ReadWeight, ReadNphot_source |
5 | 5 | from Analytic import Analytic_theta |
6 | +from Map import thetaphi | |
6 | 7 | from Constants import degre |
7 | 8 | |
8 | 9 | Eliminf = 1e0 #GeV |
9 | 10 | Elimsup = 1e5 #GeV |
10 | 11 | |
11 | 12 | def compute_theta(fileName): |
13 | + ''' | |
14 | + Compute arrival angle | |
15 | + Input: directory name | |
16 | + Output: energy, weight, arrival angle | |
17 | + ''' | |
12 | 18 | position = ReadPosition(fileName) |
13 | 19 | momentum = ReadMomentum(fileName) |
14 | 20 | energy = ReadEnergy(fileName) |
... | ... | @@ -29,12 +35,17 @@ def compute_theta(fileName): |
29 | 35 | return energy, weight, theta |
30 | 36 | |
31 | 37 | def angle_vs_energy(fileName): |
38 | + ''' | |
39 | + Compute arrival angle versus energy | |
40 | + Input: directory name | |
41 | + Output: energy, arrival angle | |
42 | + ''' | |
32 | 43 | energy,weight,theta = compute_theta(fileName) |
33 | 44 | nbBins = 40 |
34 | 45 | |
35 | 46 | energy =log10(energy) |
36 | - angle,ener =histogram(energy,nbBins,weights=theta) | |
37 | - nb,ener =histogram(energy,nbBins) | |
47 | + angle,ener =histogram(energy,nbBins,weights=weight*theta) | |
48 | + nb,ener =histogram(energy,nbBins,weights=weight) | |
38 | 49 | ener = 10**ener |
39 | 50 | enercenter=(ener[1:nbBins+1]+ener[0:nbBins])/2 |
40 | 51 | angle = angle/nb |
... | ... | @@ -42,6 +53,11 @@ def angle_vs_energy(fileName): |
42 | 53 | return enercenter, angle |
43 | 54 | |
44 | 55 | def drawAngle(files): |
56 | + ''' | |
57 | + Plot arrival angle versus energy + analytic expression | |
58 | + Input: list of directories | |
59 | + Output: graph of arrival angle versus energy | |
60 | + ''' | |
45 | 61 | fig = figure() |
46 | 62 | gs = gridspec.GridSpec(2, 1, height_ratios=[4,1]) |
47 | 63 | fig.subplots_adjust(hspace=0.001) |
... | ... | @@ -75,31 +91,49 @@ def drawAngle(files): |
75 | 91 | |
76 | 92 | show() |
77 | 93 | |
78 | -def radial(fileName): | |
79 | - nbBins = 20 | |
80 | - energy,weight,theta = compute_theta(fileName) | |
81 | - | |
82 | - dn,angle=histogram(theta**2,nbBins,range=[0,0.25],weights=weight) | |
83 | - thetacenter=(angle[1:nbBins+1]+angle[0:nbBins])/2 | |
84 | - dtheta=angle[1:nbBins+1]-angle[0:nbBins] | |
85 | - dndtheta2=dn/dtheta | |
86 | - maxflux = ReadNphot_source(fileName) | |
87 | - dndtheta2 /= maxflux | |
88 | - | |
89 | - return thetacenter, dndtheta2 | |
90 | - | |
91 | -def drawRadial(files): | |
94 | +############################################################################################## | |
95 | +def radial(fileId,thetamax=90): | |
96 | + ''' | |
97 | + Compute flux versus arrival angle | |
98 | + Input: directory name | |
99 | + Input (optionnal): maximal angle desired (by default full sky) | |
100 | + Output: arrival angle, flux (dn/dtheta) | |
101 | + ''' | |
102 | + nbBins = 50 | |
103 | + energy,weight,theta = compute_theta(fileId) | |
104 | + | |
105 | + theta=log10(theta) | |
106 | + dn,angle = histogram(theta,nbBins,range=[log10(1e-6),log10(thetamax)],weights=weight) | |
107 | + angle=10**angle | |
108 | + thetacenter = (angle[1:nbBins+1]+angle[0:nbBins])/2 | |
109 | + dtheta = angle[1:nbBins+1]-angle[0:nbBins] | |
110 | + dndtheta = dn/dtheta | |
111 | + maxflux = ReadNphot_source(fileId) | |
112 | + dndtheta /= maxflux | |
113 | + | |
114 | + print "integral: ", sum(dtheta*dndtheta) | |
115 | + | |
116 | + return thetacenter, dndtheta | |
117 | + | |
118 | +def drawRadial(files,thetamax=90): | |
119 | + ''' | |
120 | + Plot flux versus arrival angle | |
121 | + Input: list of directories | |
122 | + Input (optionnal): maximal angle desired (by default full sky) | |
123 | + Output: graph of flux versus angle | |
124 | + ''' | |
92 | 125 | fig = figure() |
93 | 126 | ax = fig.add_subplot(111) |
94 | 127 | |
95 | 128 | for fileId in files: |
96 | - theta,dndtheta2=radial(fileId) | |
129 | + theta,dndtheta2=radial(fileId,thetamax) | |
97 | 130 | ax.plot(theta,dndtheta2,drawstyle='steps-mid',label=fileId) |
98 | 131 | |
99 | - ax.legend(loc="best",title="%3d - %3d GeV"%(Eliminf,Elimsup)) | |
132 | + ax.legend(loc="best") | |
133 | + ax.set_xscale('log') | |
100 | 134 | ax.set_yscale('log') |
101 | 135 | ax.grid(b=True,which='major') |
102 | - ax.set_xlabel("$\\theta^2$ [deg$^2$]") | |
103 | - ax.set_ylabel("$dN/d\\theta^2$ [deg$^{-2}$]") | |
136 | + ax.set_xlabel("$\\theta$ [deg]") | |
137 | + ax.set_ylabel("$dN/d\\theta$ [deg$^{-1}$]") | |
104 | 138 | |
105 | 139 | show() | ... | ... |
Modules/Angle.pyc
No preview for this file type
Modules/Constants.pyc
No preview for this file type
Modules/Generation.py
... | ... | @@ -4,6 +4,11 @@ from Read import ReadGeneration, ReadWeight |
4 | 4 | |
5 | 5 | |
6 | 6 | def drawGeneration(files): |
7 | + ''' | |
8 | + Plot histogram of particles'generations | |
9 | + Input: list of directories | |
10 | + Output: histogram of generations | |
11 | + ''' | |
7 | 12 | fig = figure() |
8 | 13 | ax = fig.add_subplot(111) |
9 | 14 | nbBins = 7 | ... | ... |
Modules/Generation.pyc
No preview for this file type
Modules/Map.py
1 | -from numpy import shape, pi, histogram2d, arange, newaxis, exp, log, array | |
1 | +from numpy import shape, pi, histogram2d, arange, newaxis, exp, log, array, sin, cos | |
2 | 2 | from scipy.signal import convolve2d |
3 | 3 | from matplotlib.pyplot import figure, show, matshow |
4 | 4 | from matplotlib.colors import LogNorm |
... | ... | @@ -7,14 +7,21 @@ from Read import ReadD_source, Readz_source, ReadEGMF |
7 | 7 | from Constants import degre |
8 | 8 | |
9 | 9 | thetalim = 180 |
10 | -philim = 90 | |
11 | -step = 1 #deg | |
10 | +philim = 180 | |
11 | +step = 0.25 #deg | |
12 | 12 | nbBins = array([int(2*philim/step)+1,int(2*thetalim/step)+1]) |
13 | 13 | philim=float(philim) |
14 | 14 | thetalim=float(thetalim) |
15 | 15 | limits = [[-thetalim,thetalim],[-philim,philim]] |
16 | 16 | |
17 | 17 | def thetaphi(fileId,Elim=0.1): |
18 | + ''' | |
19 | + Compute arrival angles (theta,phi) selected with energy upper than Elim | |
20 | + normalize to 1 source photon | |
21 | + Input: directory name | |
22 | + Input (optional): lower energy limit in GeV (default = 100MeV) | |
23 | + Output: energy (GeV), theta, phi (degre), weight | |
24 | + ''' | |
18 | 25 | energy = ReadEnergy(fileId) |
19 | 26 | weight = ReadWeight(fileId) |
20 | 27 | thetaDir,phiDir = ReadMomentumAngle(fileId)*degre |
... | ... | @@ -42,7 +49,15 @@ def Gaussian2D(center=[0,0],fwhm=0.01): |
42 | 49 | y = y[:,newaxis] |
43 | 50 | return exp(-4*log(2) * ((x-center[0])**2 + (y+center[1])**2) / fwhm**2) |
44 | 51 | |
45 | -def drawMap(files,Elim=0.1,source=isotrop(),borne=[180,90]): | |
52 | +def drawMap(files,Elim=0.1,source=isotrop(),borne=[180,180]): | |
53 | + ''' | |
54 | + Plot 2D histogram of arrival direction of the photons with energy upper than Elim | |
55 | + Input: list of directories | |
56 | + Input (optional): lower energy limit (in GeV (default = 100MeV) | |
57 | + Input (optional): nature of the source (default isotrop) | |
58 | + Input (optional): limits on theta, phi | |
59 | + Output: 2D histogram of theta cos(phi), theta sin(phi) | |
60 | + ''' | |
46 | 61 | print "Cut at", Elim, "GeV" |
47 | 62 | fig = figure() |
48 | 63 | nbplots = len(files) |
... | ... | @@ -51,7 +66,7 @@ def drawMap(files,Elim=0.1,source=isotrop(),borne=[180,90]): |
51 | 66 | for fileId in files: |
52 | 67 | energy, theta, phi, weight = thetaphi(fileId,Elim) |
53 | 68 | |
54 | - H,xedges,yedges = histogram2d(phi,theta,nbBins,weights=weight,range=limits) | |
69 | + H,xedges,yedges = histogram2d(theta*cos(phi),theta*sin(phi),nbBins,weights=weight,range=limits) | |
55 | 70 | conv=convolve2d(H,source,boundary="wrap",mode="same") |
56 | 71 | |
57 | 72 | ax = fig.add_subplot(100+nbplots*10+ind) |
... | ... | @@ -62,8 +77,8 @@ def drawMap(files,Elim=0.1,source=isotrop(),borne=[180,90]): |
62 | 77 | cbar.ax.set_ylabel("counts normalize to 1 photon emitted") |
63 | 78 | ax.set_xlim((-borne[0],borne[0])) |
64 | 79 | ax.set_ylim((-borne[1],borne[1])) |
65 | - ax.set_xlabel("$\\theta$ [deg]") | |
66 | - ax.set_ylabel("$\\phi$ [deg]") | |
80 | + ax.set_xlabel("$\\theta$ $\\cos(\\phi)$ [deg]") | |
81 | + ax.set_ylabel("$\\theta$ $\\sin(\\phi)$ [deg]") | |
67 | 82 | ax.grid(b=True,which='major') |
68 | 83 | zsource=Readz_source(fileId) |
69 | 84 | Dsource=ReadD_source(fileId) | ... | ... |
Modules/Map.pyc
No preview for this file type
Modules/Spectrum.py
... | ... | @@ -7,6 +7,11 @@ from Read import ReadNphot_source, ReadGeneration |
7 | 7 | from Analytic import Analytic_flux, Ethreshold_gg |
8 | 8 | |
9 | 9 | def spectrum(fileId,gen=-1): |
10 | + ''' | |
11 | + Compute flux versus energy | |
12 | + Input: directory name, generation (optional, by default: all generation) | |
13 | + Output: energy, flux | |
14 | + ''' | |
10 | 15 | energy = ReadEnergy(fileId) |
11 | 16 | weight = ReadWeight(fileId) |
12 | 17 | |
... | ... | @@ -30,12 +35,19 @@ def spectrum(fileId,gen=-1): |
30 | 35 | return enercenter,flux |
31 | 36 | |
32 | 37 | ########################################################################################### |
33 | -def drawSpectrum(files,PlotElmag=False,PlotAnalytic=False): | |
38 | +def drawSpectrum(files,gen=-1,PlotElmag=False,PlotAnalytic=False): | |
39 | + ''' | |
40 | + Plot flux versus energy | |
41 | + Input: list of directories | |
42 | + Input (optional, default=all): selection on the generation | |
43 | + Input (optional, default=False): Plot Elmag spectrum if exists, plot analytic expression | |
44 | + Output: graph spectrum normalize to 1 source photon | |
45 | + ''' | |
34 | 46 | fig = figure() |
35 | 47 | ax = fig.add_subplot(111) |
36 | 48 | |
37 | 49 | for fileId in files: |
38 | - energy,flux = spectrum(fileId) | |
50 | + energy,flux = spectrum(fileId,gen) | |
39 | 51 | if PlotElmag: |
40 | 52 | maxflux = max(flux)*(.8) |
41 | 53 | p=ax.plot(energy,flux,drawstyle='steps-mid',label=fileId) |
... | ... | @@ -47,9 +59,10 @@ def drawSpectrum(files,PlotElmag=False,PlotAnalytic=False): |
47 | 59 | ax.plot(energy,flux,"--",color=p[0].get_color(),label="Elmag - "+fileId) |
48 | 60 | |
49 | 61 | if PlotAnalytic: |
50 | - alpha=2.8e3 | |
62 | + minEner=min(energy) | |
63 | + alpha=flux[energy==minEner]/sqrt(minEner) | |
51 | 64 | ax.plot(energy,alpha*sqrt(energy),'--m',linewidth=2) |
52 | - ax.plot(energy,energy**(0)*max(flux),'--m',linewidth=2) | |
65 | + ax.plot(energy,energy**(0)*max(flux)*0.95,'--m',linewidth=2) | |
53 | 66 | ax.axvline(x=Ethreshold_gg(), ymin=0., ymax = 1., color='r', linewidth=2) |
54 | 67 | |
55 | 68 | ax.set_xscale('log') |
... | ... | @@ -65,6 +78,11 @@ def drawSpectrum(files,PlotElmag=False,PlotAnalytic=False): |
65 | 78 | show() |
66 | 79 | |
67 | 80 | def drawSpectrum_normaLepton(files): |
81 | + ''' | |
82 | + Plot flux versus energy compare with analytic expression | |
83 | + Input: list of directories | |
84 | + Output: graph spectrum normalize to 1 lepton generated | |
85 | + ''' | |
68 | 86 | fig = figure() |
69 | 87 | gs = gridspec.GridSpec(2, 1, height_ratios=[4,1]) |
70 | 88 | fig.subplots_adjust(hspace=0.001) |
... | ... | @@ -101,6 +119,11 @@ def drawSpectrum_normaLepton(files): |
101 | 119 | |
102 | 120 | ######################################################################################## |
103 | 121 | def drawSpectrumGen(fileId): |
122 | + ''' | |
123 | + Plot flux versus energy generation by generation | |
124 | + Input: directory name | |
125 | + Output: graph spectrum normalize to 1 photon source | |
126 | + ''' | |
104 | 127 | fig = figure() |
105 | 128 | ax = fig.add_subplot(111) |
106 | 129 | |
... | ... | @@ -110,8 +133,9 @@ def drawSpectrumGen(fileId): |
110 | 133 | |
111 | 134 | energy,flux = spectrum(fileId) |
112 | 135 | p=ax.plot(energy,flux,drawstyle='steps-mid',color='k',label="gen = all") |
113 | - alpha=2e3 | |
114 | 136 | |
137 | + minEner=min(energy) | |
138 | + alpha=flux[energy==minEner]/sqrt(minEner) | |
115 | 139 | ax.plot(energy,sqrt(energy)*alpha,'--m',linewidth=2) |
116 | 140 | ax.plot(energy,energy**(0)*max(flux),'--m',linewidth=2) |
117 | 141 | ax.axvline(x=Ethreshold_gg(), ymin=0., ymax = 1., color='r', linewidth=2) | ... | ... |
Modules/Spectrum.pyc
No preview for this file type
Modules/Timing.py
1 | -from numpy import histogram, log10, shape | |
1 | +from numpy import histogram, log10, shape, sqrt, arccos | |
2 | 2 | from matplotlib.pyplot import figure, show |
3 | 3 | from scipy.integrate import quad |
4 | -from Read import ReadTime, ReadWeight, Readz_source, ReadNphot_source | |
5 | -from Constants import yr | |
4 | +from Read import ReadTime, ReadWeight, ReadGeneration, ReadE_source, ReadD_source | |
5 | +from Read import ReadNphot_source,ReadPosition,ReadMomentum,ReadNbLeptonsProd | |
6 | +from Constants import yr, degre | |
6 | 7 | from Integrand import comobileTime |
8 | +from Analytic import Analytic_delay | |
7 | 9 | |
8 | -def timing(fileName): | |
9 | - time=ReadTime(fileName) | |
10 | - weight=ReadWeight(fileName) | |
11 | - prop = float(shape(time[time<0])[0])/shape(time)[0] | |
12 | - print "file", fileName, "->", shape(time)[0], "events", "negative time:", shape(time[time<0])[0], "~", prop | |
10 | +def timing(fileId,gen=-1): | |
11 | + ''' | |
12 | + Compute flux versus time delay | |
13 | + Input: directory name | |
14 | + Input (optional): generation (default = all) | |
15 | + Output: time delay (sec), flux | |
16 | + ''' | |
17 | + time=ReadTime(fileId) | |
18 | + weight=ReadWeight(fileId) | |
19 | + | |
20 | + if gen != -1: | |
21 | + generation = ReadGeneration(fileId) | |
22 | + time=time[generation==gen] | |
23 | + weight=weight[generation==gen] | |
24 | + prop = float(shape(time[time<0])[0])/shape(time)[0] | |
25 | + print "gen", int(gen), "->", shape(time)[0], "events", "negative time:",shape(time[time<0])[0], "~", prop | |
26 | + else: | |
27 | + prop = float(shape(time[time<0])[0])/shape(time)[0] | |
28 | + print "file", fileId, "->", shape(time)[0], "events", "negative time:",shape(time[time<0])[0], "~", prop | |
13 | 29 | |
14 | 30 | time=time[time>0] |
15 | 31 | weight=weight[time>0] |
16 | 32 | |
17 | 33 | nbBins = 100 |
18 | - zSource = Readz_source(fileName) | |
19 | - tlim = quad(comobileTime,zSource,0)[0]/yr | |
20 | - time = log10(time/tlim) | |
34 | + time = log10(time*yr) | |
21 | 35 | |
22 | 36 | dN,dt=histogram(time,nbBins,weights=weight) |
23 | 37 | timecenter=(dt[1:nbBins+1]+dt[0:nbBins])/2 |
24 | 38 | binSize=dt[1:nbBins+1]-dt[0:nbBins] |
25 | - Nmax=ReadNphot_source(fileName) # Nb photons emitted by the source | |
39 | + Nmax=ReadNphot_source(fileId) # Nb photons emitted by the source | |
26 | 40 | dNdt=dN/(Nmax*binSize) |
27 | - maxflux = ReadNphot_source(fileName) | |
41 | + maxflux = ReadNphot_source(fileId) | |
28 | 42 | dNdt /= maxflux |
29 | 43 | |
30 | - return timecenter, dNdt | |
44 | + return 10**timecenter, dNdt | |
31 | 45 | |
32 | 46 | def drawTiming(files): |
47 | + ''' | |
48 | + Plot flux versus time delay | |
49 | + Input: list of directories | |
50 | + Output: graph of flux versus time delay | |
51 | + ''' | |
33 | 52 | fig = figure() |
34 | 53 | ax = fig.add_subplot(111) |
35 | 54 | for fileId in files: |
36 | 55 | time,dNdt = timing(fileId) |
37 | 56 | ax.plot(time[dNdt!=0],dNdt[dNdt!=0],linestyle="steps-mid",label=fileId) |
38 | 57 | |
58 | + ax.set_xscale('log') | |
59 | + ax.set_yscale('log') | |
60 | + ax.grid(b=True,which='major') | |
61 | + ax.legend(loc="best") | |
62 | + ax.set_xlabel("Time delay [s]") | |
63 | + ax.set_ylabel("$t\ dN/dt$") | |
64 | + | |
65 | + show() | |
66 | + | |
67 | +def drawTimingGen(fileId): | |
68 | + fig = figure() | |
69 | + ax = fig.add_subplot(111) | |
70 | + for gen in list(set(ReadGeneration(fileId))): | |
71 | + time,dNdt = timing(fileId,gen) | |
72 | + ax.plot(time[dNdt!=0],dNdt[dNdt!=0],linestyle="steps-mid",label="gen="+str(int(gen))) | |
73 | + | |
74 | + time,dNdt = timing(fileId) | |
75 | + ax.plot(time[dNdt!=0],dNdt[dNdt!=0],color='k',linestyle="steps-mid",label="gen=all") | |
76 | + | |
77 | + ax.set_xscale('log') | |
39 | 78 | ax.set_yscale('log') |
40 | 79 | ax.grid(b=True,which='major') |
41 | 80 | ax.legend(loc="best") |
42 | - ax.set_xlabel("Time [$\Delta t / t$ log scale]") | |
81 | + ax.set_xlabel("Time delay [s]") | |
43 | 82 | ax.set_ylabel("$t\ dN/dt$") |
44 | 83 | |
45 | 84 | show() |
85 | + | |
86 | +######## delay versus angle ############### | |
87 | +def delay_vs_angle(fileId,gen=-1): | |
88 | + ''' | |
89 | + Compute time delay versus arrival angle | |
90 | + Input: directory name | |
91 | + Input (optional): generation (default = all) | |
92 | + Output: arrival angle [degre], time delay [sec] | |
93 | + ''' | |
94 | + position = ReadPosition(fileId) | |
95 | + momentum = ReadMomentum(fileId) | |
96 | + weight = ReadWeight(fileId) | |
97 | + time=ReadTime(fileId) | |
98 | + | |
99 | + hyp=sqrt(position[0]**2+position[1]**2+position[2]**2) | |
100 | + position /= hyp | |
101 | + hyp=sqrt(momentum[0]**2+momentum[1]**2+momentum[2]**2) | |
102 | + momentum /= hyp | |
103 | + costheta=position[0]*momentum[0]+position[1]*momentum[1]+position[2]*momentum[2] | |
104 | + | |
105 | + if gen != -1 : | |
106 | + generation = ReadGeneration(fileId) | |
107 | + cond=(abs(costheta)<=1) & (generation==gen) & (time>0) | |
108 | + else: | |
109 | + cond=(abs(costheta)<=1) & (time>0) | |
110 | + | |
111 | + prop = float(shape(time[time<0])[0])/shape(time)[0] | |
112 | + theta = arccos(costheta[cond])*degre | |
113 | + weight= weight[cond] | |
114 | + time=time[cond]*yr | |
115 | + print "gen", int(gen), "->", shape(time)[0], "events", "negative time:",shape(time[time<0])[0], "~", prop | |
116 | + cond=(theta!=0) | |
117 | + return theta[cond], time[cond], weight[cond] | |
118 | + | |
119 | +def delay_vs_angle_histo(fileId,gen=-1): | |
120 | + theta, time, weight = delay_vs_angle(fileId,gen) | |
121 | + nbBins = 100 | |
122 | + | |
123 | + theta=log10(theta) | |
124 | + dt,dtheta=histogram(theta,nbBins,weights=time) | |
125 | + dN,dtheta=histogram(theta,nbBins,weights=weight) | |
126 | + dtheta=10**dtheta | |
127 | + thetacenter=(dtheta[1:nbBins+1]+dtheta[0:nbBins])/2 | |
128 | + timing = dt/dN | |
129 | + | |
130 | + return thetacenter, timing | |
131 | + | |
132 | +def drawDelay_vs_angle(fileId): | |
133 | + ''' | |
134 | + Plot angle versus time delay, generation by generation | |
135 | + Input: directory name | |
136 | + Output: graph of angle versus time delay, generation by generation | |
137 | + ''' | |
138 | + fig = figure() | |
139 | + ax = fig.add_subplot(111) | |
140 | + | |
141 | + Nmax = ReadNphot_source(fileId) | |
142 | + | |
143 | + for gen in list(set(ReadGeneration(fileId))): | |
144 | + angle,delay,weight = delay_vs_angle(fileId,gen) | |
145 | + ax.plot(angle,delay/weight/Nmax,".",label="gen="+str(int(gen))) | |
146 | + | |
147 | + #angle,delay = delay_vs_angle_histo(fileId,gen) | |
148 | + #ax.plot(angle,delay,linestyle="steps-mid",label="gen="+str(int(gen))) | |
149 | + | |
150 | + angle,delay = delay_vs_angle_histo(fileId) | |
151 | + ax.plot(angle,delay/Nmax,color='k',linestyle="steps-mid",label="gen=all") | |
152 | + | |
153 | + Esource = ReadE_source(fileId) | |
154 | + dSource = ReadD_source(fileId) | |
155 | + yfit = Analytic_delay(angle,Esource,dSource) | |
156 | + ax.plot(angle,yfit,'--k',linewidth=2) | |
157 | + | |
158 | + ax.set_xscale('log') | |
159 | + ax.set_yscale('log') | |
160 | + ax.grid(b=True,which='major') | |
161 | + ax.legend(loc="best") | |
162 | + ax.set_xlabel("$\\theta $[deg]") | |
163 | + ax.set_ylabel("Time delay [s]") | |
164 | + | |
165 | + show() | ... | ... |
Modules/Timing.pyc
No preview for this file type
Modules/Weight.py
... | ... | @@ -4,6 +4,11 @@ from Read import ReadGeneration, ReadWeight, ReadEnergy |
4 | 4 | |
5 | 5 | |
6 | 6 | def drawWeightHisto(fileId): |
7 | + ''' | |
8 | + Plot particles'weights histogram, generation by generation | |
9 | + Input: directory name | |
10 | + Output: particles'weights histogram | |
11 | + ''' | |
7 | 12 | fig = figure() |
8 | 13 | ax = fig.add_subplot(111) |
9 | 14 | nbBins =100 |
... | ... | @@ -24,6 +29,11 @@ def drawWeightHisto(fileId): |
24 | 29 | |
25 | 30 | ####################################################################################### |
26 | 31 | def weightVsEnergy(fileId,gen=-1): |
32 | + ''' | |
33 | + Compute particles'weight versus energy | |
34 | + Input: directory name | |
35 | + Input (optional): generation (default = all) | |
36 | + ''' | |
27 | 37 | energy = ReadEnergy(fileId) |
28 | 38 | weight = ReadWeight(fileId) |
29 | 39 | nbBins = 100 |
... | ... | @@ -43,6 +53,11 @@ def weightVsEnergy(fileId,gen=-1): |
43 | 53 | return enercenter, weight |
44 | 54 | |
45 | 55 | def drawWeightVsEnergy(fileId): |
56 | + ''' | |
57 | + Plot particles'weight versus energy, generation by generation | |
58 | + Input: directory name | |
59 | + Output: graph of particles'weight versus energy | |
60 | + ''' | |
46 | 61 | fig = figure() |
47 | 62 | ax = fig.add_subplot(111) |
48 | 63 | ... | ... |
No preview for this file type