Skip to content

Commit

Permalink
also support old scipy with simpson
Browse files Browse the repository at this point in the history
  • Loading branch information
joezuntz committed Jul 13, 2024
1 parent bd0e5fa commit a9ef549
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions shear/point_mass/add_gammat_point_mass.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
import scipy.integrate
import astropy.units as u
import astropy.constants as const
try:
from scipy.integrate import simpson
except ImportError:
from scipy.integrate import simps as simpson

sigcrit_inv_fac = (4 * np.pi * const.G)/(const.c**2)
sigcrit_inv_fac_Mpc_Msun = (sigcrit_inv_fac.to(u.Mpc/u.M_sun)).value
Expand Down Expand Up @@ -110,7 +114,7 @@ def execute(block, config):
nz_source = block[config['source_nz_section'], "bin_%d" % (j2 + 1)][1:]

ng_array_source_rep = np.tile(nz_source.reshape(1, len(z_source)), (len(z_lens), 1))
int_sourcez = sp.integrate.simpson(ng_array_source_rep * (num / chi_smat), z_source)
int_sourcez = simpson(ng_array_source_rep * (num / chi_smat), z_source)

coeff_ints = sigcrit_inv_fac_Mpc_Msun

Expand All @@ -120,7 +124,7 @@ def execute(block, config):
# Since gamma_t is a scalar it should be same in both physical and comoving coordinates
# It is just easier to match the expressions in comoving coordinates to the ones on methods paper.

betaj1j2_pm = sp.integrate.simpson(nz_lens * Is * (1./chi_lens**2), z_lens)
betaj1j2_pm = simpson(nz_lens * Is * (1./chi_lens**2), z_lens)
if (config['use_fiducial']):
config['betaj1j2'][str(j1) + '_' + str(j2)] = betaj1j2_pm
else:
Expand Down

0 comments on commit a9ef549

Please sign in to comment.