Skip to content

Commit

Permalink
Merge pull request lenstronomy#650 from ajshajib/feature/consistent_gnfw
Browse files Browse the repository at this point in the history
Refactor GNFW profile and tests
  • Loading branch information
ajshajib authored Sep 12, 2024
2 parents 17ce930 + 8652a3f commit 4765889
Show file tree
Hide file tree
Showing 9 changed files with 246 additions and 94 deletions.
4 changes: 2 additions & 2 deletions lenstronomy/Cosmo/lens_cosmo.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def gnfw_angle2physical(self, Rs_angle, alpha_Rs, gamma_in):
"""
Rs = Rs_angle * const.arcsec * self.dd
theta_scaled = alpha_Rs * self.sigma_crit * self.dd * const.arcsec
factor = self._gnfw.alpha(1, 1, 1, gamma_in) / 4.0
factor = self._gnfw.get_alpha_Rs_for_kappa_s_1(1, gamma_in) / 4.0
rho0 = theta_scaled / (4 * Rs**2 * factor)
rho0_com = rho0 / self.h**2
c = self.gnfw_param.c_rho0(rho0_com, self.z_lens, gamma_in)
Expand Down Expand Up @@ -242,7 +242,7 @@ def gnfw_physical2angle(self, M, c, gamma_in):
"""
rho0, Rs, r200 = self.gnfwParam_physical(M, c, gamma_in)
Rs_angle = Rs / self.dd / const.arcsec # Rs in arcsec
factor = self._gnfw.alpha(1, 1, 1, gamma_in) / 4.0
factor = self._gnfw.get_alpha_Rs_for_kappa_s_1(1, gamma_in) / 4.0
alpha_Rs = rho0 * (4 * Rs**2 * factor)
return Rs_angle, alpha_Rs / self.sigma_crit / self.dd / const.arcsec

Expand Down
8 changes: 3 additions & 5 deletions lenstronomy/LensModel/Profiles/gauss_decomposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,14 +497,12 @@ def get_kappa_1d(self, y, **kwargs):
:return: projected NFW profile at y
:rtype: ``type(y)``
"""
R_s = kwargs["Rs"]
Rs = kwargs["Rs"]
alpha_Rs = kwargs["alpha_Rs"]
gamma_in = kwargs["gamma_in"]

alpha_for_kappa_s_1 = self.gnfw.alpha(R_s, R_s, 1, gamma_in)
kappa_s = alpha_Rs / alpha_for_kappa_s_1

kappa = self.gnfw.kappa(y, R_s, kappa_s, gamma_in)
kappa_s = self.gnfw.alpha_Rs_to_kappa_s(Rs, alpha_Rs, gamma_in)
kappa = self.gnfw._kappa(y, Rs, kappa_s, gamma_in)

return kappa

Expand Down
Loading

0 comments on commit 4765889

Please sign in to comment.