-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_resolutions.py
More file actions
47 lines (42 loc) · 1.62 KB
/
Copy pathplot_resolutions.py
File metadata and controls
47 lines (42 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import numpy
from matplotlib import pyplot as plt
#gaussiana
def gauss(x, norm, mean, sigma):
return norm * numpy.exp(-0.5 * ((x - mean)/sigma )**2)
def res_function(x, a, norm, mean1, sigma1, mean2, sigma2):
return a * gauss(x, norm, mean1, sigma1) + \
(1.-a) * gauss(x, norm, mean2, sigma2)
def plot_resolution(data, *plot_positions, x_grid=None, figname=None, title=None):
"""
"""
positions = data[:, 0]
fig = plt.figure(figname)
if x_grid is None:
x_grid = numpy.linspace(-4., 4., 1000)
fmts = ['--', '-', '-.']
for i, p in enumerate(plot_positions):
_mask = (positions == p)
params = data[_mask][0][2:8]
y = res_function(x_grid, *params)
plt.plot(x_grid, y, fmts[i], label='x=%.2f' % p)
plt.xlabel("$T_{meas} - T_{true}$ [ns]", fontsize=14)
plt.ylabel("a.u.", fontsize=14)
plt.yticks(fontsize=14, rotation=0)
plt.xticks(fontsize=14, rotation=0)
plt.subplots_adjust(bottom = 0.13, left = 0.15)
plt.legend()
if title is not None:
plt.title(title)
return fig
if __name__ == '__main__':
"""
"""
t13_fit_data = numpy.loadtxt('T13_conv.txt', unpack=False)
t23_fit_data = numpy.loadtxt('T23_conv.txt', unpack=False)
plot_positions = (10, 140, 260)
plot_resolution(t13_fit_data, *plot_positions, figname='T13',
title='Funzione di risoluzione $\Delta t_{13}$')
plot_resolution(t23_fit_data, *plot_positions, figname='T23',
title='Funzione di risoluzione $\Delta t_{23}$')
plt.ion()
plt.show()