diff --git a/src/caustics/lenses/base.py b/src/caustics/lenses/base.py index bfb0ea7d..62cb6cc4 100644 --- a/src/caustics/lenses/base.py +++ b/src/caustics/lenses/base.py @@ -136,12 +136,12 @@ def forward_raytrace( bx: Tensor Tensor of x coordinate in the source plane. - *Unit: scalar* + *Unit: arcsec* by: Tensor Tensor of y coordinate in the source plane. - *Unit: scalar* + *Unit: arcsec* z_s: Tensor Tensor of source redshifts. @@ -159,8 +159,6 @@ def forward_raytrace( n_init: int number of random initialization points used to try and find image plane points. - *Unit: unitless* - fov: float the field of view in which the initial random samples are taken. @@ -252,7 +250,7 @@ def reduced_deflection_angle( y: Tensor Tensor of y coordinates in the lens plane. - *Unit: arcsec* + *Unit: unitless* z_s: Tensor Tensor of source redshifts. @@ -504,7 +502,7 @@ def time_delay( Tensor The gravitational time delay at the given coordinates. - *Unit: milliseconds* + *Unit: seconds* """ ... @@ -875,7 +873,9 @@ def convergence( Returns ------- Tensor - Convergence at the given coordinates. + Dimensionless convergence, normalized by the critical surface density at the lens plane + + *Unit: unitless* """ ... @@ -1094,7 +1094,7 @@ def time_delay( Tensor Time delay at the given coordinates. - *Unit: milliseconds* + *Unit: seconds* References ---------- diff --git a/src/caustics/lenses/epl.py b/src/caustics/lenses/epl.py index a85e4a06..35ae8abc 100644 --- a/src/caustics/lenses/epl.py +++ b/src/caustics/lenses/epl.py @@ -158,7 +158,7 @@ def __init__( s: float Softening length for the elliptical power-law profile. - *Unit: meters* + *Unit: arcsec* n_iter: int Number of iterations for the iterative solver. @@ -268,7 +268,7 @@ def _r_omega(self, z, t, q): Tensor The value of `R * omega(phi)`. - *Unit: meters* + *Unit: arcsec* """ # constants diff --git a/src/caustics/lenses/multiplane.py b/src/caustics/lenses/multiplane.py index 4edc79ae..f001e1a9 100644 --- a/src/caustics/lenses/multiplane.py +++ b/src/caustics/lenses/multiplane.py @@ -180,12 +180,12 @@ def raytrace( x: Tensor angular x-coordinates in the image plane. - *Unit: radians* + *Unit: arcsec* y: Tensor angular y-coordinates in the image plane. - *Unit: radians* + *Unit: arcsec* z_s: Tensor Redshifts of the sources. @@ -200,12 +200,12 @@ def raytrace( x_component: Tensor Reduced deflection angle in the x-direction. - *Unit: radians* + *Unit: arcsec* y_component: Tensor Reduced deflection angle in the y-direction. - *Unit: radians* + *Unit: arcsec* References ---------- @@ -274,7 +274,7 @@ def surface_density( Tensor Projected mass density. - *Unit: solMass / megaparsec^2* + *Unit: Msun/Mpc^2* Raises ------- @@ -319,12 +319,12 @@ def time_delay( x: Tensor x-coordinates in the image plane. - *Unit: radians* + *Unit: arcsec* y: Tensor y-coordinates in the image plane. - *Unit: radians* + *Unit: arcsec* z_s: Tensor Redshifts of the source. diff --git a/src/caustics/lenses/nfw.py b/src/caustics/lenses/nfw.py index f178bd78..9dcbe8ee 100644 --- a/src/caustics/lenses/nfw.py +++ b/src/caustics/lenses/nfw.py @@ -43,7 +43,7 @@ class NFW(ThinLens): m: Optional[Tensor] Mass of the lens. Default is None. - *Unit: solMass* + *Unit: Msun* c: Optional[Tensor] Concentration parameter of the lens. Default is None. @@ -53,7 +53,7 @@ class NFW(ThinLens): s: float Softening parameter to avoid singularities at the center of the lens. Default is 0.0. - *Unit: meters* + *Unit: arcsec* use_case: str Due to an idyosyncratic behaviour of PyTorch, the NFW/TNFW profile @@ -142,7 +142,7 @@ def __init__( m: Optional[Union[Tensor, float]] Mass of the lens. Default is None. - *Unit: solMass* + *Unit: Msun* c: Optional[Union[Tensor, float]] Concentration parameter of the lens. Default is None. @@ -153,7 +153,7 @@ def __init__( Softening parameter to avoid singularities at the center of the lens. Default is 0.0. - *Unit: meters* + *Unit: arcsec* """ super().__init__(cosmology, z_l, name=name) @@ -199,7 +199,7 @@ def get_scale_radius( m: Tensor Mass of the lens. - *Unit: solMass* + *Unit: Msun* c: Tensor Concentration parameter of the lens. @@ -216,7 +216,7 @@ def get_scale_radius( Tensor The scale radius of the lens in Mpc. - *Unit: megaparsec* + *Unit: Mpc* """ critical_density = self.cosmology.critical_density(z_l, params) @@ -258,7 +258,7 @@ def get_scale_density( Tensor The scale density of the lens in solar masses per Mpc cubed. - *Unit: solMass/megaparsec^3* + *Unit: Msun/Mpc^3* """ sigma_crit = self.cosmology.critical_density(z_l, params) @@ -295,7 +295,7 @@ def get_convergence_s( m: Tensor Mass of the lens. - *Unit: solMass* + *Unit: Msun* c: Tensor Concentration parameter of the lens. @@ -335,7 +335,7 @@ def _f_differentiable(x: Tensor) -> Tensor: Tensor Result of the deflection angle computation. - *Unit: radians* + *Unit: unitless* """ # TODO: generalize beyond torch, or patch Tensor @@ -361,7 +361,7 @@ def _f_batchable(x: Tensor) -> Tensor: Tensor Result of the deflection angle computation. - *Unit: radians* + *Unit: unitless* """ # TODO: generalize beyond torch, or patch Tensor @@ -395,7 +395,7 @@ def _g_differentiable(x: Tensor) -> Tensor: Tensor Result of the lensing potential computation. - *Unit: arcsec^2* + *Unit: unitless* """ # TODO: generalize beyond torch, or patch Tensor @@ -422,7 +422,7 @@ def _g_batchable(x: Tensor) -> Tensor: Tensor Result of the lensing potential computation. - *Unit: arcsec^2* + *Unit: unitless* """ # TODO: generalize beyond torch, or patch Tensor @@ -455,7 +455,7 @@ def _h_differentiable(x: Tensor) -> Tensor: Tensor Result of the reduced deflection angle computation. - *Unit: radians* + *Unit: unitless* """ term_1 = (x / 2).log() @@ -481,7 +481,7 @@ def _h_batchable(x: Tensor) -> Tensor: Tensor Result of the reduced deflection angle computation. - *Unit: radians* + *Unit: unitless* """ term_1 = (x / 2).log() @@ -537,12 +537,12 @@ def reduced_deflection_angle( x_component: Tensor The x-component of the reduced deflection angle. - *Unit: radians* + *Unit: arcsec* y_component: Tensor The y-component of the reduced deflection angle. - *Unit: radians* + *Unit: arcsec* """ x, y = translate_rotate(x, y, x0, y0) diff --git a/src/caustics/lenses/pixelated_convergence.py b/src/caustics/lenses/pixelated_convergence.py index d4755436..0cc643c8 100644 --- a/src/caustics/lenses/pixelated_convergence.py +++ b/src/caustics/lenses/pixelated_convergence.py @@ -61,7 +61,7 @@ def __init__( n_pix: int The number of pixels on each side of the grid. - *Unit: unitless* + *Unit: number* cosmology: Cosmology An instance of the cosmological parameters. @@ -89,23 +89,17 @@ def __init__( shape: Optional[tuple[int, ...]] The shape of the convergence map. - *Unit: unitless* - convolution_mode: str, optional The convolution mode for calculating deflection angles and lensing potential. It can be either "fft" (Fast Fourier Transform) or "conv2d" (2D convolution). Default is "fft". - - *Unit: unitless* - + use_next_fast_len: bool, optional If True, adds additional padding to speed up the FFT by calling `scipy.fft.next_fast_len`. The speed boost can be substantial when `n_pix` is a multiple of a small prime number. Default is True. - - *Unit: unitless* - + padding: { "zero", "circular", "reflect", "tile" } Specifies the type of padding to use: @@ -117,8 +111,6 @@ def __init__( Generally you should use either "zero" or "tile". - *Unit: unitless* - """ super().__init__(cosmology, z_l, name=name) @@ -196,15 +188,11 @@ def _fft2_padded(self, x: Tensor) -> Tensor: x: Tensor The input tensor to be transformed. - *Unit: unitless* - Returns ------- Tensor The 2D FFT of the input tensor with zero-padding. - - *Unit: unitless* - + """ pad = 2 * self.n_pix if self.use_next_fast_len: @@ -237,9 +225,7 @@ def _unpad_fft(self, x: Tensor) -> Tensor: ------- Tensor The input tensor without padding. - - *Unit: unitless* - + """ return torch.roll(x, (-self._s[0] // 2, -self._s[1] // 2), dims=(-2, -1))[..., : self.n_pix, : self.n_pix] # fmt: skip @@ -341,12 +327,12 @@ def reduced_deflection_angle( x_component: Tensor Deflection Angle in the x-direction. - *Unit: radians* + *Unit: arcsec* y_component: Tensor Deflection Angle in the y-direction. - *Unit: radians* + *Unit: arcsec* """ if self.convolution_mode == "fft": @@ -384,12 +370,12 @@ def _deflection_angle_fft(self, convergence_map: Tensor) -> tuple[Tensor, Tensor x_component: Tensor Deflection Angle in x-component. - *Unit: radians* + *Unit: arcsec* y_component: Tensor Deflection Angle in y-component. - *Unit: radians* + *Unit: arcsec* """ convergence_tilde = self._fft2_padded(convergence_map) @@ -419,12 +405,12 @@ def _deflection_angle_conv2d( x_component: Tensor Deflection Angle - *Unit: radians* + *Unit: arcsec* y_component: Tensor Deflection Angle - *Unit: radians* + *Unit: arcsec* """ # Use convergence_map as kernel since the kernel is twice as large. Flip since diff --git a/src/caustics/lenses/point.py b/src/caustics/lenses/point.py index f1dc9bb2..c3d61743 100644 --- a/src/caustics/lenses/point.py +++ b/src/caustics/lenses/point.py @@ -48,7 +48,7 @@ class Point(ThinLens): s: float Softening parameter to prevent numerical instabilities. - *Unit: meters* + *Unit: arcsec* """ @@ -102,7 +102,7 @@ def __init__( s: float Softening parameter to prevent numerical instabilities. - *Unit: meters* + *Unit: arcsec* """ super().__init__(cosmology, z_l, name=name) @@ -154,12 +154,12 @@ def reduced_deflection_angle( x_component: Tensor Deflection Angle in the x-direction. - *Unit: radians* + *Unit: arcsec* y_component: Tensor Deflection Angle in the y-direction. - *Unit: radians* + *Unit: arcsec* """ x, y = translate_rotate(x, y, x0, y0) diff --git a/src/caustics/lenses/pseudo_jaffe.py b/src/caustics/lenses/pseudo_jaffe.py index 7899582f..69da2351 100644 --- a/src/caustics/lenses/pseudo_jaffe.py +++ b/src/caustics/lenses/pseudo_jaffe.py @@ -43,9 +43,9 @@ class PseudoJaffe(ThinLens): *Unit: arcsec* mass: Optional[Union[Tensor, float]] - Total mass of the lens (solMass). + Total mass of the lens (Msun). - *Unit: solMass* + *Unit: Msun* core_radius: Optional[Union[Tensor, float]] Core radius of the lens (arcsec). @@ -111,9 +111,9 @@ def __init__( *Unit: arcsec* mass: Optional[Tensor] - Total mass of the lens (solMass). + Total mass of the lens (Msun). - *Unit: solMass* + *Unit: Msun* core_radius: Optional[Tensor] Core radius of the lens. @@ -128,6 +128,8 @@ def __init__( s: float Softening parameter to prevent numerical instabilities. + *Unit: arcsec* + """ super().__init__(cosmology, z_l, name=name) @@ -194,7 +196,7 @@ def mass_enclosed_2d( Tensor The mass enclosed within the given radius. - *Unit: solMass* + *Unit: Msun* """ # fmt: off @@ -236,17 +238,17 @@ def central_convergence( rho_0: Tensor Central mass density. - *Unit: solMass/megaparsec^3* + *Unit: Msun/Mpc^3* core_radius: Tensor Core radius of the lens (must be in Mpc). - *Unit: megaparsec* + *Unit: Mpc* scale_radius: Tensor Scaling radius of the lens (must be in Mpc). - *Unit: megaparsec* + *Unit: Mpc* cosmology: Cosmology The cosmology used for calculations. @@ -304,12 +306,12 @@ def reduced_deflection_angle( x_component: Tensor x-component of the deflection angle. - *Unit: radians* + *Unit: arcsec* y_component: Tensor y-component of the deflection angle. - *Unit: radians* + *Unit: arcsec* """ x, y = translate_rotate(x, y, x0, y0) @@ -433,7 +435,7 @@ def convergence( Tensor The projected mass density. - *Unit: solMass/Mpc^2* + *Unit: unitless* """ x, y = translate_rotate(x, y, x0, y0) diff --git a/src/caustics/lenses/sie.py b/src/caustics/lenses/sie.py index ba9d08fe..c5fab214 100644 --- a/src/caustics/lenses/sie.py +++ b/src/caustics/lenses/sie.py @@ -58,7 +58,7 @@ class SIE(ThinLens): s: float The core radius of the lens (defaults to 0.0). - *Unit: meters* + *Unit: arcsec* """ @@ -169,12 +169,12 @@ def reduced_deflection_angle( x_component: Tensor The x-component of the deflection angle. - *Unit: radians* + *Unit: arcsec* y_component: Tensor The y-component of the deflection angle. - *Unit: radians* + *Unit: arcsec* """ x, y = translate_rotate(x, y, x0, y0, phi) @@ -281,7 +281,7 @@ def convergence( Tensor The projected mass density. - *Unit: solMass/megaparsec^2* + *Unit: unitless* """ x, y = translate_rotate(x, y, x0, y0, phi) diff --git a/src/caustics/lenses/singleplane.py b/src/caustics/lenses/singleplane.py index 8a23f172..15b4dddb 100644 --- a/src/caustics/lenses/singleplane.py +++ b/src/caustics/lenses/singleplane.py @@ -84,12 +84,12 @@ def reduced_deflection_angle( x_component: Tensor The x-component of the deflection angle. - *Unit: radians* + *Unit: arcsec* y_component: Tensor The y-component of the deflection angle. - *Unit: radians* + *Unit: arcsec* """ ax = torch.zeros_like(x) @@ -139,7 +139,7 @@ def convergence( Tensor The total projected mass density. - *Unit: solMass/megaparsec^2* + *Unit: unitless* """ convergence = torch.zeros_like(x) diff --git a/src/caustics/lenses/sis.py b/src/caustics/lenses/sis.py index 3482dfa8..d413b9cb 100644 --- a/src/caustics/lenses/sis.py +++ b/src/caustics/lenses/sis.py @@ -48,7 +48,7 @@ class SIS(ThinLens): s: float A smoothing factor, default is 0.0. - *Unit: meters* + *Unit: arcsec* """ @@ -120,12 +120,12 @@ def reduced_deflection_angle( x_component: Tensor Deflection Angle - *Unit: radians* + *Unit: arcsec* y_component: Tensor Deflection Angle - *Unit: radians* + *Unit: arcsec* """ x, y = translate_rotate(x, y, x0, y0) @@ -225,7 +225,7 @@ def convergence( Tensor The projected mass density. - *Unit: solMass/megaparsec^2* + *Unit: unitless* """ x, y = translate_rotate(x, y, x0, y0) diff --git a/src/caustics/lenses/tnfw.py b/src/caustics/lenses/tnfw.py index 2534b815..c2ede50b 100644 --- a/src/caustics/lenses/tnfw.py +++ b/src/caustics/lenses/tnfw.py @@ -69,7 +69,7 @@ class TNFW(ThinLens): mass: Optional[Tensor] Mass of the lens. - *Unit: solMass* + *Unit: Msun* scale_radius: Optional[Tensor] Scale radius of the TNFW lens. @@ -85,7 +85,7 @@ class TNFW(ThinLens): Softening parameter to avoid singularities at the center of the lens. Default is 0.0. - *Unit: unitless* + *Unit: arcsec* interpret_m_total_mass: boolean Indicates how to interpret the mass variable "m". If true @@ -93,7 +93,6 @@ class TNFW(ThinLens): false it is interpreted as what the mass would have been within R200 of a an NFW that isn't truncated (good because it is easily compared with an NFW). - *Unit: unitless* use_case: str Due to an idyosyncratic behaviour of PyTorch, the NFW/TNFW profile @@ -209,7 +208,7 @@ def get_concentration( mass: Optional[Tensor] Mass of the lens. - *Unit: solMass* + *Unit: Msun* scale_radius: Optional[Tensor] Scale radius of the TNFW lens. @@ -218,6 +217,8 @@ def get_concentration( tau: Optional[Tensor] Truncation scale. Ratio of truncation radius to scale radius. + + *Unit: unitless* params: dict Dynamic parameter container. @@ -227,7 +228,7 @@ def get_concentration( Tensor The scale radius of the lens. - *Unit: megaparsec* + *Unit: Mpc* """ critical_density = self.cosmology.critical_density(z_l, params) @@ -271,7 +272,7 @@ def get_truncation_radius( mass: Optional[Tensor] Mass of the lens. - *Unit: solMass* + *Unit: Msun* scale_radius: Optional[Tensor] Scale radius of the TNFW lens. @@ -334,7 +335,7 @@ def get_M0( mass: Optional[Tensor] Mass of the lens. - *Unit: solMass* + *Unit: Msun* scale_radius: Optional[Tensor] Scale radius of the TNFW lens. @@ -352,9 +353,9 @@ def get_M0( Returns ------- Tensor - The reference mass of the lens in solMass. + The reference mass of the lens in Msun. - *Unit: solMass* + *Unit: Msun* """ if self.interpret_m_total_mass: @@ -399,7 +400,7 @@ def get_scale_density( mass: Optional[Tensor] Mass of the lens. - *Unit: solMass* + *Unit: Msun* scale_radius: Optional[Tensor] Scale radius of the TNFW lens. @@ -419,7 +420,7 @@ def get_scale_density( Tensor The scale density of the lens. - *Unit: solMass/Mpc^3* + *Unit: Msun/Mpc^3* """ c = self.get_concentration(params) @@ -465,7 +466,7 @@ def convergence( mass: Optional[Tensor] Mass of the lens. - *Unit: solMass* + *Unit: Msun* scale_radius: Optional[Tensor] Scale radius of the TNFW lens. @@ -522,7 +523,7 @@ def mass_enclosed_2d( **kwargs, ) -> Tensor: """ - Total projected mass (solMass) within a radius r (arcsec). + Total projected mass (Msun) within a radius r (arcsec). Parameters ----------- @@ -544,7 +545,7 @@ def mass_enclosed_2d( mass: Optional[Tensor] Mass of the lens. - *Unit: solMass* + *Unit: Msun* scale_radius: Optional[Tensor] Scale radius of the TNFW lens. @@ -564,7 +565,7 @@ def mass_enclosed_2d( Tensor Integrated mass projected in infinite cylinder within radius r. - *Unit: arcsec* + *Unit: Msun* """ g = r / scale_radius @@ -618,9 +619,9 @@ def physical_deflection_angle( *Unit: arcsec* mass: Optional[Tensor] - Mass of the lens (solMass). + Mass of the lens (Msun). - *Unit: solMass* + *Unit: Msun* scale_radius: Optional[Tensor] Scale radius of the TNFW lens. @@ -640,12 +641,12 @@ def physical_deflection_angle( x_component: Tensor Deflection Angle in x-direction. - *Unit: radians* + *Unit: arcsec* y_component: Tensor Deflection Angle in y-direction. - *Unit: radians* + *Unit: arcsec* """ d_l = self.cosmology.angular_diameter_distance(z_l, params) @@ -703,7 +704,7 @@ def potential( mass: Optional[Tensor] Mass of the lens. - *Unit: solMass* + *Unit: Msun* scale_radius: Optional[Tensor] Scale radius of the TNFW lens. diff --git a/src/caustics/light/pixelated.py b/src/caustics/light/pixelated.py index 8ba4eaec..80183623 100644 --- a/src/caustics/light/pixelated.py +++ b/src/caustics/light/pixelated.py @@ -36,6 +36,8 @@ class Pixelated(Source): image : Tensor, optional The source image from which brightness values will be interpolated. + + *Unit: flux* pixelscale : Tensor, optional The pixelscale of the source image in the lens plane. @@ -143,7 +145,7 @@ def brightness( The brightness is determined by interpolating values from the source image. - *Unit: unitless* + *Unit: flux* """ fov_x = pixelscale * image.shape[0] diff --git a/src/caustics/light/sersic.py b/src/caustics/light/sersic.py index 6211e6e2..d73e8200 100644 --- a/src/caustics/light/sersic.py +++ b/src/caustics/light/sersic.py @@ -56,17 +56,16 @@ class Sersic(Source): Ie: Optional[Tensor] The intensity at the effective radius. - *Unit: unitless* + *Unit: flux* s: float A small constant for numerical stability. - *Unit: unitless* + *Unit: arcsec* lenstronomy_k_mode: bool A flag indicating whether to use lenstronomy to compute the value of k. - *Unit: unitless* """ @@ -119,7 +118,7 @@ def __init__( Re: Optional[Tensor] The scale length of the Sersic source. - *Unit: arcsec* + *Unit: flux* Ie: Optional[Tensor] The intensity at the effective radius. @@ -129,12 +128,11 @@ def __init__( s: float A small constant for numerical stability. - *Unit: unitless* + *Unit: arcsec* use_lenstronomy_k: bool A flag indicating whether to use lenstronomy to compute the value of k. - *Unit: unitless* """ super().__init__(name=name) @@ -192,7 +190,7 @@ def brightness( The brightness of the source at the given point(s). The output tensor has the same shape as `x` and `y`. - *Unit: unitless* + *Unit: flux* Notes -----