Newer
Older
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
#!/usr/bin/env python
# coding=utf-8
# vim: ts=4 sw=4 et
"""
Creates time residuals plots.
Usage:
time_residuals.py [options] TIME_RESIDUALS_FILE
time_residuals.py (-h | --help)
Options:
-o PLOT_DIR The directory to save the plot [default: plots].
-h --help Show this screen.
"""
import os
from datetime import datetime
import time
import matplotlib
# Force matplotlib to not use any Xwindows backend.
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import km3pipe as kp
kp.style.use('km3pipe')
def main():
from docopt import docopt
args = docopt(__doc__)
plots_path = args['-o']
hours = 2
while True:
df = df[df.timestamp > time.time() - 60 * 60 * hours]
fig, axes = plt.subplots(nrows=6,
ncols=3,
figsize=(16, 10),
sharex=True,
constrained_layout=True)
for ax, floor in zip(axes.flatten(), range(1, 19)):
for du in np.unique(df.du):
_df = df[df.du == du]
t_res = _df[_df.floor == floor].t_res
ax.hist(-t_res,
bins=100,
histtype='step',
lw=2,
label=f'Floor {floor} / DU {du}')
ax.legend(loc='upper right')
if floor > 15:
ax.set_xlabel('time residual [ns]')
if floor % 3 == 1:
ax.set_ylabel('count')
ax.set_yscale('log')
utc_now = datetime.utcnow().strftime("%c")
fig.suptitle(f"Time residuals using ROy reconstructions "
f"from the past {hours} hours - "
f"{utc_now} UTC\n")
plt.savefig(os.path.join(plots_path, 'time_residuals'))
plt.close('all')
time.sleep(60)
if __name__ == '__main__':
main()