Commit a05caa75b3b2b07876b526f4900969820dcc6365
1 parent
ab1642d3
Exists in
master
Add 2d-histogram to arrival direction
- count vs theta and phi
Showing
3 changed files
with
46 additions
and
48 deletions
Show diff stats
Arrival_direction.py
@@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
3 | from sys import argv | 3 | from sys import argv |
4 | import numpy as np | 4 | import numpy as np |
5 | import matplotlib.pyplot as plt | 5 | import matplotlib.pyplot as plt |
6 | +from matplotlib.colors import LogNorm | ||
6 | from mpl_toolkits.mplot3d.axes3d import Axes3D | 7 | from mpl_toolkits.mplot3d.axes3d import Axes3D |
7 | 8 | ||
8 | if len(argv)<2: | 9 | if len(argv)<2: |
@@ -11,77 +12,73 @@ if len(argv)<2: | @@ -11,77 +12,73 @@ if len(argv)<2: | ||
11 | 12 | ||
12 | # figure: position of the arriving particles in space -> size circle = energy | 13 | # figure: position of the arriving particles in space -> size circle = energy |
13 | #============================================================================= | 14 | #============================================================================= |
14 | -nbBins = 50 | 15 | +nbBins = 100 |
15 | degre= 180/np.pi | 16 | degre= 180/np.pi |
16 | borne=5 # degree | 17 | borne=5 # degree |
17 | -Elim=1e-6 # GeV | 18 | +Elim=1e-1 # GeV |
18 | 19 | ||
19 | -fig = plt.figure() | 20 | +fig1 = plt.figure() |
21 | +fig2 = plt.figure() | ||
20 | 22 | ||
21 | nbplots = len(argv)-1 | 23 | nbplots = len(argv)-1 |
22 | ind = 1 | 24 | ind = 1 |
23 | for fileId in argv[1:]: | 25 | for fileId in argv[1:]: |
24 | energy,thetaDir,phiDir = np.loadtxt("Results_EGMF"+fileId+"/Results_momentum",unpack=True,usecols=[0,4,5]) | 26 | energy,thetaDir,phiDir = np.loadtxt("Results_EGMF"+fileId+"/Results_momentum",unpack=True,usecols=[0,4,5]) |
25 | thetaPos,phiPos = np.loadtxt("Results_EGMF"+fileId+"/Results_position",unpack=True,usecols=[4,5]) | 27 | thetaPos,phiPos = np.loadtxt("Results_EGMF"+fileId+"/Results_position",unpack=True,usecols=[4,5]) |
28 | + charge,weight=np.loadtxt("Results_EGMF"+fileId+"/Results_extra",unpack=True,usecols=[0,2]) | ||
26 | 29 | ||
27 | - plotid = 100+nbplots*10+ind | ||
28 | - ax = fig.add_subplot(plotid) | ||
29 | - | ||
30 | - Energy = energy[energy>Elim] | ||
31 | - print "Cut at", Elim, "GeV:", np.shape(Energy) | ||
32 | - thetaPos = thetaPos[energy>Elim]*degre | ||
33 | - phiPos = phiPos[energy>Elim]*degre | ||
34 | - thetaDir = thetaDir[energy>Elim]*degre | ||
35 | - phiDir = phiDir[energy>Elim]*degre | 30 | + thetaPos = thetaPos*degre |
31 | + phiPos = phiPos*degre | ||
32 | + thetaDir = thetaDir*degre | ||
33 | + phiDir = phiDir*degre | ||
36 | theta = thetaDir - thetaPos | 34 | theta = thetaDir - thetaPos |
37 | phi = phiDir -phiPos | 35 | phi = phiDir -phiPos |
38 | 36 | ||
39 | - ## random position of the detector | ||
40 | - #a=np.random.rand(2,1) | ||
41 | - #w=a[0,0]*2.-1. | ||
42 | - #u=np.sqrt(1-w*w)*np.cos(2*np.pi*a[1,0]) | ||
43 | - #v=np.sqrt(1.-w*w)*np.sin(2.*np.pi*a[1,0]) | ||
44 | - ## 2D -> use only u and v | ||
45 | - #theta_detector = u*180 #degre | ||
46 | - #phi_detector = v*90 #degre | 37 | + cond=(energy>Elim) & (abs(theta)<borne) & (abs(phi)<borne) |
38 | + Energy = energy[cond] | ||
39 | + weight=weight[cond] | ||
40 | + theta=theta[cond] | ||
41 | + phi=phi[cond] | ||
47 | 42 | ||
48 | - #FOV = 0.1 #degre | ||
49 | - | ||
50 | - #energy = energy[energy>Elim | ||
51 | - # and np.absolute(theta-theta_detector)<FOV | ||
52 | - # and np.absolute(phi-phi_detector)<FOV] | ||
53 | - #print "Cut at", Elim, "GeV:", np.shape(Energy) | ||
54 | - #theta = theta_detector - theta[energy>Elim | ||
55 | - # and np.absolute(theta-theta_detector)<FOV | ||
56 | - # and np.absolute(phi-phi_detector)<FOV] | ||
57 | - #phi = phi_detector - phi[energy>Elim | ||
58 | - # and np.absolute(theta-theta_detector)<FOV | ||
59 | - # and np.absolute(phi-phi_detector)<FOV] | ||
60 | - #Energy=np.append((Energy,energy),axis=1) | ||
61 | - #Theta=np.append((Theta,theta),axis=1) | ||
62 | - #Phi=np.append((Phi,phi),axis=1) | 43 | + print "Cut at", Elim, "GeV:", np.shape(Energy) |
63 | 44 | ||
64 | Emax = max(Energy) | 45 | Emax = max(Energy) |
65 | Emin = min(Energy) | 46 | Emin = min(Energy) |
66 | area = np.pi * (15 * Energy/Emax)**2 +15 | 47 | area = np.pi * (15 * Energy/Emax)**2 +15 |
67 | colors = Energy/Emax | 48 | colors = Energy/Emax |
68 | - sax = ax.scatter(theta, phi, s=area, c=colors, alpha=0.3, marker='o') | 49 | + |
50 | + plotid = 100+nbplots*10+ind | ||
51 | + #ax = fig1.add_subplot(plotid) | ||
52 | + #sax = ax.scatter(theta, phi, s=area, c=colors, alpha=0.3, marker='o') | ||
53 | + #ax.set_xlim((-borne,borne)) | ||
54 | + #ax.set_ylim((-borne,borne)) | ||
55 | + #ax.set_xlabel("$\\theta$ in degree") | ||
56 | + #ax.set_ylabel("$\\phi$ in degree") | ||
57 | + #ax.set_title("EGMF: $10^{-%.0f"%float(fileId)+"}$Gauss") | ||
58 | + | ||
59 | + #if Emin < 1e-3: | ||
60 | + # liminf = "%.0f"%(Emin*1e6)+"keV" | ||
61 | + #elif Emin < 1: | ||
62 | + # liminf = "%.0f"%(Emin*1e3)+"MeV" | ||
63 | + #else: | ||
64 | + # liminf = "%.0f"%(Emin)+"GeV" | ||
65 | + #limsup = "%.0f"%(Emax*1e-3)+"TeV" | ||
66 | + #cbar = fig1.colorbar(sax, ticks=[0.01,1]) | ||
67 | + #cbar.ax.set_yticklabels([liminf,limsup]) | ||
68 | + | ||
69 | + ########################################### | ||
70 | + | ||
71 | + ax = fig2.add_subplot(plotid) | ||
72 | + H,xedges,yedges,im = ax.hist2d(theta,phi,nbBins,weights=weight,norm=LogNorm()) | ||
73 | + extent = [yedges[0], yedges[-1], xedges[0], xedges[-1]] | ||
74 | + cbar=fig2.colorbar(im, ax=ax) | ||
75 | + cbar.ax.set_ylabel("counts") | ||
69 | ax.set_xlim((-borne,borne)) | 76 | ax.set_xlim((-borne,borne)) |
70 | ax.set_ylim((-borne,borne)) | 77 | ax.set_ylim((-borne,borne)) |
71 | ax.set_xlabel("$\\theta$ in degree") | 78 | ax.set_xlabel("$\\theta$ in degree") |
72 | ax.set_ylabel("$\\phi$ in degree") | 79 | ax.set_ylabel("$\\phi$ in degree") |
73 | ax.set_title("EGMF: $10^{-%.0f"%float(fileId)+"}$Gauss") | 80 | ax.set_title("EGMF: $10^{-%.0f"%float(fileId)+"}$Gauss") |
74 | - | ||
75 | - if Emin < 1e-3: | ||
76 | - liminf = "%.0f"%(Emin*1e6)+"keV" | ||
77 | - elif Emin < 1: | ||
78 | - liminf = "%.0f"%(Emin*1e3)+"MeV" | ||
79 | - else: | ||
80 | - liminf = "%.0f"%(Emin)+"GeV" | ||
81 | - limsup = "%.0f"%(Emax*1e-3)+"TeV" | ||
82 | - cbar = fig.colorbar(sax, ticks=[0.01,1]) | ||
83 | - cbar.ax.set_yticklabels([liminf,limsup]) | ||
84 | - | 81 | + |
85 | ind=ind+1 | 82 | ind=ind+1 |
86 | 83 | ||
87 | plt.show() | 84 | plt.show() |
Constantes.py
@@ -15,7 +15,7 @@ lambdaC=hb/(m*c) | @@ -15,7 +15,7 @@ lambdaC=hb/(m*c) | ||
15 | Mpc=(3.0856776e+16)*1e8 # Mpc to cm | 15 | Mpc=(3.0856776e+16)*1e8 # Mpc to cm |
16 | erg_to_GeV=1/(1.602176565e-3) | 16 | erg_to_GeV=1/(1.602176565e-3) |
17 | degre=180/pi | 17 | degre=180/pi |
18 | -s_to_yr=3600*24*365.25 | 18 | +yr=3600*24*365.25 # s |
19 | 19 | ||
20 | # Cosmology | 20 | # Cosmology |
21 | a0=1. | 21 | a0=1. |
@@ -51,6 +51,7 @@ lambda_B=0.3 #Mpc | @@ -51,6 +51,7 @@ lambda_B=0.3 #Mpc | ||
51 | Dic= 3*(me*1e-6)**2/(4*sigmaT*rhoCMB*1e-9*Ee) /Mpc #Mpc | 51 | Dic= 3*(me*1e-6)**2/(4*sigmaT*rhoCMB*1e-9*Ee) /Mpc #Mpc |
52 | lambdaIC=1/(nCMB*sigmaT*Mpc) #Mpc | 52 | lambdaIC=1/(nCMB*sigmaT*Mpc) #Mpc |
53 | Eic= 4*Ecmb*Ee**2/(3*me**2)*1e3 #GeV | 53 | Eic= 4*Ecmb*Ee**2/(3*me**2)*1e3 #GeV |
54 | +tIC=lambdaIC/(c*yr/Mpc) #yr | ||
54 | 55 | ||
55 | # Larmor radius | 56 | # Larmor radius |
56 | RL=(Ee/erg_to_GeV)/(e*B) /Mpc #Mpc | 57 | RL=(Ee/erg_to_GeV)/(e*B) /Mpc #Mpc |
Constantes.pyc
No preview for this file type