From 31657b6e8eb126eb00871278ffec84935d3f09c7 Mon Sep 17 00:00:00 2001 From: Connor Stone Date: Thu, 19 Dec 2024 16:54:59 -0500 Subject: [PATCH 1/3] update names for radii --- src/caustics/lenses/epl.py | 31 +++++------ src/caustics/lenses/func/epl.py | 20 +++---- src/caustics/lenses/func/point.py | 14 ++--- src/caustics/lenses/func/pseudo_jaffe.py | 71 ++++++++++-------------- src/caustics/lenses/func/sie.py | 39 ++++++++----- src/caustics/lenses/func/sis.py | 20 +++---- src/caustics/lenses/func/tnfw.py | 38 ++++++------- src/caustics/lenses/point.py | 18 +++--- src/caustics/lenses/pseudo_jaffe.py | 66 ++++++++++------------ src/caustics/lenses/sie.py | 62 ++++++++++----------- src/caustics/lenses/sis.py | 20 +++---- src/caustics/lenses/tnfw.py | 68 +++++++++++------------ src/caustics/tests.py | 2 +- tests/test_base.py | 4 +- tests/test_epl.py | 11 ++-- tests/test_point.py | 8 +-- tests/test_sie.py | 8 +-- tests/test_simulator_runs.py | 8 +-- tests/test_sis.py | 6 +- 19 files changed, 249 insertions(+), 265 deletions(-) diff --git a/src/caustics/lenses/epl.py b/src/caustics/lenses/epl.py index 485e0321..32911248 100644 --- a/src/caustics/lenses/epl.py +++ b/src/caustics/lenses/epl.py @@ -61,10 +61,8 @@ class EPL(ThinLens): *Unit: radians* - b: Optional[Union[Tensor, float]] - This is the scale length of the lens, - which sets the overall scale of the lensing effect. - In some contexts, this is referred to as the Einstein radius. + Rein: Optional[Union[Tensor, float]] + The Einstein radius of the lens, exact at q=1.0. *Unit: arcsec* @@ -84,7 +82,7 @@ class EPL(ThinLens): "y0": 0.0, "q": 0.5, "phi": 0.0, - "b": 1.0, + "Rein": 1.0, "t": 1.0, } @@ -104,8 +102,8 @@ def __init__( phi: Annotated[ Optional[Union[Tensor, float]], "Position angle of the lens", True ] = None, - b: Annotated[ - Optional[Union[Tensor, float]], "Scale length of the lens", True + Rein: Annotated[ + Optional[Union[Tensor, float]], "Einstein radius of the lens", True ] = None, t: Annotated[ Optional[Union[Tensor, float]], @@ -157,9 +155,8 @@ def __init__( *Unit: radians* - b: Optional[Tensor] - Scale length of the lens. - If not provided, it is considered as a free parameter. + Rein: Optional[Tensor] + Einstein radius of the lens. *Unit: arcsec* @@ -183,7 +180,7 @@ def __init__( self.y0 = Param("y0", y0, units="arcsec") self.q = Param("q", q, units="unitless", valid=(0, 1)) self.phi = Param("phi", phi, units="radians", valid=(0, pi), cyclic=True) - self.b = Param("b", b, units="arcsec", valid=(0, None)) + self.Rein = Param("Rein", Rein, units="arcsec", valid=(0, None)) self.t = Param("t", t, units="unitless", valid=(0, 2)) self.s = s @@ -199,7 +196,7 @@ def reduced_deflection_angle( y0: Annotated[Tensor, "Param"], q: Annotated[Tensor, "Param"], phi: Annotated[Tensor, "Param"], - b: Annotated[Tensor, "Param"], + Rein: Annotated[Tensor, "Param"], t: Annotated[Tensor, "Param"], ) -> tuple[Tensor, Tensor]: """ @@ -239,7 +236,7 @@ def reduced_deflection_angle( """ return func.reduced_deflection_angle_epl( - x0, y0, q, phi, b, t, x, y, self.n_iter + x0, y0, q, phi, Rein, t, x, y, self.n_iter ) def _r_omega(self, z, t, q): @@ -296,7 +293,7 @@ def potential( y0: Annotated[Tensor, "Param"], q: Annotated[Tensor, "Param"], phi: Annotated[Tensor, "Param"], - b: Annotated[Tensor, "Param"], + Rein: Annotated[Tensor, "Param"], t: Annotated[Tensor, "Param"], ): """ @@ -330,7 +327,7 @@ def potential( *Unit: arcsec^2* """ - return func.potential_epl(x0, y0, q, phi, b, t, x, y, self.n_iter) + return func.potential_epl(x0, y0, q, phi, Rein, t, x, y, self.n_iter) @forward def convergence( @@ -342,7 +339,7 @@ def convergence( y0: Annotated[Tensor, "Param"], q: Annotated[Tensor, "Param"], phi: Annotated[Tensor, "Param"], - b: Annotated[Tensor, "Param"], + Rein: Annotated[Tensor, "Param"], t: Annotated[Tensor, "Param"], ) -> Tensor: """ @@ -376,4 +373,4 @@ def convergence( *Unit: unitless* """ - return func.convergence_epl(x0, y0, q, phi, b, t, x, y, self.s) + return func.convergence_epl(x0, y0, q, phi, Rein, t, x, y, self.s) diff --git a/src/caustics/lenses/func/epl.py b/src/caustics/lenses/func/epl.py index 07f673eb..a5374189 100644 --- a/src/caustics/lenses/func/epl.py +++ b/src/caustics/lenses/func/epl.py @@ -26,7 +26,7 @@ def _r_omega(z, t, q, n_iter): return part_sum -def reduced_deflection_angle_epl(x0, y0, q, phi, b, t, x, y, n_iter): +def reduced_deflection_angle_epl(x0, y0, q, phi, Rein, t, x, y, n_iter): """ Calculate the reduced deflection angle. Given in Tessore et al. 2015 equation 13. @@ -100,14 +100,14 @@ def reduced_deflection_angle_epl(x0, y0, q, phi, b, t, x, y, n_iter): # Tessore et al 2015 (eq. 23) r_omega = _r_omega(z, t, q, n_iter) # Tessore et al 2015 (eq. 13) - alpha_c = 2.0 / (1.0 + q) * (b / r) ** t * r_omega # fmt: skip + alpha_c = 2.0 / (1.0 + q) * (Rein * q.sqrt() / r) ** t * r_omega # fmt: skip alpha_real = torch.nan_to_num(alpha_c.real, posinf=10**10, neginf=-(10**10)) alpha_imag = torch.nan_to_num(alpha_c.imag, posinf=10**10, neginf=-(10**10)) return derotate(alpha_real, alpha_imag, phi) -def potential_epl(x0, y0, q, phi, b, t, x, y, n_iter): +def potential_epl(x0, y0, q, phi, Rein, t, x, y, n_iter): """ Calculate the potential for the EPL as defined in Tessore et al. 2015 equation 15. @@ -133,8 +133,8 @@ def potential_epl(x0, y0, q, phi, b, t, x, y, n_iter): *Unit: radians* - b: Tensor - Scale length of the lens. + Rein: Tensor + The Einstein radius of the lens. *Unit: arcsec* @@ -172,13 +172,13 @@ def potential_epl(x0, y0, q, phi, b, t, x, y, n_iter): *Unit: arcsec* """ - ax, ay = reduced_deflection_angle_epl(x0, y0, q, phi, b, t, x, y, n_iter) + ax, ay = reduced_deflection_angle_epl(x0, y0, q, phi, Rein, t, x, y, n_iter) ax, ay = derotate(ax, ay, -phi) x, y = translate_rotate(x, y, x0, y0, phi) return (x * ax + y * ay) / (2 - t) # fmt: skip -def convergence_epl(x0, y0, q, phi, b, t, x, y, s=0.0): +def convergence_epl(x0, y0, q, phi, Rein, t, x, y, s=0.0): """ Calculate the reduced deflection angle. @@ -206,8 +206,8 @@ def convergence_epl(x0, y0, q, phi, b, t, x, y, s=0.0): *Unit: radians* - b: Tensor - Scale length of the lens. + Rein: Tensor + Einstein radius of the lens. *Unit: arcsec* @@ -247,4 +247,4 @@ def convergence_epl(x0, y0, q, phi, b, t, x, y, s=0.0): """ x, y = translate_rotate(x, y, x0, y0, phi) psi = (q**2 * x**2 + y**2 + s**2).sqrt() # fmt: skip - return (2 - t) / 2 * (b / psi) ** t # fmt: skip + return (2 - t) / 2 * (Rein * q.sqrt() / psi) ** t # fmt: skip diff --git a/src/caustics/lenses/func/point.py b/src/caustics/lenses/func/point.py index f71e3de7..6fedf992 100644 --- a/src/caustics/lenses/func/point.py +++ b/src/caustics/lenses/func/point.py @@ -4,7 +4,7 @@ from ...constants import G_over_c2, rad_to_arcsec -def reduced_deflection_angle_point(x0, y0, th_ein, x, y, s=0.0): +def reduced_deflection_angle_point(x0, y0, Rein, x, y, s=0.0): """ Compute the reduced deflection angles. See the Meneghetti lecture notes equation 3.1 for more detail. @@ -21,7 +21,7 @@ def reduced_deflection_angle_point(x0, y0, th_ein, x, y, s=0.0): *Unit: arcsec* - th_ein: Tensor + Rein: Tensor Einstein radius of the lens. *Unit: arcsec* @@ -56,12 +56,12 @@ def reduced_deflection_angle_point(x0, y0, th_ein, x, y, s=0.0): """ x, y = translate_rotate(x, y, x0, y0) th = (x**2 + y**2).sqrt() + s - ax = x * th_ein**2 / th**2 - ay = y * th_ein**2 / th**2 + ax = x * Rein**2 / th**2 + ay = y * Rein**2 / th**2 return ax, ay -def potential_point(x0, y0, th_ein, x, y, s=0.0): +def potential_point(x0, y0, Rein, x, y, s=0.0): """ Compute the lensing potential. See the Meneghetti lecture notes equation 3.3 for more detail. @@ -78,7 +78,7 @@ def potential_point(x0, y0, th_ein, x, y, s=0.0): *Unit: arcsec* - th_ein: Tensor + Rein: Tensor Einstein radius of the lens. *Unit: arcsec* @@ -108,7 +108,7 @@ def potential_point(x0, y0, th_ein, x, y, s=0.0): """ x, y = translate_rotate(x, y, x0, y0) th = (x**2 + y**2).sqrt() + s - return th_ein**2 * th.log() + return Rein**2 * th.log() def convergence_point(x0, y0, x, y): diff --git a/src/caustics/lenses/func/pseudo_jaffe.py b/src/caustics/lenses/func/pseudo_jaffe.py index 3239f400..cf9e7eaf 100644 --- a/src/caustics/lenses/func/pseudo_jaffe.py +++ b/src/caustics/lenses/func/pseudo_jaffe.py @@ -4,9 +4,7 @@ from ...utils import translate_rotate -def convergence_0_pseudo_jaffe( - mass, core_radius, scale_radius, d_l, critical_surface_density -): +def convergence_0_pseudo_jaffe(mass, Rc, Rs, d_l, critical_surface_density): """ Compute the convergence (dimensionless surface mass density). This is rearranged from Eliasdottir et al 2007 equation A11. @@ -18,12 +16,12 @@ def convergence_0_pseudo_jaffe( *Unit: Msun* - core_radius: Tensor + Rc: Tensor Core radius of the lens. *Unit: arcsec* - scale_radius: Tensor + Rs: Tensor Scaling radius of the lens. *Unit: arcsec* @@ -47,10 +45,10 @@ def convergence_0_pseudo_jaffe( *Unit: unitless* """ - return mass / (2 * torch.pi * critical_surface_density * core_radius * scale_radius * (d_l * arcsec_to_rad) ** 2) # fmt: skip + return mass / (2 * torch.pi * critical_surface_density * Rc * Rs * (d_l * arcsec_to_rad) ** 2) # fmt: skip -def mass_enclosed_2d_pseudo_jaffe(radius, mass, core_radius, scale_radius, s=0.0): +def mass_enclosed_2d_pseudo_jaffe(radius, mass, Rc, Rs, s=0.0): """ Compute the mass enclosed within a given radius. See Eliasdottir et al 2007 equation A10. @@ -66,12 +64,12 @@ def mass_enclosed_2d_pseudo_jaffe(radius, mass, core_radius, scale_radius, s=0.0 *Unit: Msun* - core_radius: Tensor + Rc: Tensor Core radius of the lens. *Unit: arcsec* - scale_radius: Tensor + Rs: Tensor Scaling radius of the lens. *Unit: arcsec* @@ -79,17 +77,14 @@ def mass_enclosed_2d_pseudo_jaffe(radius, mass, core_radius, scale_radius, s=0.0 """ theta = radius + s frac_enclosed_num = ( - (core_radius**2 + theta**2).sqrt() - - core_radius - - (scale_radius**2 + theta**2).sqrt() - + scale_radius + (Rc**2 + theta**2).sqrt() - Rc - (Rs**2 + theta**2).sqrt() + Rs ) # arcsec - frac_enclosed_denom = scale_radius - core_radius # arcsec + frac_enclosed_denom = Rs - Rc # arcsec return mass * frac_enclosed_num / frac_enclosed_denom def reduced_deflection_angle_pseudo_jaffe( - x0, y0, mass, core_radius, scale_radius, x, y, d_l, critical_surface_density, s=0.0 + x0, y0, mass, Rc, Rs, x, y, d_l, critical_surface_density, s=0.0 ): """ Compute the reduced deflection angle. See Eliasdottir et al 2007 equation A19. @@ -111,12 +106,12 @@ def reduced_deflection_angle_pseudo_jaffe( *Unit: Msun* - core_radius: Tensor + Rc: Tensor Core radius of the lens. *Unit: arcsec* - scale_radius: Tensor + Rs: Tensor Scaling radius of the lens. *Unit: arcsec* @@ -149,16 +144,14 @@ def reduced_deflection_angle_pseudo_jaffe( """ x, y = translate_rotate(x, y, x0, y0) R = (x**2 + y**2).sqrt() + s - f = R / core_radius / (1 + (1 + (R / core_radius) ** 2).sqrt()) - R / (scale_radius * (1 + (1 + (R / scale_radius) ** 2).sqrt())) # fmt: skip - alpha = 2 * convergence_0_pseudo_jaffe(mass, core_radius, scale_radius, d_l, critical_surface_density) * core_radius * scale_radius / (scale_radius - core_radius) * f # fmt: skip + f = R / Rc / (1 + (1 + (R / Rc) ** 2).sqrt()) - R / (Rs * (1 + (1 + (R / Rs) ** 2).sqrt())) # fmt: skip + alpha = 2 * convergence_0_pseudo_jaffe(mass, Rc, Rs, d_l, critical_surface_density) * Rc * Rs / (Rs - Rc) * f # fmt: skip ax = alpha * x / R ay = alpha * y / R return ax, ay -def potential_pseudo_jaffe( - x0, y0, mass, core_radius, scale_radius, x, y, d_l, d_s, d_ls, s=0.0 -): +def potential_pseudo_jaffe(x0, y0, mass, Rc, Rs, x, y, d_l, d_s, d_ls, s=0.0): """ Compute the lensing potential for the pseudo jaffe lens. See Eliasdottir et al 2007 equation A18. @@ -180,12 +173,12 @@ def potential_pseudo_jaffe( *Unit: Msun* - core_radius: Tensor + Rc: Tensor Core radius of the lens. *Unit: arcsec* - scale_radius: Tensor + Rs: Tensor Scaling radius of the lens. *Unit: arcsec* @@ -224,7 +217,7 @@ def potential_pseudo_jaffe( R_squared = x**2 + y**2 + s # arcsec^2 surface_density_0 = convergence_0_pseudo_jaffe( - mass, core_radius, scale_radius, d_l, 1.0 + mass, Rc, Rs, d_l, 1.0 ) # Msun / Mpc^2 coeff = -( @@ -233,25 +226,21 @@ def potential_pseudo_jaffe( * G_over_c2 * surface_density_0 * (d_l * d_ls / d_s) - * core_radius - * scale_radius - / (scale_radius - core_radius) + * Rc + * Rs + / (Rs - Rc) ) # arcsec - scale_a = (scale_radius**2 + R_squared).sqrt() # arcsec - scale_b = (core_radius**2 + R_squared).sqrt() # arcsec - scale_c = ( - core_radius * (core_radius + (core_radius**2 + R_squared).sqrt()).log() - ) # arcsec - scale_d = ( - scale_radius * (scale_radius + (scale_radius**2 + R_squared).sqrt()).log() - ) # arcsec + scale_a = (Rs**2 + R_squared).sqrt() # arcsec + scale_b = (Rc**2 + R_squared).sqrt() # arcsec + scale_c = Rc * (Rc + (Rc**2 + R_squared).sqrt()).log() # arcsec + scale_d = Rs * (Rs + (Rs**2 + R_squared).sqrt()).log() # arcsec scale_factor = scale_a - scale_b + scale_c - scale_d # arcsec return coeff * scale_factor def convergence_pseudo_jaffe( - x0, y0, mass, core_radius, scale_radius, x, y, d_l, critical_surface_density, s=0.0 + x0, y0, mass, Rc, Rs, x, y, d_l, critical_surface_density, s=0.0 ): """ Compute the convergence (dimensionless surface mass density). See Eliasdottir et al 2007 Equation A3. @@ -273,12 +262,12 @@ def convergence_pseudo_jaffe( *Unit: Msun* - core_radius: Tensor + Rc: Tensor Core radius of the lens. *Unit: arcsec* - scale_radius: Tensor + Rs: Tensor Scaling radius of the lens. *Unit: arcsec* @@ -311,5 +300,5 @@ def convergence_pseudo_jaffe( x, y = translate_rotate(x, y, x0, y0) R_squared = x**2 + y**2 + s - coeff = convergence_0_pseudo_jaffe(mass, core_radius, scale_radius, d_l, critical_surface_density) * core_radius * scale_radius / (scale_radius - core_radius) # fmt: skip - return coeff * (1 / (core_radius**2 + R_squared).sqrt() - 1 / (scale_radius**2 + R_squared).sqrt()) # fmt: skip + coeff = convergence_0_pseudo_jaffe(mass, Rc, Rs, d_l, critical_surface_density) * Rc * Rs / (Rs - Rc) # fmt: skip + return coeff * (1 / (Rc**2 + R_squared).sqrt() - 1 / (Rs**2 + R_squared).sqrt()) # fmt: skip diff --git a/src/caustics/lenses/func/sie.py b/src/caustics/lenses/func/sie.py index 04992fd5..06f17c88 100644 --- a/src/caustics/lenses/func/sie.py +++ b/src/caustics/lenses/func/sie.py @@ -1,10 +1,10 @@ from ...utils import translate_rotate, derotate -def reduced_deflection_angle_sie(x0, y0, q, phi, b, x, y, s=0.0): +def reduced_deflection_angle_sie(x0, y0, q, phi, Rein, x, y, s=0.0): """ Calculate the physical deflection angle. For more detail see Keeton 2002 - equations 34 and 35, although our ``b`` is defined as :math:`\\sqrt(q)b` in + equations 34 and 35, although our ``Rein`` is defined as :math:`b/\\sqrt(q)` in Keeton's notation. Parameters @@ -29,7 +29,7 @@ def reduced_deflection_angle_sie(x0, y0, q, phi, b, x, y, s=0.0): *Unit: radians* - b: Tensor + Rein: Tensor The Einstein radius of the lens. *Unit: arcsec* @@ -65,17 +65,17 @@ def reduced_deflection_angle_sie(x0, y0, q, phi, b, x, y, s=0.0): x, y = translate_rotate(x, y, x0, y0, phi) psi = (q**2 * (x**2 + s**2) + y**2).sqrt() f = (1 - q**2).sqrt() - ax = b * q.sqrt() / f * (f * x / (psi + s)).atan() # fmt: skip - ay = b * q.sqrt() / f * (f * y / (psi + q**2 * s)).atanh() # fmt: skip + ax = Rein * q.sqrt() / f * (f * x / (psi + s)).atan() # fmt: skip + ay = Rein * q.sqrt() / f * (f * y / (psi + q**2 * s)).atanh() # fmt: skip return derotate(ax, ay, phi) -def potential_sie(x0, y0, q, phi, b, x, y, s=0.0): +def potential_sie(x0, y0, q, phi, Rein, x, y, s=0.0): """ Compute the lensing potential. For more detail see Keeton 2002 - equation 33, although our ``b`` is defined as :math:`\\sqrt(q)b` in - Keeton's notation. Also we use the :math:`s \\approx 0` limit here. + equation 33, although our ``Rein`` is defined as :math:`b/\\sqrt(q)` in + Keeton's notation. Parameters ---------- @@ -127,13 +127,22 @@ def potential_sie(x0, y0, q, phi, b, x, y, s=0.0): *Unit: arcsec^2* """ - ax, ay = reduced_deflection_angle_sie(x0, y0, q, phi, b, x, y, s) + ax, ay = reduced_deflection_angle_sie(x0, y0, q, phi, Rein, x, y, s) ax, ay = derotate(ax, ay, -phi) x, y = translate_rotate(x, y, x0, y0, phi) - return x * ax + y * ay - - -def convergence_sie(x0, y0, q, phi, b, x, y, s=0.0): + psi = (q**2 * (x**2 + s**2) + y**2).sqrt() + return ( + x * ax + + y * ay + - Rein + * q.sqrt() + * s + * ((psi + max(s, 1e-6)) ** 2 + (1 - q**2) * x**2).sqrt().log() + + Rein * q.sqrt() * s * ((1 + q) * max(s, 1e-6)).log() + ) + + +def convergence_sie(x0, y0, q, phi, Rein, x, y, s=0.0): """ Calculate the projected mass density. This is converted from the SIS convergence definition. @@ -160,7 +169,7 @@ def convergence_sie(x0, y0, q, phi, b, x, y, s=0.0): *Unit: radians* - b: Tensor + Rein: Tensor The Einstein radius of the lens. *Unit: arcsec* @@ -190,4 +199,4 @@ def convergence_sie(x0, y0, q, phi, b, x, y, s=0.0): """ x, y = translate_rotate(x, y, x0, y0, phi) psi = (q**2 * (x**2 + s**2) + y**2).sqrt() - return 0.5 * q.sqrt() * b / psi + return 0.5 * q.sqrt() * Rein / psi diff --git a/src/caustics/lenses/func/sis.py b/src/caustics/lenses/func/sis.py index 6bac8347..091f96cd 100644 --- a/src/caustics/lenses/func/sis.py +++ b/src/caustics/lenses/func/sis.py @@ -1,7 +1,7 @@ from ...utils import translate_rotate -def reduced_deflection_angle_sis(x0, y0, th_ein, x, y, s=0.0): +def reduced_deflection_angle_sis(x0, y0, Rein, x, y, s=0.0): """ Compute the reduced deflection angles. See the Meneghetti lecture notes equation 3.46. @@ -17,7 +17,7 @@ def reduced_deflection_angle_sis(x0, y0, th_ein, x, y, s=0.0): *Unit: arcsec* - th_ein: Tensor + Rein: Tensor Einstein radius of the lens. *Unit: arcsec* @@ -52,12 +52,12 @@ def reduced_deflection_angle_sis(x0, y0, th_ein, x, y, s=0.0): """ x, y = translate_rotate(x, y, x0, y0) R = (x**2 + y**2).sqrt() + s - ax = th_ein * x / R - ay = th_ein * y / R + ax = Rein * x / R + ay = Rein * y / R return ax, ay -def potential_sis(x0, y0, th_ein, x, y, s=0.0): +def potential_sis(x0, y0, Rein, x, y, s=0.0): """ Compute the lensing potential. See the Meneghetti lecture notes equation 3.45. @@ -73,7 +73,7 @@ def potential_sis(x0, y0, th_ein, x, y, s=0.0): *Unit: arcsec* - th_ein: Tensor + Rein: Tensor Einstein radius of the lens. *Unit: arcsec* @@ -103,10 +103,10 @@ def potential_sis(x0, y0, th_ein, x, y, s=0.0): """ x, y = translate_rotate(x, y, x0, y0) R = (x**2 + y**2).sqrt() + s - return th_ein * R + return Rein * R -def convergence_sis(x0, y0, th_ein, x, y, s=0.0): +def convergence_sis(x0, y0, Rein, x, y, s=0.0): """ Compute the lensing convergence. See the Meneghetti lecture notes equation 3.44. @@ -122,7 +122,7 @@ def convergence_sis(x0, y0, th_ein, x, y, s=0.0): *Unit: arcsec* - th_ein: Tensor + Rein: Tensor Einstein radius of the lens. *Unit: arcsec* @@ -152,4 +152,4 @@ def convergence_sis(x0, y0, th_ein, x, y, s=0.0): """ x, y = translate_rotate(x, y, x0, y0) R = (x**2 + y**2).sqrt() + s - return 0.5 * th_ein / R + return 0.5 * Rein / R diff --git a/src/caustics/lenses/func/tnfw.py b/src/caustics/lenses/func/tnfw.py index ee6c4988..49302b2a 100644 --- a/src/caustics/lenses/func/tnfw.py +++ b/src/caustics/lenses/func/tnfw.py @@ -4,7 +4,7 @@ from ...utils import translate_rotate -def concentration_tnfw(mass, scale_radius, critical_density, d_l, DELTA=200.0): +def concentration_tnfw(mass, Rs, critical_density, d_l, DELTA=200.0): """ Compute the concentration parameter "c" for a TNFW profile. @@ -15,7 +15,7 @@ def concentration_tnfw(mass, scale_radius, critical_density, d_l, DELTA=200.0): *Unit: Msun* - scale_radius: Tensor + Rs: Tensor The scale radius of the TNFW lens. *Unit: arcsec* @@ -44,7 +44,7 @@ def concentration_tnfw(mass, scale_radius, critical_density, d_l, DELTA=200.0): """ r_delta = (3 * mass / (4 * torch.pi * DELTA * critical_density)) ** (1 / 3) # fmt: skip - return r_delta / (scale_radius * d_l * arcsec_to_rad) # fmt: skip + return r_delta / (Rs * d_l * arcsec_to_rad) # fmt: skip def _F_batchable_tnfw(x): @@ -93,12 +93,12 @@ def M0_totmass_tnfw(mass, tau): return mass * (tau**2 + 1) ** 2 / (tau**2 * ((tau**2 - 1) * tau.log() + torch.pi * tau - (tau**2 + 1))) # fmt: skip -def M0_scalemass_tnfw(scale_radius, c, critical_density, d_l, DELTA=200.0): +def M0_scalemass_tnfw(Rs, c, critical_density, d_l, DELTA=200.0): """What M0 would be for an NFW Parameters ---------- - scale_radius: Tensor + Rs: Tensor The scale radius of the TNFW lens. *Unit: arcsec* @@ -123,12 +123,12 @@ def M0_scalemass_tnfw(scale_radius, c, critical_density, d_l, DELTA=200.0): *Unit: unitless* """ - return 4 * torch.pi * (scale_radius * d_l * arcsec_to_rad) ** 3 * scale_density_tnfw(c, critical_density, DELTA) # fmt: skip + return 4 * torch.pi * (Rs * d_l * arcsec_to_rad) ** 3 * scale_density_tnfw(c, critical_density, DELTA) # fmt: skip def mass_enclosed_2d_tnfw( r, - scale_radius, + Rs, tau, M0, _F_mode="differentiable", @@ -149,7 +149,7 @@ def mass_enclosed_2d_tnfw( *Unit: Msun* - scale_radius: Tensor + Rs: Tensor Scale radius of the TNFW lens. *Unit: arcsec* @@ -167,7 +167,7 @@ def mass_enclosed_2d_tnfw( *Unit: Msun* """ - g = r / scale_radius + g = r / Rs t2 = tau**2 if _F_mode == "differentiable": F = _F_differentiable(g) @@ -187,7 +187,7 @@ def mass_enclosed_2d_tnfw( def physical_deflection_angle_tnfw( x0, y0, - scale_radius, + Rs, tau, x, y, @@ -212,7 +212,7 @@ def physical_deflection_angle_tnfw( *Unit: arcsec* - scale_radius: Tensor + Rs: Tensor The scale radius of the TNFW lens. *Unit: arcsec* @@ -258,7 +258,7 @@ def physical_deflection_angle_tnfw( theta = torch.arctan2(y, x) # The below actually equally comes from eq 2.13 in Meneghetti notes - dr = mass_enclosed_2d_tnfw(r, scale_radius, tau, M0,_F_mode) / ( + dr = mass_enclosed_2d_tnfw(r, Rs, tau, M0,_F_mode) / ( r * d_l * arcsec_to_rad ) # note dpsi(u)/du = 2x*dpsi(x)/dx when u = x^2 # fmt: skip S = 4 * G_over_c2 * rad_to_arcsec @@ -268,7 +268,7 @@ def physical_deflection_angle_tnfw( def convergence_tnfw( x0, y0, - scale_radius, + Rs, tau, x, y, @@ -294,7 +294,7 @@ def convergence_tnfw( *Unit: arcsec* - scale_radius: Tensor + Rs: Tensor The scale radius of the TNFW lens. *Unit: arcsec* @@ -336,7 +336,7 @@ def convergence_tnfw( """ x, y = translate_rotate(x, y, x0, y0) r = (x**2 + y**2).sqrt() + s - g = r / scale_radius + g = r / Rs if _F_mode == "differentiable": F = _F_differentiable(g) elif _F_mode == "batchable": @@ -345,7 +345,7 @@ def convergence_tnfw( raise ValueError("_F_mode must be 'differentiable' or 'batchable'") L = _L_tnfw(g, tau) - S = M0 / (2 * torch.pi * (scale_radius * d_l * arcsec_to_rad) ** 2) # fmt: skip + S = M0 / (2 * torch.pi * (Rs * d_l * arcsec_to_rad) ** 2) # fmt: skip t2 = tau**2 a1 = t2 / (t2 + 1) ** 2 @@ -359,7 +359,7 @@ def convergence_tnfw( def potential_tnfw( x0, y0, - scale_radius, + Rs, tau, x, y, @@ -386,7 +386,7 @@ def potential_tnfw( *Unit: arcsec* - scale_radius: Tensor + Rs: Tensor The scale radius of the TNFW lens. *Unit: arcsec* @@ -438,7 +438,7 @@ def potential_tnfw( """ x, y = translate_rotate(x, y, x0, y0) r = (x**2 + y**2).sqrt() + s - g = r / scale_radius + g = r / Rs t2 = tau**2 u = g**2 if _F_mode == "differentiable": diff --git a/src/caustics/lenses/point.py b/src/caustics/lenses/point.py index 13f29b73..4484fc3f 100644 --- a/src/caustics/lenses/point.py +++ b/src/caustics/lenses/point.py @@ -37,7 +37,7 @@ class Point(ThinLens): *Unit: arcsec* - th_ein: Optional[Union[Tensor, float]] + Rein: Optional[Union[Tensor, float]] Einstein radius of the lens. *Unit: arcsec* @@ -52,7 +52,7 @@ class Point(ThinLens): _null_params = { "x0": 0.0, "y0": 0.0, - "th_ein": 1.0, + "Rein": 1.0, } def __init__( @@ -69,7 +69,7 @@ def __init__( "Y coordinate of the center of the lens", True, ] = None, - th_ein: Annotated[ + Rein: Annotated[ Optional[Union[Tensor, float]], "Einstein radius of the lens", True ] = None, s: Annotated[ @@ -103,7 +103,7 @@ def __init__( *Unit: arcsec* - th_ein: Optional[Tensor] + Rein: Optional[Tensor] Einstein radius of the lens. *Unit: arcsec* @@ -118,7 +118,7 @@ def __init__( self.x0 = Param("x0", x0, units="arcsec") self.y0 = Param("y0", y0, units="arcsec") - self.th_ein = Param("th_ein", th_ein, units="arcsec", valid=(0, None)) + self.Rein = Param("Rein", Rein, units="arcsec", valid=(0, None)) self.s = s @forward @@ -185,7 +185,7 @@ def reduced_deflection_angle( z_s: Tensor, x0: Annotated[Tensor, "Param"], y0: Annotated[Tensor, "Param"], - th_ein: Annotated[Tensor, "Param"], + Rein: Annotated[Tensor, "Param"], ) -> tuple[Tensor, Tensor]: """ Compute the deflection angles. @@ -223,7 +223,7 @@ def reduced_deflection_angle( *Unit: arcsec* """ - return func.reduced_deflection_angle_point(x0, y0, th_ein, x, y, self.s) + return func.reduced_deflection_angle_point(x0, y0, Rein, x, y, self.s) @forward def potential( @@ -233,7 +233,7 @@ def potential( z_s: Tensor, x0: Annotated[Tensor, "Param"], y0: Annotated[Tensor, "Param"], - th_ein: Annotated[Tensor, "Param"], + Rein: Annotated[Tensor, "Param"], ) -> Tensor: """ Compute the lensing potential. @@ -266,7 +266,7 @@ def potential( *Unit: arcsec^2* """ - return func.potential_point(x0, y0, th_ein, x, y, self.s) + return func.potential_point(x0, y0, Rein, x, y, self.s) @forward def convergence( diff --git a/src/caustics/lenses/pseudo_jaffe.py b/src/caustics/lenses/pseudo_jaffe.py index 2869bcfa..f4b1cd96 100644 --- a/src/caustics/lenses/pseudo_jaffe.py +++ b/src/caustics/lenses/pseudo_jaffe.py @@ -45,12 +45,12 @@ class PseudoJaffe(ThinLens): *Unit: Msun* - core_radius: Optional[Union[Tensor, float]] + Rc: Optional[Union[Tensor, float]] Core radius of the lens (arcsec). *Unit: arcsec* - scale_radius: Optional[Union[Tensor, float]] + Rs: Optional[Union[Tensor, float]] Scaling radius of the lens (arcsec). *Unit: arcsec* @@ -66,8 +66,8 @@ class PseudoJaffe(ThinLens): "x0": 0.0, "y0": 0.0, "mass": 1e12, - "core_radius": 0.1, - "scale_radius": 1.0, + "Rc": 0.1, + "Rs": 1.0, } def __init__( @@ -87,10 +87,10 @@ def __init__( mass: Annotated[ Optional[Union[Tensor, float]], "Total mass of the lens", True, "Msol" ] = None, - core_radius: Annotated[ + Rc: Annotated[ Optional[Union[Tensor, float]], "Core radius of the lens", True, "arcsec" ] = None, - scale_radius: Annotated[ + Rs: Annotated[ Optional[Union[Tensor, float]], "Scaling radius of the lens", True, @@ -132,12 +132,12 @@ def __init__( *Unit: Msun* - core_radius: Optional[Tensor] + Rc: Optional[Tensor] Core radius of the lens. *Unit: arcsec* - scale_radius: Optional[Tensor] + Rs: Optional[Tensor] Scaling radius of the lens. *Unit: arcsec* @@ -153,12 +153,8 @@ def __init__( self.x0 = Param("x0", x0, units="arcsec") self.y0 = Param("y0", y0, units="arcsec") self.mass = Param("mass", mass, units="Msun", valid=(0, None)) - self.core_radius = Param( - "core_radius", core_radius, units="arcsec", valid=(0, None) - ) - self.scale_radius = Param( - "scale_radius", scale_radius, units="arcsec", valid=(0, None) - ) + self.Rc = Param("Rc", Rc, units="arcsec", valid=(0, None)) + self.Rs = Param("Rs", Rs, units="arcsec", valid=(0, None)) self.s = s @forward @@ -167,12 +163,12 @@ def get_convergence_0( z_s, z_l: Annotated[Tensor, "Param"], mass: Annotated[Tensor, "Param"], - core_radius: Annotated[Tensor, "Param"], - scale_radius: Annotated[Tensor, "Param"], + Rc: Annotated[Tensor, "Param"], + Rs: Annotated[Tensor, "Param"], ): d_l = self.cosmology.angular_diameter_distance(z_l) sigma_crit = self.cosmology.critical_surface_density(z_l, z_s) - return mass / (2 * torch.pi * sigma_crit * core_radius * scale_radius * (d_l * arcsec_to_rad) ** 2) # fmt: skip + return mass / (2 * torch.pi * sigma_crit * Rc * Rs * (d_l * arcsec_to_rad) ** 2) # fmt: skip @forward def mass_enclosed_2d( @@ -180,8 +176,8 @@ def mass_enclosed_2d( theta, z_s, mass: Annotated[Tensor, "Param"], - core_radius: Annotated[Tensor, "Param"], - scale_radius: Annotated[Tensor, "Param"], + Rc: Annotated[Tensor, "Param"], + Rs: Annotated[Tensor, "Param"], ): """ Calculate the mass enclosed within a two-dimensional radius. Using equation A10 from `Eliasdottir et al 2007 `_. @@ -209,17 +205,15 @@ def mass_enclosed_2d( *Unit: Msun* """ - return func.mass_enclosed_2d_pseudo_jaffe( - theta, mass, core_radius, scale_radius - ) + return func.mass_enclosed_2d_pseudo_jaffe(theta, mass, Rc, Rs) @staticmethod def central_convergence( z_l, z_s, rho_0, - core_radius, - scale_radius, + Rc, + Rs, critical_surface_density, ): """ @@ -242,12 +236,12 @@ def central_convergence( *Unit: Msun/Mpc^3* - core_radius: Tensor + Rc: Tensor Core radius of the lens (must be in Mpc). *Unit: Mpc* - scale_radius: Tensor + Rs: Tensor Scaling radius of the lens (must be in Mpc). *Unit: Mpc* @@ -263,7 +257,7 @@ def central_convergence( *Unit: unitless* """ - return pi * rho_0 * core_radius * scale_radius / ((core_radius + scale_radius) * critical_surface_density) # fmt: skip + return pi * rho_0 * Rc * Rs / ((Rc + Rs) * critical_surface_density) # fmt: skip @forward def reduced_deflection_angle( @@ -275,8 +269,8 @@ def reduced_deflection_angle( x0: Annotated[Tensor, "Param"], y0: Annotated[Tensor, "Param"], mass: Annotated[Tensor, "Param"], - core_radius: Annotated[Tensor, "Param"], - scale_radius: Annotated[Tensor, "Param"], + Rc: Annotated[Tensor, "Param"], + Rs: Annotated[Tensor, "Param"], ) -> tuple[Tensor, Tensor]: """Calculate the deflection angle. @@ -315,7 +309,7 @@ def reduced_deflection_angle( """ d_l = self.cosmology.angular_diameter_distance(z_l) critical_surface_density = self.cosmology.critical_surface_density(z_l, z_s) - return func.reduced_deflection_angle_pseudo_jaffe(x0, y0, mass, core_radius, scale_radius, x, y, d_l, critical_surface_density) # fmt: skip + return func.reduced_deflection_angle_pseudo_jaffe(x0, y0, mass, Rc, Rs, x, y, d_l, critical_surface_density) # fmt: skip @forward def potential( @@ -327,8 +321,8 @@ def potential( x0: Annotated[Tensor, "Param"], y0: Annotated[Tensor, "Param"], mass: Annotated[Tensor, "Param"], - core_radius: Annotated[Tensor, "Param"], - scale_radius: Annotated[Tensor, "Param"], + Rc: Annotated[Tensor, "Param"], + Rs: Annotated[Tensor, "Param"], ) -> Tensor: """ Compute the lensing potential. This calculation is based on equation A18 from `Eliasdottir et al 2007 `_. @@ -366,7 +360,7 @@ def potential( d_s = self.cosmology.angular_diameter_distance(z_s) # Mpc d_ls = self.cosmology.angular_diameter_distance_z1z2(z_l, z_s) # Mpc - return func.potential_pseudo_jaffe(x0, y0, mass, core_radius, scale_radius, x, y, d_l, d_s, d_ls) # fmt: skip + return func.potential_pseudo_jaffe(x0, y0, mass, Rc, Rs, x, y, d_l, d_s, d_ls) # fmt: skip @forward def convergence( @@ -378,8 +372,8 @@ def convergence( x0: Annotated[Tensor, "Param"], y0: Annotated[Tensor, "Param"], mass: Annotated[Tensor, "Param"], - core_radius: Annotated[Tensor, "Param"], - scale_radius: Annotated[Tensor, "Param"], + Rc: Annotated[Tensor, "Param"], + Rs: Annotated[Tensor, "Param"], ) -> Tensor: """ Calculate the projected mass density, based on equation A6. @@ -415,5 +409,5 @@ def convergence( d_l = self.cosmology.angular_diameter_distance(z_l) critical_surface_density = self.cosmology.critical_surface_density(z_l, z_s) return func.convergence_pseudo_jaffe( - x0, y0, mass, core_radius, scale_radius, x, y, d_l, critical_surface_density + x0, y0, mass, Rc, Rs, x, y, d_l, critical_surface_density ) diff --git a/src/caustics/lenses/sie.py b/src/caustics/lenses/sie.py index 1968d777..1e6ad65f 100644 --- a/src/caustics/lenses/sie.py +++ b/src/caustics/lenses/sie.py @@ -48,7 +48,7 @@ class SIE(ThinLens): *Unit: radians* - b: Optional[Union[Tensor, float]] + Rein: Optional[Union[Tensor, float]] The Einstein radius of the lens. *Unit: arcsec* @@ -65,7 +65,7 @@ class SIE(ThinLens): "y0": 0.0, "q": 0.5, "phi": 0.0, - "b": 1.0, + "Rein": 1.0, } def __init__( @@ -86,7 +86,7 @@ def __init__( "The orientation angle of the lens (position angle)", True, ] = None, - b: Annotated[ + Rein: Annotated[ Optional[Union[Tensor, float]], "The Einstein radius of the lens", True ] = None, s: Annotated[float, "The core radius of the lens"] = 0.0, @@ -101,39 +101,39 @@ def __init__( self.y0 = Param("y0", y0, units="arcsec") self.q = Param("q", q, units="unitless", valid=(0, 1)) self.phi = Param("phi", phi, units="radians", valid=(0, pi), cyclic=True) - self.b = Param("b", b, units="arcsec", valid=(0, None)) + self.Rein = Param("Rein", Rein, units="arcsec", valid=(0, None)) self.s = s - def _get_potential(self, x, y, q): - """ - Compute the radial coordinate in the lens plane. + # def _get_potential(self, x, y, q): + # """ + # Compute the radial coordinate in the lens plane. - Parameters - ---------- - x: Tensor - The x-coordinate in the lens plane. + # Parameters + # ---------- + # x: Tensor + # The x-coordinate in the lens plane. - *Unit: arcsec* + # *Unit: arcsec* - y: Tensor - The y-coordinate in the lens plane. + # y: Tensor + # The y-coordinate in the lens plane. - *Unit: arcsec* + # *Unit: arcsec* - q: Tensor - The axis ratio of the lens. + # q: Tensor + # The axis ratio of the lens. - *Unit: unitless* + # *Unit: unitless* - Returns - -------- - Tensor - The radial coordinate in the lens plane. + # Returns + # -------- + # Tensor + # The radial coordinate in the lens plane. - *Unit: arcsec* + # *Unit: arcsec* - """ - return (q**2 * (x**2 + self.s**2) + y**2).sqrt() # fmt: skip + # """ + # return (q**2 * (x**2 + self.s**2) + y**2).sqrt() # fmt: skip @forward def reduced_deflection_angle( @@ -145,7 +145,7 @@ def reduced_deflection_angle( y0: Annotated[Tensor, "Param"], q: Annotated[Tensor, "Param"], phi: Annotated[Tensor, "Param"], - b: Annotated[Tensor, "Param"], + Rein: Annotated[Tensor, "Param"], ) -> tuple[Tensor, Tensor]: """ Calculate the physical deflection angle. @@ -183,7 +183,7 @@ def reduced_deflection_angle( *Unit: arcsec* """ - return func.reduced_deflection_angle_sie(x0, y0, q, phi, b, x, y, self.s) + return func.reduced_deflection_angle_sie(x0, y0, q, phi, Rein, x, y, self.s) @forward def potential( @@ -195,7 +195,7 @@ def potential( y0: Annotated[Tensor, "Param"], q: Annotated[Tensor, "Param"], phi: Annotated[Tensor, "Param"], - b: Annotated[Tensor, "Param"], + Rein: Annotated[Tensor, "Param"], ) -> Tensor: """ Compute the lensing potential. @@ -228,7 +228,7 @@ def potential( *Unit: arcsec^2* """ - return func.potential_sie(x0, y0, q, phi, b, x, y, self.s) + return func.potential_sie(x0, y0, q, phi, Rein, x, y, self.s) @forward def convergence( @@ -240,7 +240,7 @@ def convergence( y0: Annotated[Tensor, "Param"], q: Annotated[Tensor, "Param"], phi: Annotated[Tensor, "Param"], - b: Annotated[Tensor, "Param"], + Rein: Annotated[Tensor, "Param"], ) -> Tensor: """ Calculate the projected mass density. @@ -273,4 +273,4 @@ def convergence( *Unit: unitless* """ - return func.convergence_sie(x0, y0, q, phi, b, x, y, self.s) + return func.convergence_sie(x0, y0, q, phi, Rein, x, y, self.s) diff --git a/src/caustics/lenses/sis.py b/src/caustics/lenses/sis.py index 7d25beec..9d6bd37d 100644 --- a/src/caustics/lenses/sis.py +++ b/src/caustics/lenses/sis.py @@ -36,7 +36,7 @@ class SIS(ThinLens): y0: Optional[Union[Tensor, float]] The y-coordinate of the lens center. - th_ein: Optional[Union[Tensor, float]] + Rein: Optional[Union[Tensor, float]] The Einstein radius of the lens. *Unit: arcsec* @@ -51,7 +51,7 @@ class SIS(ThinLens): _null_params = { "x0": 0.0, "y0": 0.0, - "th_ein": 1.0, + "Rein": 1.0, } def __init__( @@ -64,7 +64,7 @@ def __init__( y0: Annotated[ Optional[Union[Tensor, float]], "The y-coordinate of the lens center", True ] = None, - th_ein: Annotated[ + Rein: Annotated[ Optional[Union[Tensor, float]], "The Einstein radius of the lens", True ] = None, s: Annotated[float, "A smoothing factor"] = 0.0, @@ -77,7 +77,7 @@ def __init__( self.x0 = Param("x0", x0, units="arcsec") self.y0 = Param("y0", y0, units="arcsec") - self.th_ein = Param("th_ein", th_ein, units="arcsec", valid=(0, None)) + self.Rein = Param("Rein", Rein, units="arcsec", valid=(0, None)) self.s = s @forward @@ -88,7 +88,7 @@ def reduced_deflection_angle( z_s: Tensor, x0: Annotated[Tensor, "Param"], y0: Annotated[Tensor, "Param"], - th_ein: Annotated[Tensor, "Param"], + Rein: Annotated[Tensor, "Param"], ) -> tuple[Tensor, Tensor]: """ Calculate the deflection angle of the SIS lens. @@ -126,7 +126,7 @@ def reduced_deflection_angle( *Unit: arcsec* """ - return func.reduced_deflection_angle_sis(x0, y0, th_ein, x, y, self.s) + return func.reduced_deflection_angle_sis(x0, y0, Rein, x, y, self.s) @forward def potential( @@ -136,7 +136,7 @@ def potential( z_s: Tensor, x0: Annotated[Tensor, "Param"], y0: Annotated[Tensor, "Param"], - th_ein: Annotated[Tensor, "Param"], + Rein: Annotated[Tensor, "Param"], ) -> Tensor: """ Compute the lensing potential of the SIS lens. @@ -169,7 +169,7 @@ def potential( *Unit: arcsec^2* """ - return func.potential_sis(x0, y0, th_ein, x, y, self.s) + return func.potential_sis(x0, y0, Rein, x, y, self.s) @forward def convergence( @@ -179,7 +179,7 @@ def convergence( z_s: Tensor, x0: Annotated[Tensor, "Param"], y0: Annotated[Tensor, "Param"], - th_ein: Annotated[Tensor, "Param"], + Rein: Annotated[Tensor, "Param"], ) -> Tensor: """ Calculate the projected mass density of the SIS lens. @@ -212,4 +212,4 @@ def convergence( *Unit: unitless* """ - return func.convergence_sis(x0, y0, th_ein, x, y, self.s) + return func.convergence_sis(x0, y0, Rein, x, y, self.s) diff --git a/src/caustics/lenses/tnfw.py b/src/caustics/lenses/tnfw.py index 69bc3a76..fa935166 100644 --- a/src/caustics/lenses/tnfw.py +++ b/src/caustics/lenses/tnfw.py @@ -66,7 +66,7 @@ class TNFW(ThinLens): *Unit: Msun* - scale_radius: Optional[Tensor] + Rs: Optional[Tensor] Scale radius of the TNFW lens. *Unit: arcsec* @@ -100,7 +100,7 @@ class TNFW(ThinLens): "x0": 0.0, "y0": 0.0, "mass": 1e13, - "scale_radius": 1.0, + "Rs": 1.0, "tau": 3.0, } @@ -123,7 +123,7 @@ def __init__( mass: Annotated[ Optional[Union[Tensor, float]], "Mass of the lens", True, "Msol" ] = None, - scale_radius: Annotated[ + Rs: Annotated[ Optional[Union[Tensor, float]], "Scale radius of the TNFW lens", True, @@ -156,9 +156,7 @@ def __init__( self.x0 = Param("x0", x0, units="arcsec") self.y0 = Param("y0", y0, units="arcsec") self.mass = Param("mass", mass, units="Msun", valid=(0, None)) - self.scale_radius = Param( - "scale_radius", scale_radius, units="arcsec", valid=(0, None) - ) + self.Rs = Param("Rs", Rs, units="arcsec", valid=(0, None)) self.tau = Param("tau", tau, units="unitless", valid=(0, None)) self.s = s self.interpret_m_total_mass = interpret_m_total_mass @@ -171,7 +169,7 @@ def get_concentration( self, z_l: Annotated[Tensor, "Param"], mass: Annotated[Tensor, "Param"], - scale_radius: Annotated[Tensor, "Param"], + Rs: Annotated[Tensor, "Param"], ) -> Tensor: """ Compute the concentration parameter "c" for a TNFW profile. @@ -198,7 +196,7 @@ def get_concentration( *Unit: Msun* - scale_radius: Optional[Tensor] + Rs: Optional[Tensor] Scale radius of the TNFW lens. *Unit: arcsec* @@ -221,12 +219,12 @@ def get_concentration( """ critical_density = self.cosmology.critical_density(z_l) d_l = self.cosmology.angular_diameter_distance(z_l) - return func.concentration_tnfw(mass, scale_radius, critical_density, d_l, DELTA) + return func.concentration_tnfw(mass, Rs, critical_density, d_l, DELTA) @forward def get_truncation_radius( self, - scale_radius: Annotated[Tensor, "Param"], + Rs: Annotated[Tensor, "Param"], tau: Annotated[Tensor, "Param"], ) -> Tensor: """ @@ -254,7 +252,7 @@ def get_truncation_radius( *Unit: Msun* - scale_radius: Optional[Tensor] + Rs: Optional[Tensor] Scale radius of the TNFW lens. *Unit: arcsec* @@ -275,14 +273,14 @@ def get_truncation_radius( *Unit: arcsec* """ - return tau * scale_radius + return tau * Rs @forward def M0( self, z_l: Annotated[Tensor, "Param"], mass: Annotated[Tensor, "Param"], - scale_radius: Annotated[Tensor, "Param"], + Rs: Annotated[Tensor, "Param"], tau: Annotated[Tensor, "Param"], ) -> Tensor: """ @@ -312,7 +310,7 @@ def M0( *Unit: Msun* - scale_radius: Optional[Tensor] + Rs: Optional[Tensor] Scale radius of the TNFW lens. *Unit: arcsec* @@ -338,17 +336,15 @@ def M0( else: d_l = self.cosmology.angular_diameter_distance(z_l) critical_density = self.cosmology.critical_density(z_l) - c = func.concentration_tnfw( - mass, scale_radius, critical_density, d_l, DELTA - ) - return func.M0_scalemass_tnfw(scale_radius, c, critical_density, d_l, DELTA) + c = func.concentration_tnfw(mass, Rs, critical_density, d_l, DELTA) + return func.M0_scalemass_tnfw(Rs, c, critical_density, d_l, DELTA) @forward def get_scale_density( self, z_l: Annotated[Tensor, "Param"], mass: Annotated[Tensor, "Param"], - scale_radius: Annotated[Tensor, "Param"], + Rs: Annotated[Tensor, "Param"], ) -> Tensor: """ Calculate the scale density of the lens. @@ -375,7 +371,7 @@ def get_scale_density( *Unit: Msun* - scale_radius: Optional[Tensor] + Rs: Optional[Tensor] Scale radius of the TNFW lens. *Unit: arcsec* @@ -398,7 +394,7 @@ def get_scale_density( """ d_l = self.cosmology.angular_diameter_distance(z_l) critical_density = self.cosmology.critical_density(z_l) - c = func.concentration_tnfw(mass, scale_radius, critical_density, d_l, DELTA) + c = func.concentration_tnfw(mass, Rs, critical_density, d_l, DELTA) return func.scale_density_tnfw(c, critical_density, DELTA) @forward @@ -411,7 +407,7 @@ def convergence( x0: Annotated[Tensor, "Param"], y0: Annotated[Tensor, "Param"], mass: Annotated[Tensor, "Param"], - scale_radius: Annotated[Tensor, "Param"], + Rs: Annotated[Tensor, "Param"], tau: Annotated[Tensor, "Param"], ) -> Tensor: """ @@ -440,7 +436,7 @@ def convergence( *Unit: Msun* - scale_radius: Optional[Tensor] + Rs: Optional[Tensor] Scale radius of the TNFW lens. *Unit: arcsec* @@ -464,11 +460,11 @@ def convergence( d_l = self.cosmology.angular_diameter_distance(z_l) critical_density = self.cosmology.critical_surface_density(z_l, z_s) - M0 = self.M0(z_l=z_l, mass=mass, scale_radius=scale_radius, tau=tau) + M0 = self.M0(z_l=z_l, mass=mass, Rs=Rs, tau=tau) return func.convergence_tnfw( x0, y0, - scale_radius, + Rs, tau, x, y, @@ -484,7 +480,7 @@ def mass_enclosed_2d( self, r: Tensor, z_s: Tensor, - scale_radius: Annotated[Tensor, "Param"], + Rs: Annotated[Tensor, "Param"], tau: Annotated[Tensor, "Param"], ) -> Tensor: """ @@ -512,7 +508,7 @@ def mass_enclosed_2d( *Unit: Msun* - scale_radius: Optional[Tensor] + Rs: Optional[Tensor] Scale radius of the TNFW lens. *Unit: arcsec* @@ -535,7 +531,7 @@ def mass_enclosed_2d( """ M0 = self.M0() - return func.mass_enclosed_2d_tnfw(r, scale_radius, tau, M0, self._F_mode) + return func.mass_enclosed_2d_tnfw(r, Rs, tau, M0, self._F_mode) @forward def physical_deflection_angle( @@ -547,7 +543,7 @@ def physical_deflection_angle( x0: Annotated[Tensor, "Param"], y0: Annotated[Tensor, "Param"], mass: Annotated[Tensor, "Param"], - scale_radius: Annotated[Tensor, "Param"], + Rs: Annotated[Tensor, "Param"], tau: Annotated[Tensor, "Param"], ) -> tuple[Tensor, Tensor]: """Compute the physical deflection angle (arcsec) for this lens at @@ -577,7 +573,7 @@ def physical_deflection_angle( *Unit: Msun* - scale_radius: Optional[Tensor] + Rs: Optional[Tensor] Scale radius of the TNFW lens. *Unit: arcsec* @@ -604,9 +600,9 @@ def physical_deflection_angle( """ d_l = self.cosmology.angular_diameter_distance(z_l) - M0 = self.M0(z_l=z_l, mass=mass, scale_radius=scale_radius, tau=tau) + M0 = self.M0(z_l=z_l, mass=mass, Rs=Rs, tau=tau) return func.physical_deflection_angle_tnfw( - x0, y0, scale_radius, tau, x, y, M0, d_l, self._F_mode, self.s + x0, y0, Rs, tau, x, y, M0, d_l, self._F_mode, self.s ) @forward @@ -619,7 +615,7 @@ def potential( x0: Annotated[Tensor, "Param"], y0: Annotated[Tensor, "Param"], mass: Annotated[Tensor, "Param"], - scale_radius: Annotated[Tensor, "Param"], + Rs: Annotated[Tensor, "Param"], tau: Annotated[Tensor, "Param"], ) -> Tensor: """ @@ -651,7 +647,7 @@ def potential( *Unit: Msun* - scale_radius: Optional[Tensor] + Rs: Optional[Tensor] Scale radius of the TNFW lens. *Unit: arcsec* @@ -677,7 +673,7 @@ def potential( d_s = self.cosmology.angular_diameter_distance(z_s) d_ls = self.cosmology.angular_diameter_distance_z1z2(z_l, z_s) - M0 = self.M0(z_l=z_l, mass=mass, scale_radius=scale_radius, tau=tau) + M0 = self.M0(z_l=z_l, mass=mass, Rs=Rs, tau=tau) return func.potential_tnfw( - x0, y0, scale_radius, tau, x, y, M0, d_l, d_s, d_ls, self._F_mode, self.s + x0, y0, Rs, tau, x, y, M0, d_l, d_s, d_ls, self._F_mode, self.s ) diff --git a/src/caustics/tests.py b/src/caustics/tests.py index d5c29698..3e2f7b94 100644 --- a/src/caustics/tests.py +++ b/src/caustics/tests.py @@ -29,7 +29,7 @@ def _test_simulator_runs(device=DEVICE): y0=0.01, q=0.5, phi=pi / 3.0, - b=1.0, + Rein=1.0, ) source = Sersic( diff --git a/tests/test_base.py b/tests/test_base.py index 94ad97d8..f69cd493 100644 --- a/tests/test_base.py +++ b/tests/test_base.py @@ -20,7 +20,7 @@ def test(device): y0=torch.tensor(0.0), q=torch.tensor(0.4), phi=torch.tensor(np.pi / 5), - b=torch.tensor(1.0), + Rein=torch.tensor(1.0), ) # Send to device lens = lens.to(device) @@ -53,7 +53,7 @@ def test_magnification(device): y0=torch.tensor(0.0), q=torch.tensor(0.4), phi=torch.tensor(np.pi / 5), - b=torch.tensor(1.0), + Rein=torch.tensor(1.0), ) # Send to device lens = lens.to(device) diff --git a/tests/test_epl.py b/tests/test_epl.py index 58e43759..06e268bf 100644 --- a/tests/test_epl.py +++ b/tests/test_epl.py @@ -9,16 +9,15 @@ from caustics.cosmology import FlatLambdaCDM from caustics.lenses import EPL from caustics.sims import build_simulator -import numpy as np import pytest @pytest.mark.parametrize("q", [0.4, 0.7]) @pytest.mark.parametrize("phi", [pi / 3, -pi / 4]) -@pytest.mark.parametrize("b", [0.1, 1.0]) +@pytest.mark.parametrize("Rein", [0.1, 1.0]) @pytest.mark.parametrize("t", [0.1, 1.0, 1.9]) -def test_lenstronomy_epl(sim_source, device, q, phi, b, t): +def test_lenstronomy_epl(sim_source, device, q, phi, Rein, t): if sim_source == "yaml": yaml_str = """\ cosmology: &cosmology @@ -43,10 +42,10 @@ def test_lenstronomy_epl(sim_source, device, q, phi, b, t): # Parameters z_s = torch.tensor(1.0, device=device) - x = torch.tensor([0.7, 0.912, -0.442, q, phi, b, t], device=device) + x = torch.tensor([0.7, 0.912, -0.442, q, phi, Rein, t], device=device) e1, e2 = param_util.phi_q2_ellipticity(phi=phi, q=q) - theta_E = b / np.sqrt(q) # (x[5] / x[3].sqrt()).item() + theta_E = Rein kwargs_ls = [ { "theta_E": theta_E, @@ -84,7 +83,7 @@ def test_special_case_sie(device): z_s = torch.tensor(1.9, device=device) x = torch.tensor([0.7, 0.912, -0.442, 0.7, pi / 3, 1.4, 1.0], device=device) e1, e2 = param_util.phi_q2_ellipticity(phi=x[4].item(), q=x[3].item()) - theta_E = (x[5] / x[3].sqrt()).item() + theta_E = x[5].item() # (x[5] / x[3].sqrt()).item() kwargs_ls = [ { "theta_E": theta_E, diff --git a/tests/test_point.py b/tests/test_point.py index 02d9466f..f999a618 100644 --- a/tests/test_point.py +++ b/tests/test_point.py @@ -11,8 +11,8 @@ import pytest -@pytest.mark.parametrize("th_ein", [0.1, 1.0, 2.0]) -def test_point_lens(sim_source, device, th_ein): +@pytest.mark.parametrize("Rein", [0.1, 1.0, 2.0]) +def test_point_lens(sim_source, device, Rein): atol = 1e-5 rtol = 1e-5 z_l = torch.tensor(0.9) @@ -40,7 +40,7 @@ def test_point_lens(sim_source, device, th_ein): # Parameters z_s = torch.tensor(1.2) - x = torch.tensor([0.912, -0.442, th_ein]) - kwargs_ls = [{"center_x": x[0].item(), "center_y": x[1].item(), "theta_E": th_ein}] + x = torch.tensor([0.912, -0.442, Rein]) + kwargs_ls = [{"center_x": x[0].item(), "center_y": x[1].item(), "theta_E": Rein}] lens_test_helper(lens, lens_ls, z_s, x, kwargs_ls, rtol, atol, device=device) diff --git a/tests/test_sie.py b/tests/test_sie.py index 16f7a879..e99e5be2 100644 --- a/tests/test_sie.py +++ b/tests/test_sie.py @@ -16,8 +16,8 @@ @pytest.mark.parametrize("q", [0.5, 0.7, 0.9]) @pytest.mark.parametrize("phi", [pi / 3, -pi / 4, pi / 6]) -@pytest.mark.parametrize("th_ein", [0.1, 1.0, 2.5]) -def test_sie(sim_source, device, q, phi, th_ein): +@pytest.mark.parametrize("Rein", [0.1, 1.0, 2.5]) +def test_sie(sim_source, device, q, phi, Rein): atol = 1e-5 rtol = 1e-3 @@ -43,11 +43,11 @@ def test_sie(sim_source, device, q, phi, th_ein): # Parameters z_s = torch.tensor(1.2) - x = torch.tensor([0.5, 0.912, -0.442, q, phi, th_ein]) + x = torch.tensor([0.5, 0.912, -0.442, q, phi, Rein]) e1, e2 = param_util.phi_q2_ellipticity(phi=phi, q=q) kwargs_ls = [ { - "theta_E": th_ein, + "theta_E": Rein, "e1": e1, "e2": e2, "center_x": x[1].item(), diff --git a/tests/test_simulator_runs.py b/tests/test_simulator_runs.py index 4a5baa2d..8b3d34ef 100644 --- a/tests/test_simulator_runs.py +++ b/tests/test_simulator_runs.py @@ -27,7 +27,7 @@ def test_simulator_runs(sim_source, device): y0: 0.01 q: 0.5 phi: 1.05 - b: 1.0 + Rein: 1.0 cosmology: *cosmology source: &source @@ -90,7 +90,7 @@ def test_simulator_runs(sim_source, device): y0=0.01, q=0.5, phi=pi / 3.0, - b=1.0, + Rein=1.0, ) source = Sersic( @@ -194,7 +194,7 @@ def test_fft_vs_conv2d(): y0=0.01, q=0.5, phi=pi / 3.0, - b=1.0, + Rein=1.0, ) source = Sersic( @@ -244,7 +244,7 @@ def test_microlens_simulator_runs(): src = Sersic(name="source") x = torch.tensor([ - # z_s z_l x0 y0 q phi b x0 y0 q phi n Re Ie + # z_s z_l x0 y0 q phi Rein x0 y0 q phi n Re Ie 1.5, 0.5, -0.2, 0.0, 0.4, 1.5708, 1.7, 0.0, 0.0, 0.5, -0.985, 1.3, 1.0, 5.0 ]) # fmt: skip fov = torch.tensor((-1, -0.5, -0.25, 0.25)) diff --git a/tests/test_sis.py b/tests/test_sis.py index 2b184713..b9ef3ce3 100644 --- a/tests/test_sis.py +++ b/tests/test_sis.py @@ -11,8 +11,8 @@ import pytest -@pytest.mark.parametrize("th_ein", [0.1, 1.0, 2.0]) -def test(sim_source, device, th_ein): +@pytest.mark.parametrize("Rein", [0.1, 1.0, 2.0]) +def test(sim_source, device, Rein): atol = 1e-5 rtol = 1e-5 z_l = torch.tensor(0.5) @@ -40,7 +40,7 @@ def test(sim_source, device, th_ein): # Parameters z_s = torch.tensor(1.2) - x = torch.tensor([-0.342, 0.51, th_ein]) + x = torch.tensor([-0.342, 0.51, Rein]) kwargs_ls = [ {"center_x": x[0].item(), "center_y": x[1].item(), "theta_E": x[2].item()} ] From 58fac6ecf1186ce4c0d0f879e2bc369d893d086d Mon Sep 17 00:00:00 2001 From: Connor Stone Date: Thu, 19 Dec 2024 17:15:06 -0500 Subject: [PATCH 2/3] nfw mass variable --- src/caustics/lenses/func/nfw.py | 34 ++++++++++----------- src/caustics/lenses/nfw.py | 54 ++++++++++++++++----------------- tests/test_nfw.py | 12 ++++---- 3 files changed, 49 insertions(+), 51 deletions(-) diff --git a/src/caustics/lenses/func/nfw.py b/src/caustics/lenses/func/nfw.py index b9f76814..1b21b6fe 100644 --- a/src/caustics/lenses/func/nfw.py +++ b/src/caustics/lenses/func/nfw.py @@ -4,7 +4,7 @@ from ...constants import G_over_c2, arcsec_to_rad, rad_to_arcsec -def scale_radius_nfw(critical_density, m, c, DELTA=200.0): +def scale_radius_nfw(critical_density, mass, c, DELTA=200.0): """ Compute the scale radius of the NFW profile. @@ -15,7 +15,7 @@ def scale_radius_nfw(critical_density, m, c, DELTA=200.0): *Unit: Msun/Mpc^3* - m: Tensor + mass: Tensor The mass of the halo. *Unit: Msun* @@ -38,7 +38,7 @@ def scale_radius_nfw(critical_density, m, c, DELTA=200.0): *Unit: Mpc* """ - r_delta = (3 * m / (4 * torch.pi * DELTA * critical_density)) ** (1 / 3) # fmt: skip + r_delta = (3 * mass / (4 * torch.pi * DELTA * critical_density)) ** (1 / 3) # fmt: skip return 1 / c * r_delta @@ -74,7 +74,7 @@ def scale_density_nfw(critical_density, c, DELTA=200.0): return DELTA / 3 * critical_density * c**3 / ((1 + c).log() - c / (1 + c)) # fmt: skip -def convergence_s_nfw(critical_surface_density, critical_density, m, c, DELTA): +def convergence_s_nfw(critical_surface_density, critical_density, mass, c, DELTA): """ Compute the dimensionaless surface mass density of the lens. @@ -88,7 +88,7 @@ def convergence_s_nfw(critical_surface_density, critical_density, m, c, DELTA): *Unit: Msun/Mpc^3* - m: Tensor + mass: Tensor The mass of the halo. *Unit: Msun* @@ -110,7 +110,7 @@ def convergence_s_nfw(critical_surface_density, critical_density, m, c, DELTA): *Unit: unitless* """ - Rs = scale_radius_nfw(critical_density, m, c, DELTA) + Rs = scale_radius_nfw(critical_density, mass, c, DELTA) Ds = scale_density_nfw(critical_density, c, DELTA) return Rs * Ds / critical_surface_density @@ -275,7 +275,7 @@ def _h_batchable_nfw(x): def physical_deflection_angle_nfw( x0, y0, - m, + mass, c, critical_density, d_l, @@ -301,7 +301,7 @@ def physical_deflection_angle_nfw( *Unit: arcsec* - m: Tensor + mass: Tensor Mass of the lens. Default is None. *Unit: Msun* @@ -329,7 +329,7 @@ def physical_deflection_angle_nfw( """ x, y = translate_rotate(x, y, x0, y0) th = (x**2 + y**2).sqrt() + s - scale_radius = scale_radius_nfw(critical_density, m, c, DELTA) + scale_radius = scale_radius_nfw(critical_density, mass, c, DELTA) xi = d_l * th * arcsec_to_rad r = xi / scale_radius @@ -345,7 +345,7 @@ def convergence_nfw( critical_density, x0, y0, - m, + mass, c, x, y, @@ -370,7 +370,7 @@ def convergence_nfw( *Unit: Msun/Mpc^3* - m: Tensor + mass: Tensor The mass of the halo c: Optional[Tensor] @@ -395,11 +395,11 @@ def convergence_nfw( """ x, y = translate_rotate(x, y, x0, y0) th = (x**2 + y**2).sqrt() + s - scale_radius = scale_radius_nfw(critical_density, m, c, DELTA) + scale_radius = scale_radius_nfw(critical_density, mass, c, DELTA) xi = d_l * th * arcsec_to_rad r = xi / scale_radius # xi / xi_0 convergence_s = convergence_s_nfw( - critical_surface_density, critical_density, m, c, DELTA + critical_surface_density, critical_density, mass, c, DELTA ) return 2 * convergence_s * _f(r) / (r**2 - 1) # fmt: skip @@ -409,7 +409,7 @@ def potential_nfw( critical_density, x0, y0, - m, + mass, c, d_l, x, @@ -434,7 +434,7 @@ def potential_nfw( *Unit: Msun/Mpc^3* - m: Tensor + mass: Tensor The mass of the halo c: Optional[Tensor] @@ -459,10 +459,10 @@ def potential_nfw( """ x, y = translate_rotate(x, y, x0, y0) th = (x**2 + y**2).sqrt() + s - scale_radius = scale_radius_nfw(critical_density, m, c, DELTA) + scale_radius = scale_radius_nfw(critical_density, mass, c, DELTA) xi = d_l * th * arcsec_to_rad r = xi / scale_radius # xi / xi_0 convergence_s = convergence_s_nfw( - critical_surface_density, critical_density, m, c, DELTA + critical_surface_density, critical_density, mass, c, DELTA ) return 2 * convergence_s * _g(r) * scale_radius**2 / (d_l**2 * arcsec_to_rad**2) # fmt: skip diff --git a/src/caustics/lenses/nfw.py b/src/caustics/lenses/nfw.py index 3b6119a4..00c585de 100644 --- a/src/caustics/lenses/nfw.py +++ b/src/caustics/lenses/nfw.py @@ -35,7 +35,7 @@ class NFW(ThinLens): *Unit: arcsec* - m: Optional[Tensor] + mass: Optional[Tensor] Mass of the lens. Default is None. *Unit: Msun* @@ -80,7 +80,7 @@ class NFW(ThinLens): _null_params = { "x0": 0.0, "y0": 0.0, - "m": 1e13, + "mass": 1e13, "c": 5.0, } @@ -94,7 +94,9 @@ def __init__( y0: Annotated[ Optional[Union[Tensor, float]], "Y coordinate of the lens center", True ] = None, - m: Annotated[Optional[Union[Tensor, float]], "Mass of the lens", True] = None, + mass: Annotated[ + Optional[Union[Tensor, float]], "Mass of the lens", True + ] = None, c: Annotated[ Optional[Union[Tensor, float]], "Concentration parameter of the lens", True ] = None, @@ -136,7 +138,7 @@ def __init__( *Unit: arcsec* - m: Optional[Union[Tensor, float]] + mass: Optional[Union[Tensor, float]] Mass of the lens. Default is None. *Unit: Msun* @@ -157,7 +159,7 @@ def __init__( self.x0 = Param("x0", x0, units="arcsec") self.y0 = Param("y0", y0, units="arcsec") - self.m = Param("m", m, units="Msun") + self.mass = Param("mass", mass, units="Msun") self.c = Param("c", c, units="unitless") self.s = s if use_case == "batchable": @@ -175,7 +177,7 @@ def __init__( def get_scale_radius( self, z_l: Annotated[Tensor, "Param"], - m: Annotated[Tensor, "Param"], + mass: Annotated[Tensor, "Param"], c: Annotated[Tensor, "Param"], ) -> Tensor: """ @@ -188,7 +190,7 @@ def get_scale_radius( *Unit: unitless* - m: Tensor + mass: Tensor Mass of the lens. *Unit: Msun* @@ -198,11 +200,6 @@ def get_scale_radius( *Unit: unitless* - x: dict - Dynamic parameter container. - - *Unit: unitless* - Returns ------- Tensor @@ -212,7 +209,7 @@ def get_scale_radius( """ critical_density = self.cosmology.critical_density(z_l) - return func.scale_radius_nfw(critical_density, m, c, DELTA) + return func.scale_radius_nfw(critical_density, mass, c, DELTA) @forward def get_scale_density( @@ -235,9 +232,6 @@ def get_scale_density( *Unit: unitless* - params: Packed, optional - Dynamic parameter container. - Returns ------- Tensor @@ -258,7 +252,7 @@ def physical_deflection_angle( z_l: Annotated[Tensor, "Param"], x0: Annotated[Tensor, "Param"], y0: Annotated[Tensor, "Param"], - m: Annotated[Tensor, "Param"], + mass: Annotated[Tensor, "Param"], c: Annotated[Tensor, "Param"], ) -> tuple[Tensor, Tensor]: """ @@ -281,9 +275,6 @@ def physical_deflection_angle( *Unit: unitless* - params: Packed, optional - Dynamic parameter container. - Returns ------- x_component: Tensor @@ -300,7 +291,17 @@ def physical_deflection_angle( d_l = self.cosmology.angular_diameter_distance(z_l) critical_density = self.cosmology.critical_density(z_l) return func.physical_deflection_angle_nfw( - x0, y0, m, c, critical_density, d_l, x, y, _h=self._h, DELTA=DELTA, s=self.s + x0, + y0, + mass, + c, + critical_density, + d_l, + x, + y, + _h=self._h, + DELTA=DELTA, + s=self.s, ) @forward @@ -312,7 +313,7 @@ def convergence( z_l: Annotated[Tensor, "Param"], x0: Annotated[Tensor, "Param"], y0: Annotated[Tensor, "Param"], - m: Annotated[Tensor, "Param"], + mass: Annotated[Tensor, "Param"], c: Annotated[Tensor, "Param"], ) -> Tensor: """ @@ -335,9 +336,6 @@ def convergence( *Unit: unitless* - params: Packed, optional - Dynamic parameter container. - Returns ------- Tensor @@ -354,7 +352,7 @@ def convergence( critical_density, x0, y0, - m, + mass, c, x, y, @@ -373,7 +371,7 @@ def potential( z_l: Annotated[Tensor, "Param"], x0: Annotated[Tensor, "Param"], y0: Annotated[Tensor, "Param"], - m: Annotated[Tensor, "Param"], + mass: Annotated[Tensor, "Param"], c: Annotated[Tensor, "Param"], ) -> Tensor: """ @@ -415,7 +413,7 @@ def potential( critical_density, x0, y0, - m, + mass, c, d_l, x, diff --git a/tests/test_nfw.py b/tests/test_nfw.py index 85cd2515..28762cbd 100644 --- a/tests/test_nfw.py +++ b/tests/test_nfw.py @@ -21,9 +21,9 @@ Ob0_default = float(default_cosmology.get().Ob0) -@pytest.mark.parametrize("m", [1e8, 1e10, 1e12]) +@pytest.mark.parametrize("mass", [1e8, 1e10, 1e12]) @pytest.mark.parametrize("c", [1.0, 8.0, 20.0]) -def test_nfw(sim_source, device, m, c): +def test_nfw(sim_source, device, mass, c): atol = 1e-5 rtol = 3e-2 z_l = torch.tensor(0.1) @@ -59,12 +59,12 @@ def test_nfw(sim_source, device, m, c): thy0 = 0.141 # m = 1e12 # c = 8.0 - x = torch.tensor([thx0, thy0, m, c]) + x = torch.tensor([thx0, thy0, mass, c]) # Lenstronomy cosmo = FlatLambdaCDM_AP(H0=h0_default * 100, Om0=Om0_default, Ob0=Ob0_default) lens_cosmo = LensCosmo(z_lens=z_l.item(), z_source=z_s.item(), cosmo=cosmo) - Rs_angle, alpha_Rs = lens_cosmo.nfw_physical2angle(M=m, c=c) + Rs_angle, alpha_Rs = lens_cosmo.nfw_physical2angle(M=mass, c=c) # lenstronomy params ['Rs', 'alpha_Rs', 'center_x', 'center_y'] kwargs_ls = [ @@ -111,9 +111,9 @@ def test_runs(sim_source, device): thx0 = 0.457 thy0 = 0.141 - m = 1e12 + mass = 1e12 rs = 8.0 - x = torch.tensor([thx0, thy0, m, rs]) + x = torch.tensor([thx0, thy0, mass, rs]) thx, thy, thx_ls, thy_ls = setup_grids(device=device) From 165a17dfb808ff3d99b49b5be1c4747d7e532c17 Mon Sep 17 00:00:00 2001 From: Connor Stone Date: Thu, 19 Dec 2024 17:29:27 -0500 Subject: [PATCH 3/3] Update doc tutorials --- .../source/examples/Example_ImageFit_LM.ipynb | 2 +- .../examples/Example_ImageFit_MCMC.ipynb | 2 +- docs/source/examples/Example_QSOLensFit.ipynb | 4 +- docs/source/gravlensingintro.ipynb | 46 ++++++++++++------- .../InterfaceIntroduction_func.ipynb | 6 +-- .../tutorials/InterfaceIntroduction_oop.ipynb | 4 +- .../InterfaceIntroduction_yaml.ipynb | 4 +- docs/source/tutorials/Introduction.ipynb | 20 ++++---- .../source/tutorials/InvertLensEquation.ipynb | 2 +- docs/source/tutorials/LensZoo.ipynb | 16 +++---- docs/source/tutorials/Microlensing.ipynb | 10 ++-- docs/source/tutorials/MultiplaneDemo.ipynb | 2 +- docs/source/tutorials/VisualizeCaustics.ipynb | 2 +- 13 files changed, 66 insertions(+), 54 deletions(-) diff --git a/docs/source/examples/Example_ImageFit_LM.ipynb b/docs/source/examples/Example_ImageFit_LM.ipynb index 3a497672..a92c1d60 100644 --- a/docs/source/examples/Example_ImageFit_LM.ipynb +++ b/docs/source/examples/Example_ImageFit_LM.ipynb @@ -151,7 +151,7 @@ " \"y0\": 0.0,\n", " \"q\": 0.86,\n", " \"phi\": -0.20,\n", - " \"b\": 0.66,\n", + " \"Rein\": 0.66,\n", " },\n", " \"externalshear\": {\"gamma_1\": 0.0, \"gamma_2\": -0.05},\n", " \"sourcelight\": {\n", diff --git a/docs/source/examples/Example_ImageFit_MCMC.ipynb b/docs/source/examples/Example_ImageFit_MCMC.ipynb index 4f8db318..e0f3f0be 100644 --- a/docs/source/examples/Example_ImageFit_MCMC.ipynb +++ b/docs/source/examples/Example_ImageFit_MCMC.ipynb @@ -160,7 +160,7 @@ " \"y0\": 0.0,\n", " \"q\": 0.86,\n", " \"phi\": -0.20,\n", - " \"b\": 0.66,\n", + " \"Rein\": 0.66,\n", " },\n", " \"externalshear\": {\"gamma_1\": 0.0, \"gamma_2\": -0.05},\n", " \"sourcelight\": {\n", diff --git a/docs/source/examples/Example_QSOLensFit.ipynb b/docs/source/examples/Example_QSOLensFit.ipynb index 15783f25..6e653a0d 100644 --- a/docs/source/examples/Example_QSOLensFit.ipynb +++ b/docs/source/examples/Example_QSOLensFit.ipynb @@ -75,7 +75,7 @@ "sp_x = torch.tensor(0.2)\n", "sp_y = torch.tensor(0.2)\n", "\n", - "# true parameters x0 y0 q phi b\n", + "# true parameters x0 y0 q phi Rein\n", "params = torch.tensor([0.0, 0.0, 0.4, np.pi / 5, 1.0])\n", "# Points in image plane\n", "x, y = lens.forward_raytrace(sp_x, sp_y, z_s, params)\n", @@ -191,7 +191,7 @@ "# If you decrease the threshold from 1e-8 to 1e-10 you will get better fits, but fewer of them\n", "avg_fit = torch.mean(fit_params[0][fit_params[2] < 1e-8], dim=0)\n", "print(avg_fit.numpy())\n", - "# Note that the order is: x0, y0, q, phi, b" + "# Note that the order is: x0, y0, q, phi, Rein" ] }, { diff --git a/docs/source/gravlensingintro.ipynb b/docs/source/gravlensingintro.ipynb index 5c22b6ee..ba9787a5 100644 --- a/docs/source/gravlensingintro.ipynb +++ b/docs/source/gravlensingintro.ipynb @@ -111,7 +111,7 @@ "# Define a cosmology for the lensing\n", "cosmology = caustics.FlatLambdaCDM()\n", "# Define a point mass for the lens plane\n", - "lens = caustics.Point(cosmology=cosmology, x0=0.0, y0=0.0, th_ein=1.0, z_l=z_l)\n", + "lens = caustics.Point(cosmology=cosmology, x0=0.0, y0=0.0, Rein=1.0, z_l=z_l)\n", "\n", "# Make a bunch of theta values at which to raytrace\n", "theta_x = torch.linspace(-fov / 2, fov / 2, F, dtype=torch.float32)\n", @@ -292,7 +292,9 @@ "fig.suptitle(\"Lens Convergence Examples\")\n", "kappa_map = np.load(\"tutorials/assets/kappa_maps.npz\")[\"kappa_maps\"][1]\n", "lenses = [\n", - " caustics.SIE(cosmology=cosmology, x0=0, y0=0, q=0.6, phi=np.pi / 3, b=1, z_l=z_l),\n", + " caustics.SIE(\n", + " cosmology=cosmology, x0=0, y0=0, q=0.6, phi=np.pi / 3, Rein=1, z_l=z_l\n", + " ),\n", " caustics.PixelatedConvergence(\n", " cosmology=cosmology,\n", " x0=0,\n", @@ -301,14 +303,14 @@ " pixelscale=fov / kappa_map.shape[0],\n", " z_l=z_l,\n", " ),\n", - " caustics.NFW(cosmology=cosmology, x0=0, y0=0, m=1e12, c=5, z_l=z_l),\n", + " caustics.NFW(cosmology=cosmology, x0=0, y0=0, mass=1e12, c=5, z_l=z_l),\n", " caustics.PseudoJaffe(\n", " cosmology=cosmology,\n", " x0=0,\n", " y0=0,\n", " mass=1e12,\n", - " core_radius=0.2,\n", - " scale_radius=1.0,\n", + " Rc=0.2,\n", + " Rs=1.0,\n", " z_l=z_l,\n", " ),\n", " caustics.Multipole(\n", @@ -400,7 +402,7 @@ "# Define a cosmology for the lensing\n", "cosmology = caustics.FlatLambdaCDM()\n", "# Define a point mass for the lens plane\n", - "lens = caustics.Point(cosmology=cosmology, x0=0.0, y0=0.0, th_ein=1.0, z_l=z_l)\n", + "lens = caustics.Point(cosmology=cosmology, x0=0.0, y0=0.0, Rein=1.0, z_l=z_l)\n", "\n", "# Make a bunch of theta values at which to raytrace\n", "theta_x, theta_y = caustics.utils.meshgrid(res, n_pix)\n", @@ -485,7 +487,7 @@ " extent=[-fov / 2, fov / 2, -fov / 2, fov / 2],\n", ")\n", "ax2.scatter([0], [0], color=\"r\")\n", - "c = Circle((0, 0), lens.th_ein.value.item(), fill=False, color=\"r\", linestyle=\"--\")\n", + "c = Circle((0, 0), lens.Rein.value.item(), fill=False, color=\"r\", linestyle=\"--\")\n", "ax2.add_patch(c)\n", "ax2.set_title(\"lensed\")\n", "ax2.axis(\"off\")\n", @@ -564,7 +566,9 @@ "# Define a cosmology for the lensing\n", "cosmology = caustics.FlatLambdaCDM()\n", "# Define a point mass for the lens plane\n", - "lens = caustics.SIE(cosmology=cosmology, x0=0.0, y0=0.0, q=0.5, phi=0, b=1.0, z_l=z_l)\n", + "lens = caustics.SIE(\n", + " cosmology=cosmology, x0=0.0, y0=0.0, q=0.5, phi=0, Rein=1.0, z_l=z_l\n", + ")\n", "# Define a caustics simulator to handle the raytracing\n", "sim = caustics.LensSource(lens, source, pixelscale=res, pixels_x=n_pix, z_s=z_s)\n", "\n", @@ -662,7 +666,7 @@ "cosmology = caustics.FlatLambdaCDM()\n", "# Define a point mass for the lens plane\n", "sie_lens = caustics.SIE(\n", - " cosmology=cosmology, x0=0.0, y0=0.0, q=0.99, phi=0, b=0.1, z_l=z_l\n", + " cosmology=cosmology, x0=0.0, y0=0.0, q=0.99, phi=0, Rein=0.1, z_l=z_l\n", ")\n", "# Define a batched plane lens to combine many point masses\n", "point_lens = caustics.BatchedPlane(\n", @@ -750,7 +754,9 @@ "outputs": [], "source": [ "cosmology = caustics.FlatLambdaCDM()\n", - "lens = caustics.SIE(cosmology=cosmology, x0=0.0, y0=0.0, q=0.6, phi=0, b=1.0, z_l=z_l)\n", + "lens = caustics.SIE(\n", + " cosmology=cosmology, x0=0.0, y0=0.0, q=0.6, phi=0, Rein=1.0, z_l=z_l\n", + ")\n", "theta_x, theta_y = caustics.utils.meshgrid(res, n_pix)\n", "A = lens.jacobian_lens_equation(theta_x, theta_y, z_s)" ] @@ -809,7 +815,9 @@ "outputs": [], "source": [ "cosmology = caustics.FlatLambdaCDM()\n", - "lens = caustics.SIE(cosmology=cosmology, x0=0.0, y0=0.0, q=0.6, phi=0, b=1.0, z_l=z_l)\n", + "lens = caustics.SIE(\n", + " cosmology=cosmology, x0=0.0, y0=0.0, q=0.6, phi=0, Rein=1.0, z_l=z_l\n", + ")\n", "theta_x, theta_y = caustics.utils.meshgrid(res, n_pix)\n", "gamma_1, gamma_2 = lens.shear(theta_x, theta_y, z_s)" ] @@ -928,7 +936,9 @@ "outputs": [], "source": [ "cosmology = caustics.FlatLambdaCDM()\n", - "lens = caustics.SIE(cosmology=cosmology, x0=0.0, y0=0.0, q=0.6, phi=0, b=1.0, z_l=z_l)\n", + "lens = caustics.SIE(\n", + " cosmology=cosmology, x0=0.0, y0=0.0, q=0.6, phi=0, Rein=1.0, z_l=z_l\n", + ")\n", "mu = lens.magnification(theta_x, theta_y, z_s)" ] }, @@ -973,7 +983,7 @@ "source": [ "F = 50\n", "cosmology = caustics.FlatLambdaCDM()\n", - "lens = caustics.SIE(cosmology=cosmology, x0=0.0, y0=0.0, phi=0, b=0.6, z_l=z_l)\n", + "lens = caustics.SIE(cosmology=cosmology, x0=0.0, y0=0.0, phi=0, Rein=0.6, z_l=z_l)\n", "q = torch.linspace(0.1, 1.0, F)\n", "theta_x, theta_y = caustics.utils.meshgrid(res, n_pix)\n", "A = torch.stack([lens.jacobian_lens_equation(theta_x, theta_y, z_s, [q_]) for q_ in q])\n", @@ -1058,7 +1068,9 @@ ") # periodic brightness\n", "source.Ie.link(T)\n", "cosmology = caustics.FlatLambdaCDM()\n", - "lens = caustics.SIE(cosmology=cosmology, x0=0.0, y0=0.0, q=0.5, phi=0, b=1.0, z_l=z_l)\n", + "lens = caustics.SIE(\n", + " cosmology=cosmology, x0=0.0, y0=0.0, q=0.5, phi=0, Rein=1.0, z_l=z_l\n", + ")\n", "t = torch.linspace(0, 1, F)\n", "theta_x, theta_y = caustics.utils.meshgrid(res, n_pix)\n", "source_images = torch.vmap(lambda t: source.brightness(theta_x, theta_y, [t]))(t)\n", @@ -1234,7 +1246,7 @@ " cosmology=cosmology,\n", " x0=0.0,\n", " y0=0.0,\n", - " th_ein=1.0 / np.sqrt(len(z_ls)),\n", + " Rein=1.0 / np.sqrt(len(z_ls)),\n", " z_l=z,\n", " s=1e-3,\n", " )\n", @@ -1344,7 +1356,7 @@ "z_ls = torch.tensor([0.2, 0.4, 0.6, 0.8], dtype=torch.float32)\n", "cosmology = caustics.FlatLambdaCDM()\n", "lenses = [\n", - " caustics.Point(cosmology=cosmology, th_ein=1.0 / np.sqrt(len(z_ls)), z_l=z, s=1e-3)\n", + " caustics.Point(cosmology=cosmology, Rein=1.0 / np.sqrt(len(z_ls)), z_l=z, s=1e-3)\n", " for z in z_ls\n", "]\n", "lens = caustics.Multiplane(cosmology=cosmology, lenses=lenses)\n", @@ -1445,7 +1457,7 @@ " y0=(np.random.rand() - 0.5) * fov * 0.6,\n", " q=np.random.rand() * 0.4 + 0.3,\n", " phi=np.random.rand() * np.pi,\n", - " b=0.5 / np.sqrt(len(z_ls)),\n", + " Rein=0.5 / np.sqrt(len(z_ls)),\n", " z_l=z,\n", " s=1e-3,\n", " )\n", diff --git a/docs/source/tutorials/InterfaceIntroduction_func.ipynb b/docs/source/tutorials/InterfaceIntroduction_func.ipynb index ffae44c3..0e302a01 100644 --- a/docs/source/tutorials/InterfaceIntroduction_func.ipynb +++ b/docs/source/tutorials/InterfaceIntroduction_func.ipynb @@ -81,7 +81,7 @@ "outputs": [], "source": [ "x = torch.tensor([\n", - "# z_s z_l x0 y0 q phi b x0 y0 q phi n Re\n", + "# z_s z_l x0 y0 q phi Rein x0 y0 q phi n Re\n", " 1.5, 0.5, -0.2, 0.0, 0.4, 1.5708, 1.7, 0.0, 0.0, 0.5, -0.985, 1.3, 1.0, \n", "# Ie x0 y0 q phi n Re Ie\n", " 5.0, -0.2, 0.0, 0.8, 0.0, 1., 1.0, 10.0\n", @@ -217,7 +217,7 @@ " \"lens y0\",\n", " \"lens q\",\n", " \"lens phi\",\n", - " \"lens b\",\n", + " \"lens Rein\",\n", " \"source x0\",\n", " \"source y0\",\n", " \"source q\",\n", @@ -253,7 +253,7 @@ "- The next two parameters `x0` and `y0` indicate where the lens is relative to the main optical axis, which is the coordinates `(0, 0)`. \n", "- The `q` parameter gives the axis ratio for the `SIE`, so it knows how elongated it is. \n", "- `phi` indicates the position angle (where the ellipse is pointing). \n", - "- `b` gives the Einstein radius (in arcsec) of the lens. \n", + "- `Rein` gives the Einstein radius (in arcsec) of the lens. \n", "- The next `x0` and `y0` provide the position relative to the main optical axis of the Sersic source, here we offset the source slightly to make for an interesting figure. \n", "- The `q` parameter defines the axis ratio of the Sersic ellipse. \n", "- `phi` defines the position angle of the ellipse. \n", diff --git a/docs/source/tutorials/InterfaceIntroduction_oop.ipynb b/docs/source/tutorials/InterfaceIntroduction_oop.ipynb index b2f4e639..71a632b6 100644 --- a/docs/source/tutorials/InterfaceIntroduction_oop.ipynb +++ b/docs/source/tutorials/InterfaceIntroduction_oop.ipynb @@ -151,7 +151,7 @@ "outputs": [], "source": [ "x = torch.tensor([\n", - "# z_s z_l x0 y0 q phi b x0 y0 q phi n Re\n", + "# z_s z_l x0 y0 q phi Rein x0 y0 q phi n Re\n", " 1.5, 0.5, -0.2, 0.0, 0.4, 1.5708, 1.7, 0.0, 0.0, 0.5, -0.985, 1.3, 1.0, \n", "# Ie x0 y0 q phi n Re Ie\n", " 5.0, -0.2, 0.0, 0.8, 0.0, 1., 1.0, 10.0\n", @@ -282,7 +282,7 @@ "- The next two parameters `x0` and `y0` indicate where the lens is relative to the main optical axis, which is the coordinates `(0, 0)`. \n", "- The `q` parameter gives the axis ratio for the `SIE`, so it knows how elongated it is. \n", "- `phi` indicates the position angle (where the ellipse is pointing). \n", - "- `b` gives the Einstein radius (in arcsec) of the lens. \n", + "- `Rein` gives the Einstein radius (in arcsec) of the lens. \n", "- The next `x0` and `y0` provide the position relative to the main optical axis of the Sersic source, here we offset the source slightly to make for an interesting figure. \n", "- The `q` parameter defines the axis ratio of the Sersic ellipse. \n", "- `phi` defines the position angle of the ellipse. \n", diff --git a/docs/source/tutorials/InterfaceIntroduction_yaml.ipynb b/docs/source/tutorials/InterfaceIntroduction_yaml.ipynb index ca90620f..bb067b65 100644 --- a/docs/source/tutorials/InterfaceIntroduction_yaml.ipynb +++ b/docs/source/tutorials/InterfaceIntroduction_yaml.ipynb @@ -87,7 +87,7 @@ "source": [ "# Here we build a tensor with the parameters of the model\n", "x = torch.tensor([\n", - "# z_s z_l x0 y0 q phi b x0 y0 q phi n Re\n", + "# z_s z_l x0 y0 q phi Rein x0 y0 q phi n Re\n", " 1.5, 0.5, -0.2, 0.0, 0.4, 1.5708, 1.7, 0.0, 0.0, 0.5, -0.985, 1.3, 1.0, \n", "# Ie x0 y0 q phi n Re Ie\n", " 5.0, -0.2, 0.0, 0.8, 0.0, 1., 1.0, 10.0\n", @@ -219,7 +219,7 @@ "- The next two parameters `x0` and `y0` indicate where the lens is relative to the main optical axis, which is the coordinates `(0, 0)`. \n", "- The `q` parameter gives the axis ratio for the `SIE`, so it knows how elongated it is. \n", "- `phi` indicates the position angle (where the ellipse is pointing). \n", - "- `b` gives the Einstein radius (in arcsec) of the lens. \n", + "- `Rein` gives the Einstein radius (in arcsec) of the lens. \n", "- The next `x0` and `y0` provide the position relative to the main optical axis of the Sersic source, here we offset the source slightly to make for an interesting figure. \n", "- The `q` parameter defines the axis ratio of the Sersic ellipse. \n", "- `phi` defines the position angle of the ellipse. \n", diff --git a/docs/source/tutorials/Introduction.ipynb b/docs/source/tutorials/Introduction.ipynb index 570d85dd..b5ce3cea 100644 --- a/docs/source/tutorials/Introduction.ipynb +++ b/docs/source/tutorials/Introduction.ipynb @@ -93,7 +93,7 @@ " 0.0, # y_0\n", " 0.9, # q\n", " 0.4, # phi\n", - " 1.0, # b (Einstein radius)\n", + " 1.0, # Rein\n", " ]\n", ")\n", "\n", @@ -238,7 +238,7 @@ "simulator.lens.y0 = 0.0\n", "simulator.lens.q = 0.9\n", "simulator.lens.phi = 0.4\n", - "simulator.lens.b = None # Make sure this one stays Dynamic\n", + "simulator.lens.Rein = None # Make sure this one stays Dynamic\n", "simulator.lens.z_l = 0.5\n", "\n", "simulator.source.x0 = 0.0\n", @@ -278,7 +278,7 @@ "for i, ax in enumerate(axs.flatten()):\n", " ax.axis(\"off\")\n", " ax.imshow(ys[i], cmap=\"gray\")\n", - " ax.set_title(f\"$b = {b[i].item():.2f}$\")\n", + " ax.set_title(f\"$Rein = {b[i].item():.2f}$\")\n", "plt.subplots_adjust(wspace=0, hspace=0)" ] }, @@ -305,7 +305,7 @@ "source": [ "# Make some parameters dynamic for this example\n", "simulator.source.Ie = None\n", - "simulator.lens.b = None" + "simulator.lens.Rein = None" ] }, { @@ -332,9 +332,9 @@ "outputs": [], "source": [ "B = 5 # Batch dimension\n", - "b = torch.rand(B, 1)\n", + "Rein = torch.rand(B, 1)\n", "Ie = torch.rand(B, 1)\n", - "x = torch.concat([b, Ie], dim=1) # Concat along the feature dimension\n", + "x = torch.concat([Rein, Ie], dim=1) # Concat along the feature dimension\n", "\n", "# Now we can use vmap to simulate multiple images at once\n", "ys = vmap(simulator)(x)" @@ -361,7 +361,7 @@ "source": [ "# Make some parameters dynamic for this example\n", "simulator.source.Ie = None\n", - "simulator.lens.b = None\n", + "simulator.lens.Rein = None\n", "simulator.lens.x0 = None\n", "simulator.lens.cosmology.h0 = None\n", "\n", @@ -402,7 +402,7 @@ "source": [ "B = 5\n", "x0 = torch.randn(B, 1)\n", - "b = torch.randn(B, 1)\n", + "Rein = torch.randn(B, 1)\n", "Ie = torch.rand(B, 1)\n", "h0 = torch.rand(B, 1)" ] @@ -416,7 +416,7 @@ "x = {\n", " \"lens\": {\n", " \"x0\": x0,\n", - " \"b\": b,\n", + " \"Rein\": Rein,\n", " },\n", " \"source\": {\n", " \"Ie\": Ie,\n", @@ -494,7 +494,7 @@ "\n", "titles = [\n", " r\"$\\nabla_{x_0} f(\\mathbf{x})$\",\n", - " r\"$\\nabla_{b} f(\\mathbf{x})$\",\n", + " r\"$\\nabla_{Rein} f(\\mathbf{x})$\",\n", " r\"$\\nabla_{h_0} f(\\mathbf{x})$\",\n", " r\"$\\nabla_{I_e} f(\\mathbf{x})$\",\n", "]\n", diff --git a/docs/source/tutorials/InvertLensEquation.ipynb b/docs/source/tutorials/InvertLensEquation.ipynb index df764dc4..79174f3e 100644 --- a/docs/source/tutorials/InvertLensEquation.ipynb +++ b/docs/source/tutorials/InvertLensEquation.ipynb @@ -61,7 +61,7 @@ " y0=0.0,\n", " q=0.4,\n", " phi=np.pi / 5,\n", - " b=1.0,\n", + " Rein=1.0,\n", " s=1e-3,\n", ")" ] diff --git a/docs/source/tutorials/LensZoo.ipynb b/docs/source/tutorials/LensZoo.ipynb index 2a6ecff1..58e92180 100644 --- a/docs/source/tutorials/LensZoo.ipynb +++ b/docs/source/tutorials/LensZoo.ipynb @@ -85,7 +85,7 @@ " cosmology=cosmology,\n", " x0=0.0,\n", " y0=0.0,\n", - " th_ein=1.0,\n", + " Rein=1.0,\n", " z_l=z_l,\n", ")\n", "sim = caustics.LensSource(\n", @@ -140,7 +140,7 @@ " cosmology=cosmology,\n", " x0=0.0,\n", " y0=0.0,\n", - " th_ein=1.0,\n", + " Rein=1.0,\n", " z_l=z_l,\n", ")\n", "sim = caustics.LensSource(\n", @@ -200,7 +200,7 @@ " y0=0.0,\n", " q=0.6,\n", " phi=np.pi / 2,\n", - " b=1.0,\n", + " Rein=1.0,\n", " z_l=z_l,\n", ")\n", "sim = caustics.LensSource(\n", @@ -260,7 +260,7 @@ " y0=0.0,\n", " q=0.6,\n", " phi=np.pi / 2,\n", - " b=1.0,\n", + " Rein=1.0,\n", " t=0.5,\n", " z_l=z_l,\n", ")\n", @@ -321,7 +321,7 @@ " cosmology=cosmology,\n", " x0=0.0,\n", " y0=0.0,\n", - " m=1e13,\n", + " mass=1e13,\n", " c=20.0,\n", " z_l=z_l,\n", ")\n", @@ -385,7 +385,7 @@ " x0=0.0,\n", " y0=0.0,\n", " mass=1e12,\n", - " scale_radius=1.0,\n", + " Rs=1.0,\n", " tau=3.0,\n", " z_l=z_l,\n", ")\n", @@ -449,8 +449,8 @@ " x0=0.0,\n", " y0=0.0,\n", " mass=1e13,\n", - " core_radius=5e-1,\n", - " scale_radius=15.0,\n", + " Rc=5e-1,\n", + " Rs=15.0,\n", " z_l=z_l,\n", ")\n", "sim = caustics.LensSource(\n", diff --git a/docs/source/tutorials/Microlensing.ipynb b/docs/source/tutorials/Microlensing.ipynb index e8b1ad2c..771aa9d2 100644 --- a/docs/source/tutorials/Microlensing.ipynb +++ b/docs/source/tutorials/Microlensing.ipynb @@ -116,7 +116,7 @@ "outputs": [], "source": [ "# Microlensing Physical Parameters\n", - "th_ein = 0.3 # Einstein radius in arcsec\n", + "Rein = 0.3 # Einstein radius in arcsec\n", "\n", "# Microlensing Model Parameters\n", "t0 = 0.2 # time at peak magnification\n", @@ -144,11 +144,11 @@ "\n", "# Set all variables as static variables since they are not going to change in this simulation\n", "sim.lens.z_l = 0.0\n", - "sim.lens.y0 = -u0 * th_ein\n", - "sim.lens.th_ein = th_ein\n", + "sim.lens.y0 = -u0 * Rein\n", + "sim.lens.Rein = Rein\n", "sim.src.x0 = 0.0\n", "sim.src.y0 = 0.0\n", - "sim.src.theta_s = th_ein * rho\n", + "sim.src.theta_s = Rein * rho\n", "sim.src.Ie = 5.0\n", "sim.src.gamma = gamma\n", "\n", @@ -181,7 +181,7 @@ "ts = torch.linspace(-6 * tE + t0, 6 * tE + t0, B).view(-1, 1) # Create time grid\n", "\n", "# Calculate source position at each time in arcsec\n", - "x0s = (ts - t0) / (tE) * th_ein # Shape is [B, 1]" + "x0s = (ts - t0) / (tE) * Rein # Shape is [B, 1]" ] }, { diff --git a/docs/source/tutorials/MultiplaneDemo.ipynb b/docs/source/tutorials/MultiplaneDemo.ipynb index 0d488512..c4cda859 100644 --- a/docs/source/tutorials/MultiplaneDemo.ipynb +++ b/docs/source/tutorials/MultiplaneDemo.ipynb @@ -76,7 +76,7 @@ " y0=np.random.uniform(-fov / 4.0, fov / 4.0),\n", " q=np.random.uniform(0.3, 0.7),\n", " phi=np.random.uniform(0, np.pi),\n", - " b=np.random.uniform(0.1, 1.5),\n", + " Rein=np.random.uniform(0.1, 1.5),\n", " )\n", " )\n", "\n", diff --git a/docs/source/tutorials/VisualizeCaustics.ipynb b/docs/source/tutorials/VisualizeCaustics.ipynb index 70fdb037..cbd1efca 100644 --- a/docs/source/tutorials/VisualizeCaustics.ipynb +++ b/docs/source/tutorials/VisualizeCaustics.ipynb @@ -59,7 +59,7 @@ " 0.0, # sie y0\n", " 0.4, # sie q\n", " np.pi / 5, # sie phi\n", - " 1.0, # sie b\n", + " 1.0, # sie Rein\n", " ]\n", ")" ]