diff --git a/src/simweights/_weighter.py b/src/simweights/_weighter.py index 5112039..afd7996 100644 --- a/src/simweights/_weighter.py +++ b/src/simweights/_weighter.py @@ -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. @@ -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: