Skip to content

Commit

Permalink
Switch to linear interpolation of the inverse cumulative mass profile…
Browse files Browse the repository at this point in the history
… to avoid sampling issues
  • Loading branch information
jobovy committed Oct 23, 2024
1 parent be8e740 commit e9440f6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion galpy/df/kingdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def __init__(self, W0, M=1.0, rt=1.0, npt=1001, ro=None, vo=None):
self._icmf = interpolate.InterpolatedUnivariateSpline(
self._mass_scale * self._scalefree_kdf._cumul_mass / self.M,
self._radius_scale * self._scalefree_kdf._r,
k=3,
k=1,
)
# Setup velocity DF interpolator for velocity sampling here
self._rmin_sampling = 0.0
Expand Down
2 changes: 1 addition & 1 deletion galpy/df/sphericaldf.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ def _make_cmf_interpolator(self):
if numpy.isinf(self._rmax):
xis = numpy.append(xis, 1)
ms = numpy.append(ms, 1)
return scipy.interpolate.InterpolatedUnivariateSpline(ms, xis, k=3)
return scipy.interpolate.InterpolatedUnivariateSpline(ms, xis, k=1)

def _sample_position_angles(self, n=1):
"""Generate spherical angle samples"""
Expand Down
4 changes: 2 additions & 2 deletions tests/test_sphericaldf.py
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ def test_osipkovmerritt_nfw_dens_massprofile():
dfh = osipkovmerrittNFWdf(pot=pot, ra=ra)
numpy.random.seed(10)
samp = dfh.sample(n=100000)
tol = 5 * 1e-3
tol = 7 * 1e-3
check_spherical_massprofile(
samp, lambda r: pot.mass(r) / pot.mass(numpy.amax(samp.r())), tol, skip=1000
)
Expand Down Expand Up @@ -1133,7 +1133,7 @@ def test_isotropic_nfw_dens_massprofile():
dfp = isotropicNFWdf(pot=pot)
numpy.random.seed(10)
samp = dfp.sample(n=100000)
tol = 5 * 1e-3
tol = 7 * 1e-3
check_spherical_massprofile(
samp, lambda r: pot.mass(r) / pot.mass(numpy.amax(samp.r())), tol, skip=1000
)
Expand Down

0 comments on commit e9440f6

Please sign in to comment.