pole_residue_fit

photonforge.pole_residue_fit(s_matrix, initial_poles=(), min_poles=1, max_poles=30, rms_error_tolerance=0.0001, max_iterations=100, max_stale_iterations=3, loss_factor=0.001, real=False, passive=True, feedthrough=False, delays=None, stable=True)

Fit S matrix elements with rational functions sharing a set of poles.

If no initial pole guess is provided, the initial guess is evenly spaced over the provided frequencies, logarithmically if real is True and linearly otherwise.

Parameters:
  • s_matrix – S matrix to be fitted.

  • initial_poles – Sequence of poles used as initial guess. Complex poles should come in conjugate pairs if real is True.

  • min_poles – Minimal number of poles to try. It has no effect when initial pole guesses are provided.

  • max_poles – Maximal number of poles to try. It has no effect when initial pole guesses are provided.

  • loss_factor – For complex initial pole guesses, ratio between their real and imaginary parts.

  • rms_error_tolerance – RMS error level to break the fitting loop.

  • max_iterations – Maximal number of fitting iterations.

  • max_stale_iterations – Maximal number of iterations without error progress.

  • real – Whether the poles come in conjugate pairs, representing a real-valued (non-baseband) system.

  • passive – Whether to attempt to enforce passivity.

  • feedthrough – Whether to include a feedthrough (constant) term in the pole-residue model.

  • delays – Dictionary of explicit time delays (in seconds), one per matrix element. Missing elements have no time delay applied. If a single number is given, this is used as a global delay for all matrix elements. If "auto", the delays are estimated from the provided data.

  • stable – Whether to ensure stability of the poles of the resulting model. Only used for troubleshooting fits.

Returns:

Tuple with PoleResidueMatrix and the fit RMS error.

Note

Including explicit delays in the model can reduce the number of poles required to obtain a good fit. However, if the delays are too large, it can be difficult to obtain a good stable fit.