plot.py 2.64 KB
Newer Older
1
2
3
4
5
6
7
import matplotlib.pyplot as plt
import csv

x = []
y_gamma = []
y_mu_minus = []
y_mu_plus = []
8
9
10
11
y_nu_e = []
y_nu_mu = []
y_anti_nu_e = []
y_anti_nu_mu = []
12

13
14
15
16
17
#choose the graphs you want putting true:
gamma_graph= True
mu_graph = True
neutrino_graph = True

18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
with open("gamma.txt", "r") as csvfile:
    plots = csv.reader(csvfile, delimiter=" ")
    for row in plots:
        y_gamma.append(float(row[0]))
        x.append(float(row[1]))

with open("mu+.txt", "r") as csvfile:
    plots = csv.reader(csvfile, delimiter=" ")
    for row in plots:
        y_mu_plus.append(float(row[0]))


with open("mu-.txt", "r") as csvfile:
    plots = csv.reader(csvfile, delimiter=" ")
    for row in plots:
        y_mu_minus.append(float(row[0]))

35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
with open("nu_e.txt", "r") as csvfile:
    plots = csv.reader(csvfile, delimiter=" ")
    for row in plots:
        y_nu_e.append(float(row[0]))

with open("nu_mu.txt", "r") as csvfile:
    plots = csv.reader(csvfile, delimiter=" ")
    for row in plots:
        y_nu_mu.append(float(row[0]))

with open("anti_nu_e.txt", "r") as csvfile:
    plots = csv.reader(csvfile, delimiter=" ")
    for row in plots:
        y_anti_nu_e.append(float(row[0]))

with open("anti_nu_mu.txt", "r") as csvfile:
    plots = csv.reader(csvfile, delimiter=" ")
    for row in plots:
        y_anti_nu_mu.append(float(row[0]))


56

57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
if (gamma_graph):
    #gamma
    plt.scatter(x, y_gamma, s=20)
    plt.title("Geant4 hadronic shower graphs")
    plt.ylabel("Nº gamma")
    plt.xlabel("distance (km)")
    plt.xlim(xmin=0)
    plt.ylim(ymin=0)
    plt.show()

if (mu_graph):
    #muons 
    line1 = plt.scatter(x, y_mu_plus, c='b', label='1', s=20, marker = '^')
    line2 = plt.scatter(x,y_mu_minus, c='r', label='1', s=20)
    plt.title("Geant4 hadronic shower graphs")
    plt.ylabel("Nº muons")
    plt.xlabel("distance (km)")
    plt.xlim(xmin=0)
    plt.ylim(ymin=0)
    plt.legend((line1, line2), ('mu-', 'mu+'))
    plt.show()

if (neutrino_graph):
    #neutrinos
    line1 = plt.scatter(x, y_nu_e, c='b', label='1', s=20)
    line2 = plt.scatter(x,y_anti_nu_e, c='r', label='1', s=20)
    plt.title("Geant4 hadronic shower graphs")
    plt.ylabel("Nº electron neutrinos")
    plt.xlabel("distance (km)")
    plt.xlim(xmin=0)
    plt.ylim(ymin=0)
    plt.legend((line1, line2), ('nu_e', 'anti_nu_e'))
    plt.show()

    line1 = plt.scatter(x, y_nu_mu, c='b', label='1', s=20)
    line2 = plt.scatter(x,y_anti_nu_mu, c='r', label='1', s=20, marker = '^')
    plt.title("Geant4 hadronic shower graphs")
    plt.ylabel("Nº muon neutrinos")
    plt.xlabel("distance (km)")
    plt.xlim(xmin=0)
    plt.ylim(ymin=0)
    plt.legend((line1, line2), ('nu_mu', 'anti_nu_mu'))
    plt.show()