Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion autogalaxy/profiles/mass/abstract/cse.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,4 @@ def _deflections_2d_via_cse_from(self, grid: np.ndarray, **kwargs) -> np.ndarray
for amplitude, core_radius in zip(amplitude_list, core_radius_list)
)

return self.rotated_grid_from_reference_frame_from(deflections_2d.T)
return deflections_2d.T
10 changes: 3 additions & 7 deletions autogalaxy/profiles/mass/dark/nfw.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, xp=np, **kwargs):
return self.deflections_2d_via_analytic_from(grid=grid, xp=xp, **kwargs)

@aa.grid_dec.to_vector_yx
@aa.grid_dec.transform
@aa.grid_dec.transform(rotate_back=True)
def deflections_2d_via_analytic_from(
self, grid: aa.type.Grid2DLike, xp=np, **kwargs
):
Expand Down Expand Up @@ -103,14 +103,10 @@ def deflections_2d_via_analytic_from(
)
deflection_y *= prefactor

return self.rotated_grid_from_reference_frame_from(
xp.multiply(self.scale_radius, xp.vstack((deflection_y, deflection_x)).T),
xp=xp,
**kwargs,
)
return xp.multiply(self.scale_radius, xp.vstack((deflection_y, deflection_x)).T)

@aa.grid_dec.to_vector_yx
@aa.grid_dec.transform
@aa.grid_dec.transform(rotate_back=True)
def deflections_2d_via_cse_from(self, grid: aa.type.Grid2DLike, xp=np, **kwargs):
return self._deflections_2d_via_cse_from(grid=grid, **kwargs)

Expand Down
7 changes: 2 additions & 5 deletions autogalaxy/profiles/mass/sheets/external_shear.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def potential_2d_from(self, grid: aa.type.Grid2DLike, xp=np, **kwargs):
return -0.5 * shear_amp * rcoord**2 * xp.cos(2 * (phicoord - phig))

@aa.grid_dec.to_vector_yx
@aa.grid_dec.transform
@aa.grid_dec.transform(rotate_back=True)
def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, xp=np, **kwargs):
"""
Calculate the deflection angles at a given set of arc-second gridded coordinates.
Expand All @@ -70,7 +70,4 @@ def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, xp=np, **kwargs):
"""
deflection_y = -xp.multiply(self.magnitude(xp=xp), grid.array[:, 0])
deflection_x = xp.multiply(self.magnitude(xp=xp), grid.array[:, 1])
return self.rotated_grid_from_reference_frame_from(
grid=xp.vstack((deflection_y, deflection_x)).T,
xp=xp,
)
return xp.vstack((deflection_y, deflection_x)).T
6 changes: 2 additions & 4 deletions autogalaxy/profiles/mass/stellar/chameleon.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, xp=np, **kwargs):
return self.deflections_2d_via_analytic_from(grid=grid, xp=xp, **kwargs)

@aa.grid_dec.to_vector_yx
@aa.grid_dec.transform
@aa.grid_dec.transform(rotate_back=True)
def deflections_2d_via_analytic_from(
self, grid: aa.type.Grid2DLike, xp=np, **kwargs
):
Expand Down Expand Up @@ -128,9 +128,7 @@ def deflections_2d_via_analytic_from(
deflection_y = xp.subtract(deflection_y0, deflection_y1)
deflection_x = xp.subtract(deflection_x0, deflection_x1)

return self.rotated_grid_from_reference_frame_from(
xp.multiply(factor, xp.vstack((deflection_y, deflection_x)).T), xp=xp
)
return xp.multiply(factor, xp.vstack((deflection_y, deflection_x)).T)

@aa.over_sample
@aa.grid_dec.to_array
Expand Down
9 changes: 2 additions & 7 deletions autogalaxy/profiles/mass/stellar/gaussian.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, xp=np, **kwargs):
return self.deflections_2d_via_analytic_from(grid=grid, xp=xp, **kwargs)

@aa.grid_dec.to_vector_yx
@aa.grid_dec.transform
@aa.grid_dec.transform(rotate_back=True)
def deflections_2d_via_analytic_from(
self, grid: aa.type.Grid2DLike, xp=np, **kwargs
):
Expand All @@ -73,12 +73,7 @@ def deflections_2d_via_analytic_from(
* self.zeta_from(grid=grid, xp=xp)
)

