1 | #!/usr/bin/python -itt
|
---|
2 |
|
---|
3 | import sys
|
---|
4 | import numpy as np
|
---|
5 | import rlcompleter
|
---|
6 | import readline
|
---|
7 | readline.parse_and_bind('tab: complete')
|
---|
8 |
|
---|
9 | from readcorsika import read_corsika_file
|
---|
10 | import fact_spline_interpolations as fact_si
|
---|
11 | from Turnable import *
|
---|
12 |
|
---|
13 | absorbtion_coeff = fact_si.interpolate_from_files(
|
---|
14 | fact_si.Wavelength_dependency_description_files )
|
---|
15 |
|
---|
16 | angular_acceptance = fact_si.interpolate_from_files(
|
---|
17 | fact_si.angular_acceptance_files)
|
---|
18 |
|
---|
19 |
|
---|
20 | run = read_corsika_file(sys.argv[1])
|
---|
21 |
|
---|
22 | print "photons = ", run.table.shape[0]
|
---|
23 |
|
---|
24 | wavelength = run.table[:,9]
|
---|
25 | efficiencies = absorbtion_coeff(wavelength)
|
---|
26 | # get uniform randomvalues between 0.0 and 1.0
|
---|
27 | rndm = np.random.rand(wavelength.shape[0])
|
---|
28 |
|
---|
29 | # if the randomvalue is larger than the efficiency, the photon is absorbed
|
---|
30 | # if the randomvalue is smaller, the photon survives
|
---|
31 | run.not_absorbed = run.table[rndm < efficiencies,:]
|
---|
32 |
|
---|
33 | print "photons not absorbed = ", run.not_absorbed.shape[0],
|
---|
34 | print float(run.not_absorbed.shape[0])/run.table.shape[0]*100, "%"
|
---|
35 |
|
---|
36 | distance = np.sqrt((run.not_absorbed[:,0:3]**2).sum(axis=1))
|
---|
37 | run.inside = run.table[distance<210,:]
|
---|
38 |
|
---|
39 | print "photons inside = ", run.inside.shape[0],
|
---|
40 | print float(run.inside.shape[0])/run.not_absorbed.shape[0]*100, "%"
|
---|
41 |
|
---|
42 | tm = run.inside[:,6].mean()
|
---|
43 | pm = run.inside[:,7].mean()
|
---|
44 | print "theta mean = ", tm
|
---|
45 | print " phi mean = ", pm
|
---|
46 | # now I can turn the photons such that the photons come from directly above
|
---|
47 |
|
---|
48 | # lets turn the world around the z-axis, so that phi mean becomes zero.
|
---|
49 | Rphi = make_rotation_matrix( [0,0,1], pm)
|
---|
50 |
|
---|
51 | new_cosines = np.dot( run.inside[:,3:6],Rphi)
|
---|
52 | new_theta = np.arccos(new_cosines[:,2])
|
---|
53 | new_phi = np.arctan2(new_cosines[:,1], new_cosines[:,0])
|
---|
54 |
|
---|
55 | print "new theta mean", new_theta.mean()
|
---|
56 | print "new phi mean", new_phi.mean()
|
---|
57 |
|
---|
58 | # now I think we need to turn around the y-axis
|
---|
59 | Rtheta = make_rotation_matrix( [0,1,0], tm)
|
---|
60 |
|
---|
61 | new_cosines = np.dot( new_cosines,Rtheta)
|
---|
62 | new_theta = np.arccos(new_cosines[:,2])
|
---|
63 | new_phi = np.arctan2(new_cosines[:,1], new_cosines[:,0])
|
---|
64 |
|
---|
65 | print "new theta mean", new_theta.mean()
|
---|
66 | print "new phi mean", new_phi.mean()
|
---|
67 |
|
---|