Skip to content

Commit d4cf8e5

Browse files
Jammy2211Jammy2211
authored andcommitted
v3
1 parent c91ca22 commit d4cf8e5

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

autoarray/inversion/pixelization/border_relocator.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,18 @@ def relocated_grid_via_ellipse_border_fro1m(grid, origin, a, b, phi, xp=np, eps=
314314
return xp.where(outside[:, None], moved, grid)
315315

316316
def relocated_grid_via_ellipse_border_from(grid, origin, a, b, phi, xp=np, eps=1e-12):
317-
outside = grid[:, 0] > xp.asarray(0.0, dtype=grid.dtype)
318-
moved = grid + xp.asarray(1e-3, dtype=grid.dtype) # constant shift
317+
dy = grid[:, 0] - origin[0]
318+
dx = grid[:, 1] - origin[1]
319+
320+
c = xp.cos(phi)
321+
s = xp.sin(phi)
322+
323+
xprime = c * dx + s * dy
324+
yprime = -s * dx + c * dy
325+
326+
outside = xprime > xp.asarray(0.0, dtype=grid.dtype)
327+
328+
moved = xp.stack([origin[0] + yprime, origin[1] + xprime], axis=1)
319329
return xp.where(outside[:, None], moved, grid)
320330

321331
class BorderRelocator:

0 commit comments

Comments
 (0)