return self.rotated_grid_from_reference_frame_from(
xp.multiply(
1.0, xp.vstack((-1.0 * xp.imag(deflections), xp.real(deflections))).T
),
xp=xp,
)
return xp.vstack((-1.0 * xp.imag(deflections), xp.real(deflections))).T

@aa.over_sample
@aa.grid_dec.to_array
Expand Down
2 changes: 1 addition & 1 deletion autogalaxy/profiles/mass/stellar/sersic.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, xp=np, **kwargs):
return self.deflections_2d_via_cse_from(grid=grid, xp=xp, **kwargs)

@aa.grid_dec.to_vector_yx
@aa.grid_dec.transform
@aa.grid_dec.transform(rotate_back=True)
def deflections_2d_via_cse_from(self, grid: aa.type.Grid2DLike, xp=np, **kwargs):
"""
Calculate the projected 2D deflection angles from a grid of (y,x) arc second coordinates, by computing and
Expand Down
27 changes: 6 additions & 21 deletions autogalaxy/profiles/mass/total/dual_pseudo_isothermal_mass.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def _ellip(self, xp=np):
return xp.min(xp.array([ellip, MAX_ELLIP]))

@aa.grid_dec.to_vector_yx
@aa.grid_dec.transform
@aa.grid_dec.transform(rotate_back=True)
def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, xp=np, **kwargs):
"""
Calculate the deflection angles on a grid of (y,x) arc-second coordinates.
Expand All @@ -283,12 +283,7 @@ def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, xp=np, **kwargs):
deflection_x = zis.real
deflection_y = zis.imag

# And here we convert back to the real axes
return self.rotated_grid_from_reference_frame_from(
grid=xp.multiply(factor, xp.vstack((deflection_y, deflection_x)).T),
xp=xp,
**kwargs,
)
return xp.multiply(factor, xp.vstack((deflection_y, deflection_x)).T)

def _convergence(self, radii, xp=np):

Expand Down Expand Up @@ -418,7 +413,7 @@ def _ellip(self, xp=np):
return xp.min(xp.array([ellip, MAX_ELLIP]))

@aa.grid_dec.to_vector_yx
@aa.grid_dec.transform
@aa.grid_dec.transform(rotate_back=True)
def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, xp=np, **kwargs):
"""
Calculate the deflection angles on a grid of (y,x) arc-second coordinates.
Expand All @@ -443,12 +438,7 @@ def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, xp=np, **kwargs):
deflection_x = zis.real
deflection_y = zis.imag

# And here we convert back to the real axes
return self.rotated_grid_from_reference_frame_from(
grid=xp.multiply(factor, xp.vstack((deflection_y, deflection_x)).T),
xp=xp,
**kwargs,
)
return xp.multiply(factor, xp.vstack((deflection_y, deflection_x)).T)

def _convergence(self, radii, xp=np):

Expand Down Expand Up @@ -594,7 +584,7 @@ def __init__(
self.b0 = b0

@aa.grid_dec.to_vector_yx
@aa.grid_dec.transform
@aa.grid_dec.transform(rotate_back=True)
def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, xp=np, **kwargs):
"""
Calculate the deflection angles on a grid of (y,x) arc-second coordinates.
Expand Down Expand Up @@ -627,12 +617,7 @@ def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, xp=np, **kwargs):
deflection_x = grid.array[:, 1] * factor
deflection_y = grid.array[:, 0] * factor

# And here we convert back to the real axes
return self.rotated_grid_from_reference_frame_from(
grid=xp.multiply(1.0, xp.vstack((deflection_y, deflection_x)).T),
xp=xp,
**kwargs,
)
return xp.vstack((deflection_y, deflection_x)).T

@aa.grid_dec.to_array
@aa.grid_dec.transform
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def _convergence(self, radii, xp=np):
)

