Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Dec 28, 2024
1 parent 409a5d0 commit 4d5a2bd
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lasy/utils/mode_decomposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def hermite_gauss_decomposition(
in the decomposition. The keys of the dictionary are tuples
corresponding to (`m`,`n`)
waist : array of floats
waist : array of floats
Beam waist for which the decomposition is calculated.
It is computed as the waist for which the weight of order 0 is maximum.
"""
Expand Down Expand Up @@ -138,19 +138,21 @@ def estimate_best_HG_waist(x, y, field, wavelength):

D4SigX, D4SigY = find_d4sigma(np.abs(field) ** 2)
# convert this to a 1/e^2 width
w0EstX = np.mean(D4SigX) / 2 * dx
w0EstY = np.mean(D4SigY) / 2 * dy
w0EstX = np.mean(D4SigX) / 2 * dx
w0EstY = np.mean(D4SigY) / 2 * dy

# Scan around the waist obtained from the D4sigma calculation,
# and keep the waist for which this HG mode has the highest scalar
# product with the input profile.
waistTestX = np.linspace(w0EstX / 2, w0EstX * 1.5, 30)
waistTestY = np.linspace(w0EstY / 2, w0EstY * 1.5, 30)
coeffTest = np.zeros_like(waistTestX)
coeffTest = np.zeros_like(waistTestX)

for i, wTest in enumerate(waistTestX):
# create a gaussian
HGMode = HermiteGaussianTransverseProfile(wTest, waistTestY[i], 0, 0, wavelength)
HGMode = HermiteGaussianTransverseProfile(
wTest, waistTestY[i], 0, 0, wavelength
)
profile = HGMode.evaluate(X, Y)
coeffTest[i] = np.real(np.sum(profile * field))
waistX = waistTestX[np.argmax(coeffTest)]
Expand All @@ -159,4 +161,4 @@ def estimate_best_HG_waist(x, y, field, wavelength):

print("Estimated w0(x-axis) = %.2f microns (1/e^2 width)" % (w0[0] * 1e6))
print("Estimated w0(y-axis) = %.2f microns (1/e^2 width)" % (w0[1] * 1e6))
return w0
return w0

0 comments on commit 4d5a2bd

Please sign in to comment.