forked from seinecke/pct-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathangular_resolution_vs_energy.py
72 lines (55 loc) · 2.03 KB
/
angular_resolution_vs_energy.py
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Authors: S. Einecke <sabrina.einecke@adelaide.edu.au>
# K. Brueege <kai.bruegge@tu-dortmund.de>
import click
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import astropy.units as u
from utilities import read_data, make_energy_bins, add_theta
from plotting import plot_percentile
@click.command()
@click.argument('input_file', type=click.Path(exists=True))
@click.option('-o', '--output', type=click.Path(exists=False))
@click.option('-t', '--thresholds', multiple=True, default=0.0)
@click.option('-b', '--bins_number', default=15)
@click.option('--auto_energy', is_flag=True, default=False)
@click.option('--auto_limits', is_flag=True, default=False)
def main(input_file, output, thresholds, bins_number, auto_energy, auto_limits):
df = read_data(input_file)
source_az = df['true_source_az'][0]*u.rad
df = add_theta(df,source_az=source_az.to(u.deg))
if not auto_energy:
e_min = 0.08; e_max = 300.0
else:
e_min = df['energy_range_min'][0]
e_max = df['energy_range_max'][0]
if not thresholds:
thresholds = [0.0]
bins, bin_centers, bin_widths = make_energy_bins(
e_min=e_min * u.TeV,
e_max=e_max * u.TeV,
bins=bins_number,
centering='log'
)
ax = None
for t in thresholds:
x = df[df.gamma_score_mean > t].energy_mean.values
y = df[df.gamma_score_mean > t].theta
ax = plot_percentile(x, y, t, bins, bin_centers, bin_widths, ax=ax)
ref = np.loadtxt('references/South-SST-AngRes.txt')
plt.plot(10**ref[:,0], ref[:,1],
'--', label='SST sub-system', color='silver')
ax.set_xscale('log')
if not auto_limits:
ax.set_xlim([0.5,300])
ax.set_ylim([0,0.5])
ax.set_ylabel('Angular Resolution / deg')
ax.set_xlabel(r'$\mathrm{Reconstructed}\ \mathrm{Energy}\ /\ \mathrm{TeV}$')
ax.legend()
plt.tight_layout()
if output:
plt.savefig(output)
else:
plt.show()
if __name__ == "__main__":
main()