"""Ideal Hermite-Gaussian waist intensities; Python 3.14, NumPy 2.3.5, Matplotlib 3.10.7. Run through Make in the mirrored media working directory. Each panel is normalized by its own peak; this is a comparison of spatial shape, not equal optical power. """ from pathlib import Path import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt import numpy as np from numpy.polynomial.hermite import hermval def field(m, n, x, y): """Real waist-plane field in coordinates x/w0, y/w0 (unnormalized).""" cm = np.zeros(m + 1) cn = np.zeros(n + 1) cm[m] = cn[n] = 1 return hermval(np.sqrt(2) * x, cm) * hermval(np.sqrt(2) * y, cn) * np.exp(-(x*x + y*y)) def main(): coords = np.linspace(-2, 2, 401) x, y = np.meshgrid(coords, coords) fig, axes = plt.subplots(1, 4, figsize=(10, 3.5), facecolor='white') fig.suptitle('Transverse cavity modes: intensity at the beam waist', fontsize=14, y=.97) for ax, (m, n) in zip(axes, [(0, 0), (1, 0), (2, 0), (1, 1)]): intensity = field(m, n, x, y)**2 image = ax.imshow(intensity/intensity.max(), extent=(-2, 2, -2, 2), origin='lower', cmap='Blues', vmin=0, vmax=1, interpolation='nearest') ax.set_title(f'Order ({m}, {n})', fontsize=12) ax.set_xlabel(r'$x/w_0$') ax.set_xticks([-2, 0, 2]) ax.set_yticks([-2, 0, 2]) ax.set_facecolor('white') axes[0].set_ylabel(r'$y/w_0$') fig.subplots_adjust(left=.055, right=.91, bottom=.22, top=.81, wspace=.30) cax = fig.add_axes([.93, .29, .015, .40]) fig.colorbar(image, cax=cax, ticks=[0, .5, 1], label='Relative intensity') fig.text(.5, .055, 'Each panel normalized to its own peak; field phase is not shown.', ha='center', fontsize=10) fig.savefig(Path.cwd()/'transverse-cavity-mode-patterns.png', dpi=112, facecolor='white') plt.close(fig) if __name__ == '__main__': main()