Skip to content

Commit ab45cf5

Browse files
Jammy2211Jammy2211
authored andcommitted
remove grid_2d_slim_upscaled_from
1 parent 783ff84 commit ab45cf5

2 files changed

Lines changed: 1 addition & 157 deletions

File tree

autoarray/structures/grids/grid_2d_util.py

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -738,58 +738,6 @@ def grid_2d_native_from(
738738
return jnp.stack((grid_2d_native_y, grid_2d_native_x), axis=-1)
739739

740740

741-
@numba_util.jit()
742-
def grid_2d_slim_upscaled_from(
743-
grid_slim: np.ndarray, upscale_factor: int, pixel_scales: ty.PixelScales
744-
) -> np.ndarray:
745-
"""
746-
From an input slimmed 2D grid, return an upscaled slimmed 2D grid where (y,x) coordinates are added at an
747-
upscaled resolution to each grid coordinate.
748-
749-
Parameters
750-
----------
751-
grid_slim
752-
The slimmed grid of (y,x) coordinates over which a square uniform grid is overlaid.
753-
upscale_factor
754-
The upscaled resolution at which the new grid coordinates are computed.
755-
pixel_scales
756-
The pixel scale of the uniform grid that laid over the irregular grid of (y,x) coordinates.
757-
"""
758-
759-
grid_2d_slim_upscaled = np.zeros(shape=(grid_slim.shape[0] * upscale_factor**2, 2))
760-
761-
upscale_index = 0
762-
763-
y_upscale_half = pixel_scales[0] / 2
764-
y_upscale_step = pixel_scales[0] / upscale_factor
765-
766-
x_upscale_half = pixel_scales[1] / 2
767-
x_upscale_step = pixel_scales[1] / upscale_factor
768-
769-
for slim_index in range(grid_slim.shape[0]):
770-
y_grid = grid_slim[slim_index, 0]
771-
x_grid = grid_slim[slim_index, 1]
772-
773-
for y in range(upscale_factor):
774-
for x in range(upscale_factor):
775-
grid_2d_slim_upscaled[upscale_index, 0] = (
776-
y_grid
777-
+ y_upscale_half
778-
- y * y_upscale_step
779-
- (y_upscale_step / 2.0)
780-
)
781-
grid_2d_slim_upscaled[upscale_index, 1] = (
782-
x_grid
783-
- x_upscale_half
784-
+ x * x_upscale_step
785-
+ (x_upscale_step / 2.0)
786-
)
787-
788-
upscale_index += 1
789-
790-
return grid_2d_slim_upscaled
791-
792-
793741
def grid_2d_of_points_within_radius(
794742
radius: float, centre: Tuple[float, float], grid_2d: np.ndarray
795743
):

test_autoarray/structures/grids/test_grid_2d_util.py

Lines changed: 1 addition & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -460,108 +460,4 @@ def test__grid_2d_native_from():
460460
[[-1.0, -1.0], [-2.0, -2.0], [0.0, 0.0], [-3.0, -3.0]],
461461
]
462462
)
463-
).all()
464-
465-
grid_slim = np.array(
466-
[
467-
[1.0, 1.0],
468-
[1.0, 1.0],
469-
[1.0, 1.0],
470-
[1.0, 1.0],
471-
[2.0, 2.0],
472-
[2.0, 2.0],
473-
[2.0, 2.0],
474-
[2.0, 2.0],
475-
[3.0, 3.0],
476-
[3.0, 3.0],
477-
[3.0, 3.0],
478-
[4.0, 4.0],
479-
]
480-
)
481-
482-
483-
def test__grid_2d_slim_upscaled_from():
484-
grid_slim = np.array([[1.0, 1.0]])
485-
486-
grid_upscaled_2d = aa.util.grid_2d.grid_2d_slim_upscaled_from(
487-
grid_slim=grid_slim, upscale_factor=1, pixel_scales=(2.0, 2.0)
488-
)
489-
490-
assert (grid_upscaled_2d == np.array([[1.0, 1.0]])).all()
491-
492-
grid_upscaled_2d = aa.util.grid_2d.grid_2d_slim_upscaled_from(
493-
grid_slim=grid_slim, upscale_factor=2, pixel_scales=(2.0, 2.0)
494-
)
495-
496-
assert (
497-
grid_upscaled_2d == np.array([[1.5, 0.5], [1.5, 1.5], [0.5, 0.5], [0.5, 1.5]])
498-
).all()
499-
500-
grid_slim = np.array([[1.0, 1.0], [1.0, 3.0]])
501-
502-
grid_upscaled_2d = aa.util.grid_2d.grid_2d_slim_upscaled_from(
503-
grid_slim=grid_slim, upscale_factor=2, pixel_scales=(2.0, 2.0)
504-
)
505-
506-
assert (
507-
grid_upscaled_2d
508-
== np.array(
509-
[
510-
[1.5, 0.5],
511-
[1.5, 1.5],
512-
[0.5, 0.5],
513-
[0.5, 1.5],
514-
[1.5, 2.5],
515-
[1.5, 3.5],
516-
[0.5, 2.5],
517-
[0.5, 3.5],
518-
]
519-
)
520-
).all()
521-
522-
grid_slim = np.array([[1.0, 1.0], [3.0, 1.0]])
523-
524-
grid_upscaled_2d = aa.util.grid_2d.grid_2d_slim_upscaled_from(
525-
grid_slim=grid_slim, upscale_factor=2, pixel_scales=(2.0, 2.0)
526-
)
527-
528-
assert (
529-
grid_upscaled_2d
530-
== np.array(
531-
[
532-
[1.5, 0.5],
533-
[1.5, 1.5],
534-
[0.5, 0.5],
535-
[0.5, 1.5],
536-
[3.5, 0.5],
537-
[3.5, 1.5],
538-
[2.5, 0.5],
539-
[2.5, 1.5],
540-
]
541-
)
542-
).all()
543-
544-
grid_slim = np.array([[1.0, 1.0]])
545-
546-
grid_upscaled_2d = aa.util.grid_2d.grid_2d_slim_upscaled_from(
547-
grid_slim=grid_slim, upscale_factor=2, pixel_scales=(3.0, 2.0)
548-
)
549-
550-
assert (
551-
grid_upscaled_2d
552-
== np.array([[1.75, 0.5], [1.75, 1.5], [0.25, 0.5], [0.25, 1.5]])
553-
).all()
554-
555-
grid_upscaled_2d = aa.util.grid_2d.grid_2d_slim_upscaled_from(
556-
grid_slim=grid_slim, upscale_factor=3, pixel_scales=(2.0, 2.0)
557-
)
558-
559-
assert grid_upscaled_2d[0] == pytest.approx(np.array([1.666, 0.333]), 1.0e-2)
560-
assert grid_upscaled_2d[1] == pytest.approx(np.array([1.666, 1.0]), 1.0e-2)
561-
assert grid_upscaled_2d[2] == pytest.approx(np.array([1.666, 1.666]), 1.0e-2)
562-
assert grid_upscaled_2d[3] == pytest.approx(np.array([1.0, 0.333]), 1.0e-2)
563-
assert grid_upscaled_2d[4] == pytest.approx(np.array([1.0, 1.0]), 1.0e-2)
564-
assert grid_upscaled_2d[5] == pytest.approx(np.array([1.0, 1.666]), 1.0e-2)
565-
assert grid_upscaled_2d[6] == pytest.approx(np.array([0.333, 0.333]), 1.0e-2)
566-
assert grid_upscaled_2d[7] == pytest.approx(np.array([0.333, 1.0]), 1.0e-2)
567-
assert grid_upscaled_2d[8] == pytest.approx(np.array([0.333, 1.666]), 1.0e-2)
463+
).all()

0 commit comments

Comments
 (0)