We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 14b5485 commit 977f2ecCopy full SHA for 977f2ec
skyllh/core/flux_model.py
@@ -814,7 +814,14 @@ def get_integral(
814
integral = np.empty((len(E1),), dtype=np.float64)
815
816
for (i, (E1_i, E2_i)) in enumerate(zip(E1, E2)):
817
- integral[i] = quad(self, E1_i, E2_i, full_output=True)[0]
+
818
+ # integration for log(energy) for hopefully better numerical stability
819
+ tmp_e = np.linspace(np.log10(E1_i), np.log10(E2_i), 5000)
820
+ tmp_int = np.trapz(np.log(10) * self(10**tmp_e) * 10**tmp_e, tmp_e)
821
822
+ # make sure it is always positive (probably not an issue any more with np.trapz.
823
+ # used to be an issue using the spline integrate self.function.integrate)
824
+ integral[i] = max(0.0, tmp_int)
825
826
return integral
827
0 commit comments