Skip to content

Commit

Permalink
Updating Definition of Hermite-Gaussian Modes (#319)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Maxence Thévenet <[email protected]>
  • Loading branch information
3 people authored Nov 14, 2024
1 parent 802fe00 commit 0529779
Show file tree
Hide file tree
Showing 6 changed files with 242 additions and 185 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ Hermite Gaussian Transverse Profile
===================================

Used to define a Hermite-Gaussian transverse laser profile.
Hermite-Gaussian modes are a family of solutions to the paraxial wave equation written in cartesian coordinates. The modes are characterised by two transverse indices :math:`n_x` and :math:`n_y`.
Hermite-Gaussian modes are a family of solutions to the paraxial wave equation written in cartesian coordinates. The modes are characterised by two transverse indices :math:`m` and :math:`n`.

.. image:: https://user-images.githubusercontent.com/27694869/211018259-15d925bb-f123-42c6-b5ba-86488356ae70.png
:alt: Hermite-Gauss-Modes

------------

Expand Down
63 changes: 55 additions & 8 deletions docs/source/tutorials/denoised_laser.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -309,19 +309,19 @@
"outputs": [],
"source": [
"# Maximum Hermite-Gauss mode index in x and y\n",
"n_modes_x = 2\n",
"n_modes_y = 2\n",
"m_max = 10\n",
"n_max = 10\n",
"\n",
"# Calculate the decomposition and waist of the laser pulse\n",
"modeCoeffs, waist = hermite_gauss_decomposition(\n",
" transverse_profile, n_x_max=n_modes_x, n_y_max=n_modes_y, res=cal\n",
" transverse_profile, longitudinal_profile.lambda0, m_max=m_max, n_max=n_max, res=cal\n",
")\n",
"\n",
"# Create a num profile, summing over the first few modes\n",
"energy_frac = 0\n",
"for i, mode_key in enumerate(list(modeCoeffs)):\n",
" tmp_transverse_profile = HermiteGaussianTransverseProfile(\n",
" waist, mode_key[0], mode_key[1]\n",
" waist, waist, mode_key[0], mode_key[1], longitudinal_profile.lambda0\n",
" )\n",
" energy_frac += modeCoeffs[mode_key] ** 2 # Energy fraction of the mode\n",
" if i == 0: # First mode (0,0)\n",
Expand Down Expand Up @@ -365,13 +365,14 @@
"# Determine the figure parameters\n",
"fig, ax = plt.subplots(1, 3, figsize=(12, 4), tight_layout=True)\n",
"fig.suptitle(\n",
" \"Hermite-Gauss Reconstruction using n_x_max = %i, n_y_max = %i\"\n",
" % (n_modes_x, n_modes_y)\n",
" \"Hermite-Gauss Reconstruction using m_max = %i, n_max = %i\" % (m_max, n_max)\n",
")\n",
"\n",
"# Plot the original profile\n",
"pltextent = np.array([np.min(x), np.max(x), np.min(x), np.max(x)]) * 1e6 # in microns\n",
"prof1 = np.abs(laser_profile_raw.evaluate(X, Y, 0)) ** 2\n",
"maxInten = np.max(prof1)\n",
"prof1 /= maxInten\n",
"divider0 = make_axes_locatable(ax[0])\n",
"ax0_cb = divider0.append_axes(\"right\", size=\"5%\", pad=0.05)\n",
"pl0 = ax[0].imshow(prof1, cmap=\"magma\", extent=pltextent, vmin=0, vmax=np.max(prof1))\n",
Expand All @@ -383,6 +384,7 @@
"\n",
"# Plot the reconstructed profile\n",
"prof2 = np.abs(laser_profile_cleaned.evaluate(X, Y, 0)) ** 2\n",
"prof2 /= maxInten\n",
"divider1 = make_axes_locatable(ax[1])\n",
"ax1_cb = divider1.append_axes(\"right\", size=\"5%\", pad=0.05)\n",
"pl1 = ax[1].imshow(prof2, cmap=\"magma\", extent=pltextent, vmin=0, vmax=np.max(prof1))\n",
Expand All @@ -403,6 +405,51 @@
"ax[2].set_ylabel(\"y ($ \\\\mu m $)\")\n",
"ax[2].set_title(\"Error\")\n",
"\n",
"plt.show()\n",
"\n",
"fig2, ax2 = plt.subplots(2, 1, figsize=(8, 6), tight_layout=True)\n",
"fig2.suptitle(\n",
" \"Hermite-Gauss Reconstruction using m_max = %i, n_max = %i\" % (m_max, n_max)\n",
")\n",
"ax2[0].plot(\n",
" x * 1e6,\n",
" prof2[int(len(x) / 2), :],\n",
" label=\"Reconstructed Profile\",\n",
" color=(1, 0.5, 0.5),\n",
" lw=2.5,\n",
")\n",
"ax2[0].plot(\n",
" x * 1e6,\n",
" prof1[int(len(x) / 2), :],\n",
" label=\"Original Profile\",\n",
" color=(0.3, 0.3, 0.3),\n",
" lw=1.0,\n",
")\n",
"ax2[0].legend()\n",
"ax2[0].set_xlim(pltextent[0], pltextent[1])\n",
"ax2[0].set_xlabel(\"x ($ \\\\mu m $)\")\n",
"ax2[0].set_ylabel(\"Intensity (norm.)\")\n",
"\n",
"ax2[1].plot(\n",
" x * 1e6,\n",
" prof2[int(len(x) / 2), :],\n",
" label=\"Reconstructed Profile\",\n",
" color=(1, 0.5, 0.5),\n",
" lw=2.5,\n",
")\n",
"ax2[1].plot(\n",
" x * 1e6,\n",
" prof1[int(len(x) / 2), :],\n",
" label=\"Original Profile\",\n",
" color=(0.3, 0.3, 0.3),\n",
" lw=1.0,\n",
")\n",
"ax2[1].legend()\n",
"ax2[1].set_xlim(pltextent[0], pltextent[1])\n",
"ax2[1].set_yscale(\"log\")\n",
"ax2[1].set_xlabel(\"x ($ \\\\mu m $)\")\n",
"ax2[1].set_ylabel(\"Intensity (norm.)\")\n",
"\n",
"plt.show()"
]
},
Expand Down Expand Up @@ -473,7 +520,7 @@
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"display_name": "base",
"language": "python",
"name": "python3"
},
Expand All @@ -487,7 +534,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.0"
"version": "3.12.7"
}
},
"nbformat": 4,
Expand Down
110 changes: 0 additions & 110 deletions examples/example_modal_decomposition_data.py

This file was deleted.

Loading

0 comments on commit 0529779

Please sign in to comment.