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

Merge branch '11-rename-jpp-daq' into 'master'

Resolve "Rename jpp -> daq"

Closes #11

See merge request !3
parents 7c13e6df ab1539e0
No related branches found
No related tags found
1 merge request!3Resolve "Rename jpp -> daq"
Pipeline #7678 failed
Unreleased changes
------------------
* Jpp things were renamed to DAQ things (;
* Reading of summary slices is done!
Version 0
......
......@@ -54,7 +54,7 @@ Tutorial
* `Overview of offline files <#overview-of-offline-files>`__
* `Daq files reader <#daq-files-reader>`__
* `DAQ files reader <#daq-files-reader>`__
* `Offline files reader <#offline-file-reader>`__
......@@ -75,7 +75,7 @@ Introduction
Most of km3net data is stored in root files. These root files are either created with `Jpp <https://git.km3net.de/common/jpp>`__ or `aanet <https://git.km3net.de/common/aanet>`__ software. A root file created with
`Jpp <https://git.km3net.de/common/jpp>`__ is often referred to as "a Jpp root file". Similarly, a root file created with `aanet <https://git.km3net.de/common/aanet>`__ is often referred to as "an aanet file". In km3io, an aanet root file will always be reffered to as an ``offline file``, while a Jpp root file will always be referred to as a ``daq file``.
km3io is a Python package that provides a set of classes (``DaqReader`` and ``OfflineReader``) to read both daq root files and offline root files without any dependency to aanet, Jpp or ROOT.
km3io is a Python package that provides a set of classes (``DAQReader`` and ``OfflineReader``) to read both daq root files and offline root files without any dependency to aanet, Jpp or ROOT.
Data in km3io is often returned as a "lazyarray", a "jagged lazyarray" or a `Numpy <https://docs.scipy.org/doc/numpy>`__ array. A lazyarray is an array-like object that reads data on demand! In a lazyarray, only the first and the last chunks of data are read in memory. A lazyarray can be used with all Numpy's universal `functions <https://docs.scipy.org/doc/numpy/reference/ufuncs.html>`__. Here is how a lazyarray looks like:
......@@ -101,7 +101,7 @@ Overview of offline files
# info needed here
Daq files reader
DAQ files reader
----------------
# an update is needed here?
......@@ -115,7 +115,7 @@ To get a lazy ragged array of the events:
.. code-block:: python3
import km3io as ki
events = ki.JppReader("KM3NeT_00000044_00005404.root").events
events = ki.DAQReader("KM3NeT_00000044_00005404.root").events
That's it! Now let's have a look at the hits data:
......
"""
Reading DAQ Data (Jpp)
======================
Reading DAQ Data
================
The following example shows how to access hits in a ROOT file which is coming
from the detector and written by the `JDataWriter` application.
Such a file is usually called "KM3NET_00000001_00000002.root", where the first
number is the detector ID and the second the run number.
"""
import km3io
......@@ -13,7 +16,7 @@ import km3io
# Just pass a filename to the reader class and get access to the event tree
# with:
events = km3io.JppReader("samples/jpp_v12.0.0.root").events
f = km3io.DAQReader("samples/jpp_v12.0.0.root")
#####################################################
# Note that only some meta information is read into memory.
......@@ -21,4 +24,4 @@ events = km3io.JppReader("samples/jpp_v12.0.0.root").events
# Printing it will simply tell you how many events it has found. Again, nothing
# else is read yet:
print(events)
print(f.events)
......@@ -2,4 +2,4 @@ from .__version__ import version
__version__ = version
from .aanet import OfflineReader
from .jpp import JppReader
from .daq import DAQReader
......@@ -23,8 +23,8 @@ def get_rate(value):
return MINIMAL_RATE_HZ * np.exp(value * RATE_FACTOR)
class JppReader:
"""Reader for Jpp ROOT files"""
class DAQReader:
"""Reader for DAQ ROOT files"""
def __init__(self, filename):
self.fobj = uproot.open(filename)
self._events = None
......@@ -51,13 +51,13 @@ class JppReader:
(" cnt", "u4"), (" vers", "u2"),
("trigger_mask", "u8")])),
skipbytes=10))
self._events = JppEvents(headers, snapshot_hits, triggered_hits)
self._events = DAQEvents(headers, snapshot_hits, triggered_hits)
return self._events
@property
def timeslices(self):
if self._timeslices is None:
self._timeslices = JppTimeslices(self.fobj)
self._timeslices = DAQTimeslices(self.fobj)
return self._timeslices
@property
......@@ -115,8 +115,8 @@ class SummmarySlices:
cntvers=True))
class JppTimeslices:
"""A simple wrapper for Jpp timeslices"""
class DAQTimeslices:
"""A simple wrapper for DAQ timeslices"""
def __init__(self, fobj):
self.fobj = fobj
self._timeslices = {}
......@@ -157,7 +157,7 @@ class JppTimeslices:
def stream(self, stream, idx):
ts = self._timeslices[stream]
return JppTimeslice(*ts, idx, stream)
return DAQTimeslice(*ts, idx, stream)
def __str__(self):
return "Available timeslice streams: {}".format(', '.join(
......@@ -167,8 +167,8 @@ class JppTimeslices:
return str(self)
class JppTimeslice:
"""A wrapper for a Jpp timeslice"""
class DAQTimeslice:
"""A wrapper for a DAQ timeslice"""
def __init__(self, header, superframe, hits_buffer, idx, stream):
self.header = header
self._frames = {}
......@@ -212,15 +212,15 @@ class JppTimeslice:
len(self.header))
class JppEvents:
"""A simple wrapper for Jpp events"""
class DAQEvents:
"""A simple wrapper for DAQ events"""
def __init__(self, headers, snapshot_hits, triggered_hits):
self.headers = headers
self.snapshot_hits = snapshot_hits
self.triggered_hits = triggered_hits
def __getitem__(self, item):
return JppEvent(self.headers[item], self.snapshot_hits[item],
return DAQEvent(self.headers[item], self.snapshot_hits[item],
self.triggered_hits[item])
def __len__(self):
......@@ -233,15 +233,15 @@ class JppEvents:
return str(self)
class JppEvent:
"""A wrapper for a Jpp event"""
class DAQEvent:
"""A wrapper for a DAQ event"""
def __init__(self, header, snapshot_hits, triggered_hits):
self.header = header
self.snapshot_hits = snapshot_hits
self.triggered_hits = triggered_hits
def __str__(self):
return "Jpp event with {} snapshot hits and {} triggered hits".format(
return "DAQ event with {} snapshot hits and {} triggered hits".format(
len(self.snapshot_hits), len(self.triggered_hits))
def __repr__(self):
......
File moved
......@@ -2,15 +2,15 @@ import os
import re
import unittest
from km3io import JppReader
from km3io import DAQReader
SAMPLES_DIR = os.path.join(os.path.dirname(__file__), "samples")
class TestJppEvents(unittest.TestCase):
class TestDAQEvents(unittest.TestCase):
def setUp(self):
self.events = JppReader(os.path.join(SAMPLES_DIR,
"jpp_v12.0.0.root")).events
self.events = DAQReader(os.path.join(SAMPLES_DIR,
"daq_v1.0.0.root")).events
def test_index_lookup(self):
assert 3 == len(self.events)
......@@ -22,10 +22,10 @@ class TestJppEvents(unittest.TestCase):
assert re.match(".*events.*3", self.events.__repr__())
class TestJppEvent(unittest.TestCase):
class TestDAQEvent(unittest.TestCase):
def setUp(self):
self.event = JppReader(os.path.join(SAMPLES_DIR,
"jpp_v12.0.0.root")).events[0]
self.event = DAQReader(os.path.join(SAMPLES_DIR,
"daq_v1.0.0.root")).events[0]
def test_str(self):
assert re.match(".*event.*96.*snapshot.*18.*triggered",
......@@ -36,10 +36,10 @@ class TestJppEvent(unittest.TestCase):
self.event.__repr__())
class TestJppEventsSnapshotHits(unittest.TestCase):
class TestDAQEventsSnapshotHits(unittest.TestCase):
def setUp(self):
self.events = JppReader(os.path.join(SAMPLES_DIR,
"jpp_v12.0.0.root")).events
self.events = DAQReader(os.path.join(SAMPLES_DIR,
"daq_v1.0.0.root")).events
self.lengths = {0: 96, 1: 124, -1: 78}
self.total_item_count = 298
......@@ -75,10 +75,10 @@ class TestJppEventsSnapshotHits(unittest.TestCase):
assert all(c < 31 for c in hits.channel_id.max())
class TestJppEventsTriggeredHits(unittest.TestCase):
class TestDAQEventsTriggeredHits(unittest.TestCase):
def setUp(self):
self.events = JppReader(os.path.join(SAMPLES_DIR,
"jpp_v12.0.0.root")).events
self.events = DAQReader(os.path.join(SAMPLES_DIR,
"daq_v1.0.0.root")).events
self.lengths = {0: 18, 1: 53, -1: 9}
self.total_item_count = 80
......@@ -116,10 +116,10 @@ class TestJppEventsTriggeredHits(unittest.TestCase):
assert all(c < 31 for c in hits.channel_id.max())
class TestJppTimeslices(unittest.TestCase):
class TestDAQTimeslices(unittest.TestCase):
def setUp(self):
self.ts = JppReader(os.path.join(SAMPLES_DIR,
"jpp_v12.0.0.root")).timeslices
self.ts = DAQReader(os.path.join(SAMPLES_DIR,
"daq_v1.0.0.root")).timeslices
def test_data_lengths(self):
assert 3 == len(self.ts._timeslices["default"][0])
......@@ -140,10 +140,10 @@ class TestJppTimeslices(unittest.TestCase):
assert "SN" in s
class TestJppTimeslice(unittest.TestCase):
class TestDAQTimeslice(unittest.TestCase):
def setUp(self):
self.ts = JppReader(os.path.join(SAMPLES_DIR,
"jpp_v12.0.0.root")).timeslices
self.ts = DAQReader(os.path.join(SAMPLES_DIR,
"daq_v1.0.0.root")).timeslices
self.n_frames = {"L1": [69, 69, 69], "SN": [64, 66, 68]}
def test_str(self):
......@@ -156,8 +156,8 @@ class TestJppTimeslice(unittest.TestCase):
class TestSummaryslices(unittest.TestCase):
def setUp(self):
self.ss = JppReader(os.path.join(SAMPLES_DIR,
"jpp_v12.0.0.root")).summaryslices
self.ss = DAQReader(os.path.join(SAMPLES_DIR,
"daq_v1.0.0.root")).summaryslices
def test_headers(self):
assert 3 == len(self.ss.headers)
......
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