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
......@@ -9,12 +9,13 @@ Note: the offline file used here has MC offline data and was intentionaly reduce
to 10 events.
"""
import km3io as ki
from km3net_testdata import data_path
#####################################################
# First, pass a filename to the `OfflineReader` class to open the file.
# 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
to 10 events.
"""
import km3io as ki
from km3net_testdata import data_path
#####################################################
# To access offline hits/mc_hits data:
mc_hits = ki.OfflineReader("samples/numucc.root").events.mc_hits
hits = ki.OfflineReader("samples/km3net_offline.root").events.hits
mc_hits = ki.OfflineReader(data_path("offline/numucc.root")).events.mc_hits
hits = ki.OfflineReader(data_path("offline/km3net_offline.root")).events.hits
#####################################################
......@@ -111,4 +112,4 @@ print(hits.channel_id[mask])
#####################################################
# or:
print(hits.dom_id[mask])
\ No newline at end of file
print(hits.dom_id[mask])
......@@ -8,12 +8,13 @@ written by aanet software.
Note: the offline files used here were intentionaly reduced to 10 events.
"""
import km3io as ki
from km3net_testdata import data_path
#####################################################
# To access offline tracks/mc_tracks data:
mc_tracks = ki.OfflineReader("samples/numucc.root").events.mc_tracks
tracks = ki.OfflineReader("samples/km3net_offline.root").events.tracks
mc_tracks = ki.OfflineReader(data_path("offline/numucc.root")).events.mc_tracks
tracks = ki.OfflineReader(data_path("offline/km3net_offline.root")).events.tracks
#####################################################
......@@ -113,4 +114,4 @@ print(tracks.lik[mask])
#####################################################
# or:
print(tracks.dir_z[mask])
\ No newline at end of file
print(tracks.dir_z[mask])
......@@ -8,12 +8,13 @@ interface. The available keys can be accessed either as attributes or via a
dictionary lookup:
"""
import km3io as ki
from km3net_testdata import data_path
#####################################################
# First, pass a filename to the `OfflineReader` class to open the file.
# 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
number is the detector ID and the second the run number.
"""
import km3io as ki
from km3net_testdata import data_path
#####################################################
# Accessing the event tree
......@@ -17,7 +18,7 @@ import km3io as ki
# 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.
......
km3net-testdata>=0.2.6
matplotlib
memory_profiler
numpydoc==0.9.2
......
......@@ -2,11 +2,11 @@ import os
import re
import unittest
from km3net_testdata import data_path
from km3io.gseagen import GSGReader
SAMPLES_DIR = os.path.join(os.path.dirname(__file__), "samples")
GSG_FILE = os.path.join(SAMPLES_DIR, "gseagen.root")
GSG_READER = GSGReader(GSG_FILE)
GSG_READER = GSGReader(data_path("gseagen/gseagen.root"))
class TestGSGHeader(unittest.TestCase):
......@@ -56,7 +56,7 @@ class TestGSGHeader(unittest.TestCase):
self.assertListEqual(self.header["NuList"].tolist(), [-14, 14])
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):
f.header
......
......@@ -2,17 +2,15 @@ import unittest
import numpy as np
from pathlib import Path
from km3net_testdata import data_path
from km3io import OfflineReader
from km3io.offline import _nested_mapper, Header
SAMPLES_DIR = Path(__file__).parent / 'samples'
OFFLINE_FILE = OfflineReader(SAMPLES_DIR / 'km3net_offline.root')
OFFLINE_USR = OfflineReader(SAMPLES_DIR / 'usr-sample.root')
OFFLINE_MC_TRACK_USR = OfflineReader(
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
OFFLINE_FILE = OfflineReader(data_path("offline/km3net_offline.root"))
OFFLINE_USR = OfflineReader(data_path("offline/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_NUMUCC = OfflineReader(data_path("offline/numucc.root")) # with mc data
class TestOfflineReader(unittest.TestCase):
......@@ -22,9 +20,9 @@ class TestOfflineReader(unittest.TestCase):
self.n_events = 10
def test_context_manager(self):
filename = SAMPLES_DIR / 'km3net_offline.root'
with OfflineReader(filename) as r:
assert r._filename == filename
filename = OFFLINE_FILE
with OfflineReader(data_path("offline/km3net_offline.root")) as r:
assert r
def test_number_events(self):
assert self.n_events == len(self.r.events)
......
......@@ -2,10 +2,11 @@ import os
import re
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
SAMPLES_DIR = os.path.join(os.path.dirname(__file__), "samples")
ONLINE_FILE = os.path.join(SAMPLES_DIR, "km3net_online.root")
ONLINE_FILE = data_path("online/km3net_online.root")
class TestOnlineReaderContextManager(unittest.TestCase):
......
......@@ -3,16 +3,17 @@
import unittest
import awkward1 as ak
import numpy as np
from pathlib import Path
from km3net_testdata import data_path
from km3io import OfflineReader
from km3io.tools import (to_num, cached_property, unfold_indices, unique,
uniquecount, fitinf, fitparams, count_nested, _find,
mask, best_track, rec_types, get_w2list_param,
get_multiplicity)
SAMPLES_DIR = Path(__file__).parent / 'samples'
OFFLINE_FILE = OfflineReader(SAMPLES_DIR / 'km3net_offline.root')
OFFLINE_FILE = OfflineReader(data_path("offline/km3net_offline.root"))
# class TestGetw2listParam(unittest.TestCase):
# 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