Skip to content

Commit 4546afb

Browse files
authored
Merge pull request #801 from Aske-Rosted/i3filtermapextractor
I3filtermapextractor
2 parents 384644b + 446f439 commit 4546afb

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

src/graphnet/data/extractors/icecube/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@
1818
from .i3pisaextractor import I3PISAExtractor
1919
from .i3ntmuonlabelsextractor import I3NTMuonLabelExtractor
2020
from .i3quesoextractor import I3QUESOExtractor
21+
from .i3filtermapextractor import I3FilterMapExtractor
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
"""I3Extractor for extracting the boolean condition of the I3FilterMask."""
2+
3+
from typing import TYPE_CHECKING, Dict
4+
5+
from graphnet.data.extractors.icecube import I3Extractor
6+
7+
if TYPE_CHECKING:
8+
from icecube import icetray # pyright: reportMissingImports=false
9+
10+
11+
class I3FilterMapExtractor(I3Extractor):
12+
"""Class for extracting I3FilterMap properties.
13+
14+
This class extracts the boolean condition of the I3FilterMask from the
15+
I3FilterMap in the frame.
16+
"""
17+
18+
def __init__(
19+
self,
20+
key: str = "FilterMask",
21+
extractor_name: str = "I3FilterMap",
22+
exclude: list = [None],
23+
) -> None:
24+
"""Construct I3FilterMapExtractor."""
25+
# Base class constructor
26+
super().__init__(extractor_name=extractor_name, exclude=exclude)
27+
self._key = key
28+
29+
def __call__(self, frame: "icetray.I3Frame") -> Dict[str, bool]:
30+
"""Extract I3FilterMap properties from I3FilterMap in frame."""
31+
output = {}
32+
if self._key not in frame:
33+
raise KeyError(f"Key {self._key} not found in frame.")
34+
items = frame[self._key].items()
35+
for item in items:
36+
output[item[0]] = item[1].condition_passed
37+
return output

0 commit comments

Comments
 (0)