Skip to content
This repository has been archived by the owner on Jun 14, 2024. It is now read-only.

Commit

Permalink
made changes to units based on suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
RashmikaReddy committed Feb 23, 2024
1 parent 194a6c7 commit 4069869
Show file tree
Hide file tree
Showing 13 changed files with 101 additions and 112 deletions.
16 changes: 8 additions & 8 deletions src/caustics/lenses/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -504,7 +502,7 @@ def time_delay(
Tensor
The gravitational time delay at the given coordinates.
*Unit: milliseconds*
*Unit: seconds*
"""
...
Expand Down Expand Up @@ -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*
"""
...
Expand Down Expand Up @@ -1094,7 +1094,7 @@ def time_delay(
Tensor
Time delay at the given coordinates.
*Unit: milliseconds*
*Unit: seconds*
References
----------
Expand Down
4 changes: 2 additions & 2 deletions src/caustics/lenses/epl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -268,7 +268,7 @@ def _r_omega(self, z, t, q):
Tensor
The value of `R * omega(phi)`.
*Unit: meters*
*Unit: arcsec*
"""
# constants
Expand Down
14 changes: 7 additions & 7 deletions src/caustics/lenses/multiplane.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
----------
Expand Down Expand Up @@ -274,7 +274,7 @@ def surface_density(
Tensor
Projected mass density.
*Unit: solMass / megaparsec^2*
*Unit: Msun/Mpc^2*
Raises
-------
Expand Down Expand Up @@ -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.
Expand Down
32 changes: 16 additions & 16 deletions src/caustics/lenses/nfw.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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)
Expand Down Expand Up @@ -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.
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand Down Expand Up @@ -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)
Expand Down
36 changes: 11 additions & 25 deletions src/caustics/lenses/pixelated_convergence.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand All @@ -117,8 +111,6 @@ def __init__(
Generally you should use either "zero" or "tile".
*Unit: unitless*
"""

super().__init__(cosmology, z_l, name=name)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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":
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit 4069869

Please sign in to comment.