Skip to content

Commit 44f2104

Browse files
committed
3D case, removing meshgrid and using mgrid instead
1 parent e5d3fdd commit 44f2104

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

utility_functions.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,8 @@ def distribute_srcs_2D(X, Y, n_src, ext_x, ext_y, R_init):
8484
[nx, ny, Lx_nn, Ly_nn, ds] = get_src_params_2D(Lx_n, Ly_n, n_src)
8585
ext_x_n = (Lx_nn - Lx)/2
8686
ext_y_n = (Ly_nn - Ly)/2
87-
8887
X_src, Y_src = np.mgrid[(np.min(X) - ext_x_n):(np.max(X) + ext_x_n):np.complex(0,nx),
8988
(np.min(Y) - ext_y_n):(np.max(Y) + ext_y_n):np.complex(0,ny)]
90-
9189
d = round(R_init/ds)
9290
R = d * ds
9391
return X_src, Y_src, R
@@ -164,10 +162,9 @@ def distribute_srcs_3D(X, Y, Z, n_src, ext_x, ext_y, ext_z, R_init):
164162
ext_x_n = (Lx_nn - Lx)/2
165163
ext_y_n = (Ly_nn - Ly)/2
166164
ext_z_n = (Lz_nn - Lz)/2
167-
lin_x = np.linspace(np.min(X) - ext_x_n, np.max(X) + ext_x_n, nx)
168-
lin_y = np.linspace(np.min(Y) - ext_y_n, np.max(Y) + ext_y_n, ny)
169-
lin_z = np.linspace(np.min(Z) - ext_z_n, np.max(Z) + ext_z_n, nz)
170-
(X_src, Y_src, Z_src) = np.meshgrid(lin_x, lin_y, lin_z)
165+
X_src, Y_src, Z_src = np.mgrid[(np.min(X) - ext_x_n):(np.max(X) + ext_x_n):np.complex(0,nx),
166+
(np.min(Y) - ext_y_n):(np.max(Y) + ext_y_n):np.complex(0,ny),
167+
(np.min(Z) - ext_z_n):(np.max(Z) + ext_z_n):np.complex(0,nz)]
171168
d = np.round(R_init/ds)
172169
R = d * ds
173170
return (X_src, Y_src, Z_src, R)

0 commit comments

Comments
 (0)