Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Dec 12, 2024
1 parent 2b838bb commit d122cca
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/simweights/_weighter.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def effective_area(
self: Weighter,
energy_bins: ArrayLike,
cos_zenith_bins: ArrayLike,
flux: Any = 1e-4, # default is 1 GeV^-1 m^-2 sr^-1 flux
flux: Any = 1e-4, # default is 1 GeV^-1 m^-2 sr^-1 flux
mask: ArrayLike | None = None,
) -> NDArray[np.float64]:
r"""Calculate The effective area for the given energy and zenith bins.
Expand Down Expand Up @@ -204,9 +204,20 @@ def effective_area(
return np.asarray(hist_val / (e_width * 2 * np.pi * z_width * nspecies), dtype=np.float64)
elif callable(flux):
flux_pdgids = [pdgid.value for pdgid in flux.pdgids]
flux_func = lambda E: sum([flux._funcs[flux_pdgids.index(np.unique(self.get_weight_column("pdgid")[maska])[i_species])](E) for i_species in range(nspecies)])
flux_func = lambda E: sum(
[
flux._funcs[flux_pdgids.index(np.unique(self.get_weight_column("pdgid")[maska])[i_species])](E)
for i_species in range(nspecies)
]
)
from scipy.integrate import quad
flux_integrals = np.asarray([quad(flux_func, energy_bins[bin_index], energy_bins[bin_index+1])[0] for bin_index in range(len(energy_bins)-1)])

flux_integrals = np.asarray(
[
quad(flux_func, energy_bins[bin_index], energy_bins[bin_index + 1])[0]
for bin_index in range(len(energy_bins) - 1)
]
)
e_width, z_width = np.meshgrid(flux_integrals, np.ediff1d(czbin))
return np.asarray(1e-4 * hist_val / (e_width * 2 * np.pi * z_width), dtype=np.float64)
else:
Expand Down

0 comments on commit d122cca

Please sign in to comment.