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

Resolve "Rename jpp -> daq"

parent 7c13e6df
No related branches found
No related tags found
No related merge requests found
Unreleased changes Unreleased changes
------------------ ------------------
* Jpp things were renamed to DAQ things (;
* Reading of summary slices is done! * Reading of summary slices is done!
Version 0 Version 0
......
...@@ -54,7 +54,7 @@ Tutorial ...@@ -54,7 +54,7 @@ Tutorial
* `Overview of offline files <#overview-of-offline-files>`__ * `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>`__ * `Offline files reader <#offline-file-reader>`__
...@@ -75,7 +75,7 @@ Introduction ...@@ -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 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``. `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: 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 ...@@ -101,7 +101,7 @@ Overview of offline files
# info needed here # info needed here
Daq files reader DAQ files reader
---------------- ----------------
# an update is needed here? # an update is needed here?
...@@ -115,7 +115,7 @@ To get a lazy ragged array of the events: ...@@ -115,7 +115,7 @@ To get a lazy ragged array of the events:
.. code-block:: python3 .. code-block:: python3
import km3io as ki 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: 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 The following example shows how to access hits in a ROOT file which is coming
from the detector and written by the `JDataWriter` application. 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 import km3io
...@@ -13,7 +16,7 @@ import km3io ...@@ -13,7 +16,7 @@ import km3io
# Just pass a filename to the reader class and get access to the event tree # Just pass a filename to the reader class and get access to the event tree
# with: # 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. # Note that only some meta information is read into memory.
...@@ -21,4 +24,4 @@ events = km3io.JppReader("samples/jpp_v12.0.0.root").events ...@@ -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 # Printing it will simply tell you how many events it has found. Again, nothing
# else is read yet: # else is read yet:
print(events) print(f.events)
...@@ -2,4 +2,4 @@ from .__version__ import version ...@@ -2,4 +2,4 @@ from .__version__ import version
__version__ = version __version__ = version
from .aanet import OfflineReader from .aanet import OfflineReader
from .jpp import JppReader from .daq import DAQReader
...@@ -23,8 +23,8 @@ def get_rate(value): ...@@ -23,8 +23,8 @@ def get_rate(value):
return MINIMAL_RATE_HZ * np.exp(value * RATE_FACTOR) return MINIMAL_RATE_HZ * np.exp(value * RATE_FACTOR)
class JppReader: class DAQReader:
"""Reader for Jpp ROOT files""" """Reader for DAQ ROOT files"""
def __init__(self, filename): def __init__(self, filename):
self.fobj = uproot.open(filename) self.fobj = uproot.open(filename)
self._events = None self._events = None
...@@ -51,13 +51,13 @@ class JppReader: ...@@ -51,13 +51,13 @@ class JppReader:
(" cnt", "u4"), (" vers", "u2"), (" cnt", "u4"), (" vers", "u2"),
("trigger_mask", "u8")])), ("trigger_mask", "u8")])),
skipbytes=10)) skipbytes=10))
self._events = JppEvents(headers, snapshot_hits, triggered_hits) self._events = DAQEvents(headers, snapshot_hits, triggered_hits)
return self._events return self._events
@property @property
def timeslices(self): def timeslices(self):
if self._timeslices is None: if self._timeslices is None:
self._timeslices = JppTimeslices(self.fobj) self._timeslices = DAQTimeslices(self.fobj)
return self._timeslices return self._timeslices
@property @property
...@@ -115,8 +115,8 @@ class SummmarySlices: ...@@ -115,8 +115,8 @@ class SummmarySlices:
cntvers=True)) cntvers=True))
class JppTimeslices: class DAQTimeslices:
"""A simple wrapper for Jpp timeslices""" """A simple wrapper for DAQ timeslices"""
def __init__(self, fobj): def __init__(self, fobj):
self.fobj = fobj self.fobj = fobj
self._timeslices = {} self._timeslices = {}
...@@ -157,7 +157,7 @@ class JppTimeslices: ...@@ -157,7 +157,7 @@ class JppTimeslices:
def stream(self, stream, idx): def stream(self, stream, idx):
ts = self._timeslices[stream] ts = self._timeslices[stream]
return JppTimeslice(*ts, idx, stream) return DAQTimeslice(*ts, idx, stream)
def __str__(self): def __str__(self):
return "Available timeslice streams: {}".format(', '.join( return "Available timeslice streams: {}".format(', '.join(
...@@ -167,8 +167,8 @@ class JppTimeslices: ...@@ -167,8 +167,8 @@ class JppTimeslices:
return str(self) return str(self)
class JppTimeslice: class DAQTimeslice:
"""A wrapper for a Jpp timeslice""" """A wrapper for a DAQ timeslice"""
def __init__(self, header, superframe, hits_buffer, idx, stream): def __init__(self, header, superframe, hits_buffer, idx, stream):
self.header = header self.header = header
self._frames = {} self._frames = {}
...@@ -212,15 +212,15 @@ class JppTimeslice: ...@@ -212,15 +212,15 @@ class JppTimeslice:
len(self.header)) len(self.header))
class JppEvents: class DAQEvents:
"""A simple wrapper for Jpp events""" """A simple wrapper for DAQ events"""
def __init__(self, headers, snapshot_hits, triggered_hits): def __init__(self, headers, snapshot_hits, triggered_hits):
self.headers = headers self.headers = headers
self.snapshot_hits = snapshot_hits self.snapshot_hits = snapshot_hits
self.triggered_hits = triggered_hits self.triggered_hits = triggered_hits
def __getitem__(self, item): 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]) self.triggered_hits[item])
def __len__(self): def __len__(self):
...@@ -233,15 +233,15 @@ class JppEvents: ...@@ -233,15 +233,15 @@ class JppEvents:
return str(self) return str(self)
class JppEvent: class DAQEvent:
"""A wrapper for a Jpp event""" """A wrapper for a DAQ event"""
def __init__(self, header, snapshot_hits, triggered_hits): def __init__(self, header, snapshot_hits, triggered_hits):
self.header = header self.header = header
self.snapshot_hits = snapshot_hits self.snapshot_hits = snapshot_hits
self.triggered_hits = triggered_hits self.triggered_hits = triggered_hits
def __str__(self): 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)) len(self.snapshot_hits), len(self.triggered_hits))
def __repr__(self): def __repr__(self):
......
File moved
...@@ -2,15 +2,15 @@ import os ...@@ -2,15 +2,15 @@ import os
import re import re
import unittest import unittest
from km3io import JppReader from km3io import DAQReader
SAMPLES_DIR = os.path.join(os.path.dirname(__file__), "samples") SAMPLES_DIR = os.path.join(os.path.dirname(__file__), "samples")
class TestJppEvents(unittest.TestCase): class TestDAQEvents(unittest.TestCase):
def setUp(self): def setUp(self):
self.events = JppReader(os.path.join(SAMPLES_DIR, self.events = DAQReader(os.path.join(SAMPLES_DIR,
"jpp_v12.0.0.root")).events "daq_v1.0.0.root")).events
def test_index_lookup(self): def test_index_lookup(self):
assert 3 == len(self.events) assert 3 == len(self.events)
...@@ -22,10 +22,10 @@ class TestJppEvents(unittest.TestCase): ...@@ -22,10 +22,10 @@ class TestJppEvents(unittest.TestCase):
assert re.match(".*events.*3", self.events.__repr__()) assert re.match(".*events.*3", self.events.__repr__())
class TestJppEvent(unittest.TestCase): class TestDAQEvent(unittest.TestCase):
def setUp(self): def setUp(self):
self.event = JppReader(os.path.join(SAMPLES_DIR, self.event = DAQReader(os.path.join(SAMPLES_DIR,
"jpp_v12.0.0.root")).events[0] "daq_v1.0.0.root")).events[0]
def test_str(self): def test_str(self):
assert re.match(".*event.*96.*snapshot.*18.*triggered", assert re.match(".*event.*96.*snapshot.*18.*triggered",
...@@ -36,10 +36,10 @@ class TestJppEvent(unittest.TestCase): ...@@ -36,10 +36,10 @@ class TestJppEvent(unittest.TestCase):
self.event.__repr__()) self.event.__repr__())
class TestJppEventsSnapshotHits(unittest.TestCase): class TestDAQEventsSnapshotHits(unittest.TestCase):
def setUp(self): def setUp(self):
self.events = JppReader(os.path.join(SAMPLES_DIR, self.events = DAQReader(os.path.join(SAMPLES_DIR,
"jpp_v12.0.0.root")).events "daq_v1.0.0.root")).events
self.lengths = {0: 96, 1: 124, -1: 78} self.lengths = {0: 96, 1: 124, -1: 78}
self.total_item_count = 298 self.total_item_count = 298
...@@ -75,10 +75,10 @@ class TestJppEventsSnapshotHits(unittest.TestCase): ...@@ -75,10 +75,10 @@ class TestJppEventsSnapshotHits(unittest.TestCase):
assert all(c < 31 for c in hits.channel_id.max()) assert all(c < 31 for c in hits.channel_id.max())
class TestJppEventsTriggeredHits(unittest.TestCase): class TestDAQEventsTriggeredHits(unittest.TestCase):
def setUp(self): def setUp(self):
self.events = JppReader(os.path.join(SAMPLES_DIR, self.events = DAQReader(os.path.join(SAMPLES_DIR,
"jpp_v12.0.0.root")).events "daq_v1.0.0.root")).events
self.lengths = {0: 18, 1: 53, -1: 9} self.lengths = {0: 18, 1: 53, -1: 9}
self.total_item_count = 80 self.total_item_count = 80
...@@ -116,10 +116,10 @@ class TestJppEventsTriggeredHits(unittest.TestCase): ...@@ -116,10 +116,10 @@ class TestJppEventsTriggeredHits(unittest.TestCase):
assert all(c < 31 for c in hits.channel_id.max()) assert all(c < 31 for c in hits.channel_id.max())
class TestJppTimeslices(unittest.TestCase): class TestDAQTimeslices(unittest.TestCase):
def setUp(self): def setUp(self):
self.ts = JppReader(os.path.join(SAMPLES_DIR, self.ts = DAQReader(os.path.join(SAMPLES_DIR,
"jpp_v12.0.0.root")).timeslices "daq_v1.0.0.root")).timeslices
def test_data_lengths(self): def test_data_lengths(self):
assert 3 == len(self.ts._timeslices["default"][0]) assert 3 == len(self.ts._timeslices["default"][0])
...@@ -140,10 +140,10 @@ class TestJppTimeslices(unittest.TestCase): ...@@ -140,10 +140,10 @@ class TestJppTimeslices(unittest.TestCase):
assert "SN" in s assert "SN" in s
class TestJppTimeslice(unittest.TestCase): class TestDAQTimeslice(unittest.TestCase):
def setUp(self): def setUp(self):
self.ts = JppReader(os.path.join(SAMPLES_DIR, self.ts = DAQReader(os.path.join(SAMPLES_DIR,
"jpp_v12.0.0.root")).timeslices "daq_v1.0.0.root")).timeslices
self.n_frames = {"L1": [69, 69, 69], "SN": [64, 66, 68]} self.n_frames = {"L1": [69, 69, 69], "SN": [64, 66, 68]}
def test_str(self): def test_str(self):
...@@ -156,8 +156,8 @@ class TestJppTimeslice(unittest.TestCase): ...@@ -156,8 +156,8 @@ class TestJppTimeslice(unittest.TestCase):
class TestSummaryslices(unittest.TestCase): class TestSummaryslices(unittest.TestCase):
def setUp(self): def setUp(self):
self.ss = JppReader(os.path.join(SAMPLES_DIR, self.ss = DAQReader(os.path.join(SAMPLES_DIR,
"jpp_v12.0.0.root")).summaryslices "daq_v1.0.0.root")).summaryslices
def test_headers(self): def test_headers(self):
assert 3 == len(self.ss.headers) 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