Skip to content

Commit

Permalink
[mini] Fix grid size calculation in mode decomposition (#297)
Browse files Browse the repository at this point in the history
Co-authored-by: Parth Ramakant Patil <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Sep 19, 2024
1 parent a70e3ab commit 31db178
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions lasy/utils/mode_decomposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,23 @@ def hermite_gauss_decomposition(laserProfile, n_x_max=12, n_y_max=12, res=1e-6):
hi[0] = laserProfile.w0 * 5 + laserProfile.x_offset
hi[1] = laserProfile.w0 * 5 + laserProfile.x_offset

N_pts_x = int((hi[0] - lo[0]) / res)
N_pts_y = int((hi[1] - lo[1]) / res)
Nx = int((hi[0] - lo[0]) // (2 * res) * 2) + 2
Ny = int((hi[1] - lo[1]) // (2 * res) * 2) + 2

# Define spatial arrays
x = np.linspace(lo[0], hi[0], N_pts_x)
y = np.linspace(lo[1], hi[1], N_pts_y)
x = np.linspace(
(lo[0] + hi[0]) / 2 - (Nx - 1) / 2 * res,
(lo[0] + hi[0]) / 2 + (Nx - 1) / 2 * res,
Nx,
)
y = np.linspace(
(lo[1] + hi[1]) / 2 - (Ny - 1) / 2 * res,
(lo[1] + hi[1]) / 2 + (Ny - 1) / 2 * res,
Ny,
)
X, Y = np.meshgrid(x, y)
dx = x[2] - x[1]
dy = y[2] - y[1]
dx = x[1] - x[0]
dy = y[1] - y[0]

# Get the field on this grid
field = laserProfile.evaluate(X, Y)
Expand Down Expand Up @@ -123,7 +131,7 @@ def estimate_best_HG_waist(x, y, field):
"""
dx = x[1] - x[0]
dy = y[1] - y[0]
assert dx == dy
assert np.isclose(dx, dy, rtol=1e-10)

X, Y = np.meshgrid(x, y)

Expand Down

0 comments on commit 31db178

Please sign in to comment.