Blame view

Map_arrival.py 2.52 KB
b5217158   Thomas Fitoussi   Python scripts to...
1
2
3
#!/usr/bin/python

from sys import argv
e4ba931e   Thomas Fitoussi   Corrections:
4
from numpy import *
b5217158   Thomas Fitoussi   Python scripts to...
5
import matplotlib.pyplot as plt
a05caa75   Thomas Fitoussi   Add 2d-histogram ...
6
from matplotlib.colors import LogNorm
b5217158   Thomas Fitoussi   Python scripts to...
7
8
9
10
11
12
13
14
from mpl_toolkits.mplot3d.axes3d import Axes3D

if len(argv)<2:
   print "Please give at least 1 file id \n For example: 14 for Results.EGMF14 \n or 14 15 for EGMF14 and EGMF15"
   exit()

# figure: position of the arriving particles in space -> size circle = energy
#=============================================================================
a05caa75   Thomas Fitoussi   Add 2d-histogram ...
15
nbBins = 100
e4ba931e   Thomas Fitoussi   Corrections:
16
degre= 180/pi
b5217158   Thomas Fitoussi   Python scripts to...
17
borne=5 # degree
a05caa75   Thomas Fitoussi   Add 2d-histogram ...
18
Elim=1e-1 # GeV
b5217158   Thomas Fitoussi   Python scripts to...
19

e4ba931e   Thomas Fitoussi   Corrections:
20
fig = plt.figure()
b5217158   Thomas Fitoussi   Python scripts to...
21
22
23
24

nbplots = len(argv)-1
ind = 1
for fileId in argv[1:]:
e4ba931e   Thomas Fitoussi   Corrections:
25
26
27
   energy,thetaDir,phiDir = loadtxt("Results_EGMF"+fileId+"/Results_momentum",unpack=True,usecols=[0,4,5])
   thetaPos,phiPos = loadtxt("Results_EGMF"+fileId+"/Results_position",unpack=True,usecols=[4,5])
   charge,weight= loadtxt("Results_EGMF"+fileId+"/Results_extra",unpack=True,usecols=[0,2])
b5217158   Thomas Fitoussi   Python scripts to...
28

a05caa75   Thomas Fitoussi   Add 2d-histogram ...
29
30
31
32
   thetaPos = thetaPos*degre
   phiPos = phiPos*degre
   thetaDir = thetaDir*degre
   phiDir = phiDir*degre
b5217158   Thomas Fitoussi   Python scripts to...
33
34
35
   theta = thetaDir - thetaPos
   phi = phiDir -phiPos

a05caa75   Thomas Fitoussi   Add 2d-histogram ...
36
37
38
39
40
   cond=(energy>Elim) & (abs(theta)<borne) & (abs(phi)<borne)
   Energy = energy[cond]
   weight=weight[cond]
   theta=theta[cond]
   phi=phi[cond]
b5217158   Thomas Fitoussi   Python scripts to...
41

e4ba931e   Thomas Fitoussi   Corrections:
42
43
   print "Cut at", Elim, "GeV:", fileId, "->", shape(Energy)[0], "particles"
   plotid = 100+nbplots*10+ind
b5217158   Thomas Fitoussi   Python scripts to...
44

e4ba931e   Thomas Fitoussi   Corrections:
45
46
47
48
   #Emax = max(Energy)
   #Emin = min(Energy)
   #area = pi * (15 * Energy/Emax)**2 +15
   #colors = Energy/Emax
a05caa75   Thomas Fitoussi   Add 2d-histogram ...
49

e4ba931e   Thomas Fitoussi   Corrections:
50
   #ax = fig.add_subplot(plotid)
a05caa75   Thomas Fitoussi   Add 2d-histogram ...
51
52
53
54
55
56
57
58
59
60
61
62
63
64
   #sax = ax.scatter(theta, phi, s=area, c=colors, alpha=0.3, marker='o')
   #ax.set_xlim((-borne,borne))
   #ax.set_ylim((-borne,borne))
   #ax.set_xlabel("$\\theta$ in degree")
   #ax.set_ylabel("$\\phi$ in degree")
   #ax.set_title("EGMF: $10^{-%.0f"%float(fileId)+"}$Gauss")
 
   #if Emin < 1e-3:
   #   liminf = "%.0f"%(Emin*1e6)+"keV"
   #elif Emin < 1:
   #   liminf = "%.0f"%(Emin*1e3)+"MeV"
   #else: 
   #   liminf = "%.0f"%(Emin)+"GeV"
   #limsup = "%.0f"%(Emax*1e-3)+"TeV"
e4ba931e   Thomas Fitoussi   Corrections:
65
   #cbar = fig.colorbar(sax, ticks=[0.01,1])
a05caa75   Thomas Fitoussi   Add 2d-histogram ...
66
67
68
69
   #cbar.ax.set_yticklabels([liminf,limsup])
   
   ###########################################

e4ba931e   Thomas Fitoussi   Corrections:
70
71
   ax = fig.add_subplot(plotid)
   H,xedges,yedges,im = ax.hist2d(theta,phi,nbBins,weights=weight/shape(weight),norm=LogNorm())
a05caa75   Thomas Fitoussi   Add 2d-histogram ...
72
   extent = [yedges[0], yedges[-1], xedges[0], xedges[-1]]
e4ba931e   Thomas Fitoussi   Corrections:
73
   cbar=fig.colorbar(im, ax=ax)
a05caa75   Thomas Fitoussi   Add 2d-histogram ...
74
   cbar.ax.set_ylabel("counts")
b5217158   Thomas Fitoussi   Python scripts to...
75
76
77
78
79
   ax.set_xlim((-borne,borne))
   ax.set_ylim((-borne,borne))
   ax.set_xlabel("$\\theta$ in degree")
   ax.set_ylabel("$\\phi$ in degree")
   ax.set_title("EGMF: $10^{-%.0f"%float(fileId)+"}$Gauss")
a05caa75   Thomas Fitoussi   Add 2d-histogram ...
80
 
b5217158   Thomas Fitoussi   Python scripts to...
81
82
83
   ind=ind+1

plt.show()