Skip to content

Commit

Permalink
Merge pull request #48 from specktakel/fix-data
Browse files Browse the repository at this point in the history
Fixed bug reading in multiple seasons' events
  • Loading branch information
cescalara authored Oct 27, 2023
2 parents 94e9b09 + f3959e9 commit e47c509
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion icecube_tools/detector/r2021.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ def from_period(cls, period, **kwargs):
"""

if period not in available_irf_periods:
raise ValueError("Period {period} is not supported.")
raise ValueError(f"Period {period} is not supported.")

if kwargs.get("fetch", True):
data_interface = IceCubeData()
Expand Down
21 changes: 13 additions & 8 deletions icecube_tools/utils/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -903,10 +903,10 @@ def from_event_files(
dataset = data_interface.find("20210126")
data_interface.fetch(dataset)
dataset_dir = data_interface.get_path_to(dataset[0])

periods = list(periods)
if not periods:
# use all periods if none are specified
periods = (
periods = [
"IC40",
"IC59",
"IC79",
Expand All @@ -917,23 +917,28 @@ def from_event_files(
"IC86_V",
"IC86_VI",
"IC86_VII",
)
]

if use_all and periods == ("IC86_II",):
periods = (
if use_all and "IC86_II" in periods:
periods += [
"IC86_II",
"IC86_III",
"IC86_IV",
"IC86_V",
"IC86_VI",
"IC86_VII",
)
]

# Get rid of possible double entries
periods = list(set(periods))

# Check in STACK if there is a singular period event instance
# if not, create one from scratch
# Then, copy data into a new instance encompassing all periods
inst = cls(seed=seed)
for p in periods:
for p in available_data_periods:
if not p in periods:
continue
if p in RealEvents.STACK:
temp = RealEvents.STACK[p]
else:
Expand All @@ -954,7 +959,7 @@ def from_event_files(

# Compress IC86_II and onwards into a single entry
inst._add()
inst._uptime = Uptime(*periods)
inst._uptime = Uptime(*inst._periods)
inst._data_periods = inst._uptime.data_periods
inst._irf_periods = inst._uptime.irf_periods
return inst
Expand Down

0 comments on commit e47c509

Please sign in to comment.