Skip to content

Commit

Permalink
Throw useful error if density evaluation resulted only in nans or infs
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakob Bottcher committed Dec 19, 2024
1 parent 01adbc5 commit 7e15788
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion MCEq/geometry/density_profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,12 @@ def calculate_density_spline(self, n_steps=2000):

# Calculate integral for each depth point
rho_l = vec_rho_l(dl_vec)
X_int = cumtrapz(rho_l[np.isfinite(rho_l)], dl_vec[np.isfinite(rho_l)])
if np.sum(np.isfinite(rho_l)) >= 1:
X_int = cumtrapz(rho_l[np.isfinite(rho_l)],
dl_vec[np.isfinite(rho_l)])
else:
raise Exception("No finite density values found"
" in the density spline evaluation.")
dl_vec = dl_vec[np.isfinite(rho_l)][1:]

info(5, ".. took {0:1.2f}s".format(time() - now))
Expand Down

0 comments on commit 7e15788

Please sign in to comment.