SMatrix¶
- class photonforge.SMatrix(frequencies, elements, ports=None)¶
S matrix object.
- Parameters:
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 = SMatrix( ... [C_0 / 1.55], ... {("P0@0", "P0@0"): [0], ("P0@0", "P1@0"): [1j]}, ... )
Methods
apply_time_delay
(delay)Apply a time delay to the S matrix data.
copy
()Create a copy of this s_matrix.
estimate_delays
([lossless])Estimate delays from the phase data of the provided S matrix.
Create a new S matrix object with the same amplitude data as the current S matrix.
load_snp
(cls, filename[, ports])Load an S matrix from a Touchstone (snp) file.
write_snp
(filename)Write this S matrix in a Touchstone (snp) file.
Attributes
S matrix elements (read only).
S matrix frequencies (read only).
S matrix ports (read only).
Object properties.
S matrix wavelengths (read only).
- apply_time_delay(delay)¶
Apply a time delay to the S matrix data. Multiplies the S matrix by $e^{2 pi i f d}$ where $f$ is the frequency and $d$ is the time delay. The S matrix is modified in-place.
- Parameters:
delay (float) – The time-delay to be applied, in seconds.
- Returns:
This object.
- Return type:
- elements¶
S matrix elements (read only).
- Type:
dict[tuple[str, str], ndarray]
- estimate_delays(lossless=False)¶
Estimate delays from the phase data of the provided S matrix.
- Parameters:
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:
Estimated delays for each matrix element.
- Return type:
dict[tuple[str, str], float]
- estimate_phase()¶
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:
Resulting minimum-phase-shift S matrix.
- Return type:
- frequencies¶
S matrix frequencies (read only).
- Type:
ndarray
- static load_snp(cls, filename, ports=())¶
Load an S matrix from a Touchstone (snp) file.
- Parameters:
filename (str) – Touchstone file name to load.
ports (Sequence[str | tuple[str, int]]) – 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 no ports are provided, default ones are used.
- Returns:
Loaded S matrix.
- Return type:
See also
- ports¶
S matrix ports (read only).
- Type:
dict[str, Port | FiberPort | GaussianPort | None]
- properties¶
Object properties.
- Type:
- wavelengths¶
S matrix wavelengths (read only).
- Type:
ndarray