diff --git a/README.rst b/README.rst index 0df3147b884764663f8b886e57514eb399e34a63..38e09f4cb59305c0e8565929efb7770cf725f78e 100644 --- a/README.rst +++ b/README.rst @@ -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: diff --git a/examples/plot_example.py b/examples/plot_example.py index faae689c8f3b80087f80a0738838c528b3da022d..6796508a8935d15e727c199d9332d91ecb229cd6 100644 --- a/examples/plot_example.py +++ b/examples/plot_example.py @@ -1,9 +1,12 @@ """ -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) diff --git a/km3io/__init__.py b/km3io/__init__.py index 9332aa830d8706ce3999963df9846663e15f7a6e..5ae07630512fc534a511d43e9a0a40dad03d3890 100644 --- a/km3io/__init__.py +++ b/km3io/__init__.py @@ -2,4 +2,4 @@ from .__version__ import version __version__ = version from .aanet import OfflineReader -from .jpp import JppReader +from .daq import DAQReader diff --git a/km3io/jpp.py b/km3io/daq.py similarity index 93% rename from km3io/jpp.py rename to km3io/daq.py index 70e1c88423c09df3e3db6d0717f0838480c0538b..f7bb48b16b20e5246e0d3d91fef03e39fb481f43 100644 --- a/km3io/jpp.py +++ b/km3io/daq.py @@ -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): diff --git a/tests/samples/jpp_v12.0.0.root b/tests/samples/daq_v1.0.0.root similarity index 100% rename from tests/samples/jpp_v12.0.0.root rename to tests/samples/daq_v1.0.0.root diff --git a/tests/test_jpp.py b/tests/test_daq.py similarity index 80% rename from tests/test_jpp.py rename to tests/test_daq.py index 1aac5442873af34fc5a1605d7e1b7ba4d7b476fc..f0a7189e470fa629f81b89b01db30fbe287cf888 100644 --- a/tests/test_jpp.py +++ b/tests/test_daq.py @@ -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)