finesse.knm.maps.scattering_coefficients_to_KnmMatrix

finesse.knm.maps.scattering_coefficients_to_KnmMatrix(modes, K)

Converts a 4-D scattering coefficient array into a 2D KnmMatrix object to be used in simulations.

Parameters:
modestuple, array

Array of 2D modes indicies (n,m) to specify the order in which they appear in the returned matrix.

Karray

4D array of coefficients indexed with [in_x, out_x, in_y, out_y]

Returns:
KnmKnmMatrix

A KnmMatrix class representing a 2D scattering matrix for the requested modes.

Examples

Compute KNM matrix from a previously calculated 4-D scattering coefficient array:

import finesse
from finesse.knm.maps import (
    map_scattering_coefficients,
    scattering_coefficients_to_KnmMatrix
)
import numpy as np

# compute all scatterings up to maximum TEM order
maxtem = 3
q = finesse.BeamParam(w0=1e-3, z=0)
x = np.linspace(-4*q.w, 4*q.w, 201)
y = np.linspace(-4*q.w, 4*q.w, 200)
X, Y = np.meshgrid(x, y)
# Mix of liner and quadratic phase terms to compute scattering
# coefficients for
Z = np.exp(1j * 1e-6 * 2 * np.pi * X / 1064e-9)
K = map_scattering_coefficients(q, maxtem, x, y, Z)
# Generate specific ordering of coefficients into a 2D matrix that can
# be used in simulations for propagating and array of modes.
modes = (
    (0,0),
    (1,0),
    (2,1),
)
Knm = scattering_coefficients_to_KnmMatrix(modes, K)
# Propagate some mode amplitudes
Knm.data @ [1, 0.1, 0]
>>> array([9.99995641e-01+2.95261180e-04j,
           9.99986923e-02+2.95261180e-03j,
           4.23516474e-22+2.16840434e-20j])