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

Add plotting

parent bbacfaba
No related branches found
No related tags found
No related merge requests found
...@@ -18,19 +18,45 @@ Options: ...@@ -18,19 +18,45 @@ Options:
""" """
from collections import deque from collections import deque
import time
import threading
import numpy as np
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
import km3pipe as kp import km3pipe as kp
import km3pipe.style
km3pipe.style.use('km3pipe')
class ZenithDistribution(kp.Module): class ZenithDistribution(kp.Module):
def configure(self): def configure(self):
self.plots_path = self.require('plots_path')
self.max_events = 1000 self.max_events = 1000
self.zeniths = deque(maxlen=1000) self.thetas = deque(maxlen=1000)
self.interval = 60
threading.Thread(target=self.plot).start()
def process(self, blob): def process(self, blob):
print(blob.keys()) track = blob['RecoTrack']
print(blob['RecoTrack']) theta = np.rad2deg(
kp.math.angle_between([0, 0, -1], [track.dx, track.dy, track.dz]))
self.thetas.append(theta)
return blob return blob
def plot(self):
while True:
time.sleep(self.interval)
self.create_plot()
def create_plot(self):
fig, ax = plt.subplots(figsize=(16, 4))
plt.histogram(self.thetas, bins=180)
filename = join(self.plots_path, 'track_reco.png')
plt.savefig(filename, dpi=120, bbox_inches="tight")
plt.close('all')
def main(): def main():
from docopt import docopt from docopt import docopt
...@@ -47,8 +73,7 @@ def main(): ...@@ -47,8 +73,7 @@ def main():
port=ligier_port, port=ligier_port,
tags='IO_OLINE', tags='IO_OLINE',
timeout=60 * 60 * 24 * 7, timeout=60 * 60 * 24 * 7,
max_queue=2000 max_queue=2000)
)
pipe.attach(kp.io.daq.DAQProcessor) pipe.attach(kp.io.daq.DAQProcessor)
pipe.attach(ZenithDistribution, plots_path=plots_path) pipe.attach(ZenithDistribution, plots_path=plots_path)
pipe.drain() pipe.drain()
......
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