Skip to content

Commit e44c685

Browse files
Jammy2211Jammy2211
authored andcommitted
remove eps
1 parent 8bd0ca7 commit e44c685

File tree

1 file changed

+3
-24
lines changed

1 file changed

+3
-24
lines changed

autoarray/inversion/pixelization/border_relocator.py

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ def ellipse_params_via_border_pca_from(border_grid, xp=np, eps=1e-12):
263263
return origin, a, b, phi
264264

265265

266-
def relocated_grid_via_ellipse_border_fro1m(grid, origin, a, b, phi, xp=np, eps=1e-12):
266+
def relocated_grid_via_ellipse_border_from(grid, origin, a, b, phi, xp=np, eps=1e-12):
267267
"""
268268
Rotated ellipse centered at origin with semi-axes a (major, x'), b (minor, y'),
269269
rotated by phi radians (counterclockwise).
@@ -299,7 +299,8 @@ def relocated_grid_via_ellipse_border_fro1m(grid, origin, a, b, phi, xp=np, eps=
299299
q = (xprime / a) ** 2 + (yprime / b) ** 2
300300

301301
outside = q > 1.0
302-
scale = 1.0 / xp.sqrt(xp.maximum(q, 1.0 + eps))
302+
scale = 1.0 / xp.sqrt(xp.maximum(q, 1.0))
303+
scale = xp.minimum(scale, 1.0)
303304

304305
# scale back to boundary
305306
xprime2 = xprime * scale
@@ -313,28 +314,6 @@ def relocated_grid_via_ellipse_border_fro1m(grid, origin, a, b, phi, xp=np, eps=
313314

314315
return xp.where(outside[:, None], moved, grid)
315316

316-
def relocated_grid_via_ellipse_border_from(grid, origin, a, b, phi, xp=np, eps=1e-12):
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-
# ellipse radius in normalized coords
327-
q = (xprime / a) ** 2 + (yprime / b) ** 2
328-
329-
outside = q > 1.0
330-
scale = 1.0 / xp.sqrt(xp.maximum(q, 1.0 + eps))
331-
332-
# scale back to boundary
333-
xprime2 = xprime * scale
334-
yprime2 = yprime * scale
335-
336-
moved = xp.stack([origin[0] + yprime2, origin[1] + xprime2], axis=1)
337-
return xp.where(outside[:, None], moved, grid)
338317

339318
class BorderRelocator:
340319
def __init__(

0 commit comments

Comments
 (0)