Skip to content
Snippets Groups Projects
Commit fb58052d authored by Tamas Gal's avatar Tamas Gal :speech_balloon:
Browse files

Add time_residuals plotter

parent f5a6f34a
No related branches found
No related tags found
No related merge requests found
#!/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 = pd.read_csv(
args['TIME_RESIDUALS_FILE'],
names=['run', 'timestamp', 'du', 'floor', 'dom_id', 't_res', 'Q'])
df = df[df.timestamp > time.time() - 60 * 60 * hours]
fig, axes = plt.subplots(nrows=6,
ncols=3,
figsize=(16, 10),
sharex=True,
sharey=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()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment