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]},... )Methods
Section titled “Methods”| Method | Description |
|---|---|
apply_time_delay | Apply a time delay to the S matrix data. Multiplies the S matrix |
copy | Create a copy of this s_matrix. |
estimate_delays | Estimate delays from the phase data of the provided S matrix. |
estimate_phase | Create a new S matrix object with the same amplitude data |
force_symmetric | Force this S matrix to be symmetric. |
load_snp | Load an S matrix from a Touchstone (snp) file. |
write_snp | Write this S matrix in a Touchstone (snp) file. |
apply_time_delay
Section titled “apply_time_delay”apply_time_delay(self, delay)Apply a time delay to the S matrix data. Multiplies the S matrix by where is the frequency and 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
Section titled “estimate_delays”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
Section titled “estimate_phase”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
Section titled “force_symmetric”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
Section titled “load_snp”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 (seeSMatrix.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
write_snp
Section titled “write_snp”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"! ". IfNone, 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.
Attributes
Section titled “Attributes”| Attribute | Description |
|---|---|
elements | dict[tuple[str, str], ndarray]: S matrix elements (read only). |
frequencies | ndarray: S matrix frequencies (read only). |
ports | dict[str, Port | FiberPort | GaussianPort | None]: S matrix ports (read only). |
properties | Properties: Object properties. |
wavelengths | ndarray: S matrix wavelengths (read only). |
elements
Section titled “elements”dict[tuple[str, str], ndarray]: S matrix elements (read only).
frequencies
Section titled “frequencies”ndarray: S matrix frequencies (read only).
dict[str, Port | FiberPort | GaussianPort | None]: S matrix ports (read only).
properties
Section titled “properties”Properties: Object properties.
wavelengths
Section titled “wavelengths”ndarray: S matrix wavelengths (read only).