Skip to content

SMatrix

SMatrix(frequencies, elements, ports=None)

S matrix object.

Args

  • frequencies (Sequence[float]): Frequency values for the computed elements.
  • elements (dict[tuple[str, str], Sequence[complex]]): Mapping from pairs of port names and mode numbers to S matrix elements. The keys must be: ("in_port@in_mode", "out_port@out_mode").
  • ports (dict[str, Port | FiberPort | GaussianPort | None] | None): Mapping from port names to ports or to None.

Example

>>> s_matrix = pf.SMatrix(
... [pf.C_0 / 1.55],
... {("P0@0", "P0@0"): [0], ("P0@0", "P1@0"): [1j]},
... )
MethodDescription
apply_time_delayApply a time delay to the S matrix data. Multiplies the S matrix
copyCreate a copy of this s_matrix.
estimate_delaysEstimate delays from the phase data of the provided S matrix.
estimate_phaseCreate a new S matrix object with the same amplitude data
force_symmetricForce this S matrix to be symmetric.
load_snpLoad an S matrix from a Touchstone (snp) file.
write_snpWrite this S matrix in a Touchstone (snp) file.

apply_time_delay(self, delay)

Apply a time delay to the S matrix data. Multiplies the S matrix by e2πifde^{2 \pi i f d} where ff is the frequency and dd is the time delay. The S matrix is modified in-place.

Args

  • delay (float): The time-delay to be applied, in seconds.

Returns

SMatrix: This object.

copy(self)

Create a copy of this s_matrix.

Returns

SMatrix: New copy.

estimate_delays(self, lossless=False)

Estimate delays from the phase data of the provided S matrix.

Args

  • lossless (bool): If False, estimate the actual delays; otherwise estimate the lossless delays. The lossless delays are less than the true delays, and they give the phase difference between the provided phase data and that of a minimum-phase-shift system with the same amplitude data. The lossless delays may be more appropriate for pole-residue fitting.

Returns

dict[tuple[str, str], float]: Estimated delays for each matrix element.

estimate_phase(self)

Create a new S matrix object with the same amplitude data as the current S matrix. The phase data in the new S matrix is estimated from the amplitude data assuming a minimum-phase-shift (mps) model. The phase at zero frequency is preserved.

Returns

SMatrix: Resulting minimum-phase-shift S matrix.

force_symmetric(self)

Force this S matrix to be symmetric.

Reciprocity is ensured by averaging transposed entries (if both are present) or filling in missing elements.

Returns

SMatrix: This object.

load_snp(cls, filename, ports=None, conjugate=False)

Load an S matrix from a Touchstone (snp) file.

Args

  • filename (str): Touchstone file name to load.
  • ports (Sequence[str | tuple[str, int]] | None): Sequence of port names to be associated with the ports in the Touchstone file. Each element in the sequence can also be a tuple with port name and number of supported modes in case of multimode ports. If None, the port list in the file comments is used, if present (see SMatrix.write_snp). If empty or if the file has no port list, default ones are used.
  • conjugate (bool): If set, conjugate the loaded data. Used for files in the exp(+jωt) time convention.

Returns

SMatrix: Loaded S matrix.

See Also

Data Model

write_snp(self, filename, conjugate=False, comments=None)

Write this S matrix in a Touchstone (snp) file.

Args

  • filename (str): Touchstone file name to write.
  • conjugate (bool): If set, conjugate the written data, e.g., for tools that use the exp(+jωt) time convention.
  • comments (Sequence[str] | None): Comment lines written before the network data. Lines not starting with "!" are prefixed with "! ". If None, the conjugation flag and the port list are written (see note).

Note

The order of the ports in the S matrix is sorted by name and mode number, with numeric suffixes in natural order, e.g., “P2@0”, “P2@1”, …, “P2@10”, “P10@0”, etc.

The default comments have the form:

! [Conjugate Data] Yes
! [Optical Port List]
! Port[0]: "P0", mode 0
! Port[1]: "P0", mode 1
! Port[2]: "P1", mode 0
! [Optical Port End]

Returns

SMatrix: This object.

AttributeDescription
elementsdict[tuple[str, str], ndarray]: S matrix elements (read only).
frequenciesndarray: S matrix frequencies (read only).
portsdict[str, Port | FiberPort | GaussianPort | None]: S matrix ports (read only).
propertiesProperties: Object properties.
wavelengthsndarray: S matrix wavelengths (read only).

dict[tuple[str, str], ndarray]: S matrix elements (read only).

ndarray: S matrix frequencies (read only).

dict[str, Port | FiberPort | GaussianPort | None]: S matrix ports (read only).

Properties: Object properties.

ndarray: S matrix wavelengths (read only).