@aa.grid_dec.to_vector_yx
@aa.grid_dec.transform
@aa.grid_dec.transform(rotate_back=True)
def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, xp=np, **kwargs):
"""
Calculate the deflection angles on a grid of (y,x) arc-second coordinates.
Expand All @@ -116,12 +116,7 @@ def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, xp=np, **kwargs):
deflection_y = alpha_circ * xp.sqrt(1 + ellip) * (grid.array[:, 0] / grid_radii)
deflection_x = alpha_circ * xp.sqrt(1 - ellip) * (grid.array[:, 1] / grid_radii)

# And here we convert back to the real axes
return self.rotated_grid_from_reference_frame_from(
grid=xp.multiply(1.0, xp.vstack((deflection_y, deflection_x)).T),
xp=xp,
**kwargs,
)
return xp.vstack((deflection_y, deflection_x)).T

@aa.grid_dec.to_vector_yx
@aa.grid_dec.transform
Expand Down
8 changes: 2 additions & 6 deletions autogalaxy/profiles/mass/total/isothermal.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def axis_ratio(self, xp=np):
return xp.minimum(axis_ratio, 0.99999)

@aa.grid_dec.to_vector_yx
@aa.grid_dec.transform
@aa.grid_dec.transform(rotate_back=True)
def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, xp=np, **kwargs):
"""
Calculate the deflection angles on a grid of (y,x) arc-second coordinates.
Expand Down Expand Up @@ -105,11 +105,7 @@ def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, xp=np, **kwargs):
psi,
)
)
return self.rotated_grid_from_reference_frame_from(
grid=xp.multiply(factor, xp.vstack((deflection_y, deflection_x)).T),
xp=xp,
**kwargs,
)
return xp.multiply(factor, xp.vstack((deflection_y, deflection_x)).T)

@aa.grid_dec.to_vector_yx
@aa.grid_dec.transform
Expand Down
6 changes: 2 additions & 4 deletions autogalaxy/profiles/mass/total/power_law.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def potential_2d_from(self, grid: aa.type.Grid2DLike, xp=np, **kwargs):
return (x * alpha_x + y * alpha_y) / (3 - self.slope)

@aa.grid_dec.to_vector_yx
@aa.grid_dec.transform
@aa.grid_dec.transform(rotate_back=True)
def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, xp=np, **kwargs):
"""
Calculate the deflection angles on a grid of (y,x) arc-second coordinates.
Expand Down Expand Up @@ -119,9 +119,7 @@ def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, xp=np, **kwargs):
deflection_y *= rescale_factor
deflection_x *= rescale_factor

return self.rotated_grid_from_reference_frame_from(
grid=xp.vstack((deflection_y, deflection_x)).T, xp=xp
)
return xp.vstack((deflection_y, deflection_x)).T

def convergence_func(self, grid_radius: float, xp=np) -> float:
return self.einstein_radius_rescaled(xp) * grid_radius.array ** (
Expand Down
9 changes: 2 additions & 7 deletions autogalaxy/profiles/mass/total/power_law_broken.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def potential_2d_from(self, grid: aa.type.Grid2DLike, xp=np, **kwargs):
return xp.zeros(shape=grid.shape[0])

@aa.grid_dec.to_vector_yx
@aa.grid_dec.transform
@aa.grid_dec.transform(rotate_back=True)
def deflections_yx_2d_from(self, grid, xp=np, max_terms=20, **kwargs):
"""
Returns the complex deflection angle from eq. 18 and 19
Expand Down Expand Up @@ -135,12 +135,7 @@ def deflections_yx_2d_from(self, grid, xp=np, max_terms=20, **kwargs):
inner_part * (R <= self.break_radius) + outer_part * (R > self.break_radius)
).conjugate()

return self.rotated_grid_from_reference_frame_from(
grid=xp.multiply(
1.0, xp.vstack((xp.imag(deflections), xp.real(deflections))).T
),
xp=xp,
)
return xp.vstack((xp.imag(deflections), xp.real(deflections))).T

@staticmethod
def hyp2f1_series(t, q, r, z, max_terms=20, xp=np):
Expand Down
6 changes: 2 additions & 4 deletions autogalaxy/profiles/mass/total/power_law_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def potential_2d_from(self, grid: aa.type.Grid2DLike, xp=np, **kwargs):
return self.einstein_radius_rescaled(xp) * self.axis_ratio(xp) * potential_grid

@aa.grid_dec.to_vector_yx
@aa.grid_dec.transform
@aa.grid_dec.transform(rotate_back=True)
def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, xp=np, **kwargs):
"""
Calculate the deflection angles on a grid of (y,x) arc-second coordinates.
Expand Down Expand Up @@ -139,9 +139,7 @@ def calculate_deflection_component(npow, index):
deflection_y = calculate_deflection_component(1.0, 0)
deflection_x = calculate_deflection_component(0.0, 1)

return self.rotated_grid_from_reference_frame_from(
grid=np.multiply(1.0, np.vstack((deflection_y, deflection_x)).T), xp=xp
)
return np.vstack((deflection_y, deflection_x)).T

def convergence_func(self, grid_radius: float, xp=np) -> float:
return self.einstein_radius_rescaled(xp) * (
Expand Down
Loading
Loading