Skip to content

Commit

Permalink
compute.py:run exit early if no valid events
Browse files Browse the repository at this point in the history
  • Loading branch information
Areustle committed May 15, 2024
1 parent 314a0ce commit 8fb5e60
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/nuspacesim/compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
compute
"""

from __future__ import annotations

from typing import Any, Iterable
Expand Down Expand Up @@ -189,9 +190,19 @@ def add_meta(self, name: str, value: Any, comment: str):
beta_tr, thetaArr, pathLenArr, *_ = geom(
config.simulation.thrown_events, store=sw, plot=to_plot
)
thrown_color = "[blue]" if beta_tr.size == 0 else "[red]"
logv(
f"\t[blue]Threw {config.simulation.thrown_events} neutrinos. {beta_tr.size} were valid.[/]"
f"\t{thrown_color}Threw {config.simulation.thrown_events} neutrinos.\
{beta_tr.size} were valid.[/]"
)

# Avoid Exceptions and return a (valid) empty sim object
if beta_tr.size:
console.log(
"\t[red] WARNING: No valid events thrown! Exiting early! Check geometry![/]"
)
return sim

init_lat, init_long = geom.find_lat_long_along_traj(np.zeros_like(beta_tr))
sw(
("init_lat", "init_lon"),
Expand Down

0 comments on commit 8fb5e60

Please sign in to comment.