hanjinliu / coords-array

N-Dimensional array implemented with slicing, transformation and interpolation in a coordinate-based manner.
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Axis-based indices creation #1

Open hanjinliu opened 2 years ago

hanjinliu commented 2 years ago

Following code should work.

import coords_array as cr
arr = cr.zeros((10, 10), coords=["y", "x"])  # y and x are orthogonal

y = arr.coords.y
x = arr.coords.x

circle = (y - y.center) ** 2 + (x - x.center) ** 2 < 10  # boolean array
image = np.exp(-((y - y.center) ** 2 + (x - x.center) ** 2) / 50)  # float64 array