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

Use km3net_testdata

parent 8144dbf5
No related branches found
No related tags found
1 merge request!38Resolve "Use km3net_testdata"
Pipeline #13353 failed
This commit is part of merge request !38. Comments created here will be created in the context of that merge request.
...@@ -9,12 +9,13 @@ Note: the offline file used here has MC offline data and was intentionaly reduce ...@@ -9,12 +9,13 @@ Note: the offline file used here has MC offline data and was intentionaly reduce
to 10 events. to 10 events.
""" """
import km3io as ki import km3io as ki
from km3net_testdata import data_path
##################################################### #####################################################
# First, pass a filename to the `OfflineReader` class to open the file. # First, pass a filename to the `OfflineReader` class to open the file.
# Note that only some meta information is read into memory. # Note that only some meta information is read into memory.
r = ki.OfflineReader("samples/numucc.root") r = ki.OfflineReader(data_path("offline/numucc.root"))
##################################################### #####################################################
......
...@@ -9,12 +9,13 @@ Note: the offline file used here has MC offline data and was intentionaly reduce ...@@ -9,12 +9,13 @@ Note: the offline file used here has MC offline data and was intentionaly reduce
to 10 events. to 10 events.
""" """
import km3io as ki import km3io as ki
from km3net_testdata import data_path
##################################################### #####################################################
# To access offline hits/mc_hits data: # To access offline hits/mc_hits data:
mc_hits = ki.OfflineReader("samples/numucc.root").events.mc_hits mc_hits = ki.OfflineReader(data_path("offline/numucc.root")).events.mc_hits
hits = ki.OfflineReader("samples/km3net_offline.root").events.hits hits = ki.OfflineReader(data_path("offline/km3net_offline.root")).events.hits
##################################################### #####################################################
...@@ -111,4 +112,4 @@ print(hits.channel_id[mask]) ...@@ -111,4 +112,4 @@ print(hits.channel_id[mask])
##################################################### #####################################################
# or: # or:
print(hits.dom_id[mask]) print(hits.dom_id[mask])
\ No newline at end of file
...@@ -8,12 +8,13 @@ written by aanet software. ...@@ -8,12 +8,13 @@ written by aanet software.
Note: the offline files used here were intentionaly reduced to 10 events. Note: the offline files used here were intentionaly reduced to 10 events.
""" """
import km3io as ki import km3io as ki
from km3net_testdata import data_path
##################################################### #####################################################
# To access offline tracks/mc_tracks data: # To access offline tracks/mc_tracks data:
mc_tracks = ki.OfflineReader("samples/numucc.root").events.mc_tracks mc_tracks = ki.OfflineReader(data_path("offline/numucc.root")).events.mc_tracks
tracks = ki.OfflineReader("samples/km3net_offline.root").events.tracks tracks = ki.OfflineReader(data_path("offline/km3net_offline.root")).events.tracks
##################################################### #####################################################
...@@ -113,4 +114,4 @@ print(tracks.lik[mask]) ...@@ -113,4 +114,4 @@ print(tracks.lik[mask])
##################################################### #####################################################
# or: # or:
print(tracks.dir_z[mask]) print(tracks.dir_z[mask])
\ No newline at end of file
...@@ -8,12 +8,13 @@ interface. The available keys can be accessed either as attributes or via a ...@@ -8,12 +8,13 @@ interface. The available keys can be accessed either as attributes or via a
dictionary lookup: dictionary lookup:
""" """
import km3io as ki import km3io as ki
from km3net_testdata import data_path
##################################################### #####################################################
# First, pass a filename to the `OfflineReader` class to open the file. # First, pass a filename to the `OfflineReader` class to open the file.
# Note that only some meta information is read into memory. # Note that only some meta information is read into memory.
r = ki.OfflineReader("samples/usr-sample.root") r = ki.OfflineReader(data_path("offline/usr-sample.root"))
##################################################### #####################################################
......
...@@ -9,6 +9,7 @@ Such a file is usually called "KM3NET_00000001_00000002.root", where the first ...@@ -9,6 +9,7 @@ Such a file is usually called "KM3NET_00000001_00000002.root", where the first
number is the detector ID and the second the run number. number is the detector ID and the second the run number.
""" """
import km3io as ki import km3io as ki
from km3net_testdata import data_path
##################################################### #####################################################
# Accessing the event tree # Accessing the event tree
...@@ -17,7 +18,7 @@ import km3io as ki ...@@ -17,7 +18,7 @@ import km3io as ki
# with: # with:
f = ki.OnlineReader("samples/km3net_online.root") f = ki.OnlineReader(data_path("online/km3net_online.root"))
##################################################### #####################################################
# Note that only some meta information is read into memory. # Note that only some meta information is read into memory.
......
km3net-testdata>=0.2.6
matplotlib matplotlib
memory_profiler memory_profiler
numpydoc==0.9.2 numpydoc==0.9.2
......
...@@ -2,11 +2,11 @@ import os ...@@ -2,11 +2,11 @@ import os
import re import re
import unittest import unittest
from km3net_testdata import data_path
from km3io.gseagen import GSGReader from km3io.gseagen import GSGReader
SAMPLES_DIR = os.path.join(os.path.dirname(__file__), "samples") GSG_READER = GSGReader(data_path("gseagen/gseagen.root"))
GSG_FILE = os.path.join(SAMPLES_DIR, "gseagen.root")
GSG_READER = GSGReader(GSG_FILE)
class TestGSGHeader(unittest.TestCase): class TestGSGHeader(unittest.TestCase):
...@@ -56,7 +56,7 @@ class TestGSGHeader(unittest.TestCase): ...@@ -56,7 +56,7 @@ class TestGSGHeader(unittest.TestCase):
self.assertListEqual(self.header["NuList"].tolist(), [-14, 14]) self.assertListEqual(self.header["NuList"].tolist(), [-14, 14])
def test_unsupported_header(self): def test_unsupported_header(self):
f = GSGReader(os.path.join(SAMPLES_DIR, "km3net_online.root")) f = GSGReader(data_path("online/km3net_online.root"))
with self.assertWarns(UserWarning): with self.assertWarns(UserWarning):
f.header f.header
......
...@@ -2,17 +2,15 @@ import unittest ...@@ -2,17 +2,15 @@ import unittest
import numpy as np import numpy as np
from pathlib import Path from pathlib import Path
from km3net_testdata import data_path
from km3io import OfflineReader from km3io import OfflineReader
from km3io.offline import _nested_mapper, Header from km3io.offline import _nested_mapper, Header
SAMPLES_DIR = Path(__file__).parent / 'samples' OFFLINE_FILE = OfflineReader(data_path("offline/km3net_offline.root"))
OFFLINE_FILE = OfflineReader(SAMPLES_DIR / 'km3net_offline.root') OFFLINE_USR = OfflineReader(data_path("offline/usr-sample.root"))
OFFLINE_USR = OfflineReader(SAMPLES_DIR / 'usr-sample.root') OFFLINE_MC_TRACK_USR = OfflineReader(data_path('offline/mcv5.11r2.gsg_muonCChigherE-CC_50-5000GeV.km3_AAv1.jterbr00004695.jchain.aanet.498.root'))
OFFLINE_MC_TRACK_USR = OfflineReader( OFFLINE_NUMUCC = OfflineReader(data_path("offline/numucc.root")) # with mc data
SAMPLES_DIR /
'mcv5.11r2.gsg_muonCChigherE-CC_50-5000GeV.km3_AAv1.jterbr00004695.jchain.aanet.498.root'
)
OFFLINE_NUMUCC = OfflineReader(SAMPLES_DIR / "numucc.root") # with mc data
class TestOfflineReader(unittest.TestCase): class TestOfflineReader(unittest.TestCase):
...@@ -22,9 +20,9 @@ class TestOfflineReader(unittest.TestCase): ...@@ -22,9 +20,9 @@ class TestOfflineReader(unittest.TestCase):
self.n_events = 10 self.n_events = 10
def test_context_manager(self): def test_context_manager(self):
filename = SAMPLES_DIR / 'km3net_offline.root' filename = OFFLINE_FILE
with OfflineReader(filename) as r: with OfflineReader(data_path("offline/km3net_offline.root")) as r:
assert r._filename == filename assert r
def test_number_events(self): def test_number_events(self):
assert self.n_events == len(self.r.events) assert self.n_events == len(self.r.events)
......
...@@ -2,10 +2,11 @@ import os ...@@ -2,10 +2,11 @@ import os
import re import re
import unittest import unittest
from km3net_testdata import data_path
from km3io.online import OnlineReader, get_rate, has_udp_trailer, get_udp_max_sequence_number, get_channel_flags, get_number_udp_packets from km3io.online import OnlineReader, get_rate, has_udp_trailer, get_udp_max_sequence_number, get_channel_flags, get_number_udp_packets
SAMPLES_DIR = os.path.join(os.path.dirname(__file__), "samples") ONLINE_FILE = data_path("online/km3net_online.root")
ONLINE_FILE = os.path.join(SAMPLES_DIR, "km3net_online.root")
class TestOnlineReaderContextManager(unittest.TestCase): class TestOnlineReaderContextManager(unittest.TestCase):
......
...@@ -3,16 +3,17 @@ ...@@ -3,16 +3,17 @@
import unittest import unittest
import awkward1 as ak import awkward1 as ak
import numpy as np import numpy as np
from pathlib import Path from pathlib import Path
from km3net_testdata import data_path
from km3io import OfflineReader from km3io import OfflineReader
from km3io.tools import (to_num, cached_property, unfold_indices, unique, from km3io.tools import (to_num, cached_property, unfold_indices, unique,
uniquecount, fitinf, fitparams, count_nested, _find, uniquecount, fitinf, fitparams, count_nested, _find,
mask, best_track, rec_types, get_w2list_param, mask, best_track, rec_types, get_w2list_param,
get_multiplicity) get_multiplicity)
SAMPLES_DIR = Path(__file__).parent / 'samples' OFFLINE_FILE = OfflineReader(data_path("offline/km3net_offline.root"))
OFFLINE_FILE = OfflineReader(SAMPLES_DIR / 'km3net_offline.root')
# class TestGetw2listParam(unittest.TestCase): # class TestGetw2listParam(unittest.TestCase):
# def test_get_w2list_param(self): # def test_get_w2list_param(self):
......
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