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

Improve time residuals plot

parent c9fdb8c6
No related branches found
No related tags found
No related merge requests found
Pipeline #54886 passed
...@@ -21,6 +21,7 @@ import matplotlib ...@@ -21,6 +21,7 @@ import matplotlib
# Force matplotlib to not use any Xwindows backend. # Force matplotlib to not use any Xwindows backend.
matplotlib.use('Agg') matplotlib.use('Agg')
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np import numpy as np
import pandas as pd import pandas as pd
...@@ -28,6 +29,10 @@ import km3pipe as kp ...@@ -28,6 +29,10 @@ import km3pipe as kp
kp.style.use('km3pipe') kp.style.use('km3pipe')
LINE_STYLES = ['solid', 'dashed', 'dashdot', 'dotted']
N_STYLES = len(LINE_STYLES)
def main(): def main():
from docopt import docopt from docopt import docopt
args = docopt(__doc__) args = docopt(__doc__)
...@@ -42,6 +47,12 @@ def main(): ...@@ -42,6 +47,12 @@ def main():
names=["run", "timestamp", "du", "floor", "dom_id", "t_res", "Q"], names=["run", "timestamp", "du", "floor", "dom_id", "t_res", "Q"],
header=1, header=1,
) )
n_dus = len(np.unique(df.du))
n_colors = int(np.ceil(n_dus / N_STYLES))
colors = sns.color_palette('colorblind', n_colors=n_colors)
linestyles = [(c, s) for c in colors for s in LINE_STYLES]
df = df[df.timestamp > time.time() - 60 * 60 * hours] df = df[df.timestamp > time.time() - 60 * 60 * hours]
print(f" -> number of entries: {len(df)}") print(f" -> number of entries: {len(df)}")
...@@ -53,16 +64,20 @@ def main(): ...@@ -53,16 +64,20 @@ def main():
constrained_layout=True) constrained_layout=True)
for ax, floor in zip(axes.flatten(), range(1, 19)): for ax, floor in zip(axes.flatten(), range(1, 19)):
for du in np.unique(df.du): for du, linestyle in zip(sorted(np.unique(df.du)), linestyles):
_df = df[df.du == du] _df = df[df.du == du]
t_res = _df[_df.floor == floor].t_res t_res = _df[_df.floor == floor].t_res
t_res = t_res[np.abs(t_res) < 500] t_res = t_res[np.abs(t_res) < 150]
du = int(du)
print(f" DU {du} floor {floor}: {len(t_res)} entries") print(f" DU {du} floor {floor}: {len(t_res)} entries")
ax.hist(t_res, ax.hist(t_res,
bins=100, bins=60,
histtype='step', histtype='step',
lw=2, lw=2,
label=f'Floor {floor} / DU {du}') label=f'DU {du}',
density=true,
color=linestyle[0],
linestyle=linestyle[1])
ax.legend(loc='upper right') ax.legend(loc='upper right')
if floor > 15: if floor > 15:
ax.set_xlabel('time residual [ns]') ax.set_xlabel('time residual [ns]')
...@@ -70,14 +85,14 @@ def main(): ...@@ -70,14 +85,14 @@ def main():
ax.set_ylabel('count') ax.set_ylabel('count')
ax.set_yscale('log') ax.set_yscale('log')
utc_now = datetime.utcnow().strftime("%c") utc_now = datetime.utcnow().strftime("%c")
fig.suptitle(f"Time residuals using ROy reconstructions " fig.suptitle(f"Time residuals using FibonacciFit reconstructions "
f"from the past {hours} hours - " f"from the past {hours} hours - "
f"{utc_now} UTC\n") f"{utc_now} UTC\n")
plt.savefig(os.path.join(plots_path, 'time_residuals')) plt.savefig(os.path.join(plots_path, 'time_residuals'))
plt.close('all') plt.close('all')
gc.collect() gc.collect()
time.sleep(60) time.sleep(300)
if __name__ == '__main__': if __name__ == '__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