SMatrix¶
- class photonforge.SMatrix(frequencies, elements, ports=None)¶
S matrix object.
- Parameters:
frequencies – Frequency values for the computed elements.
elements – Mapping from pairs of port names and mode numbers to S matrix elements. The keys have the format:
("in_port@in_mode", "out_port@out_mode")
.ports – 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).
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 – The time-delay to be applied, in seconds.
- Returns:
This object.
- copy()¶
Create a copy of this s_matrix.
- Returns:
New copy.
- elements¶
S matrix elements (read only).
- estimate_delays(lossless=False)¶
Estimate delays from the phase data of the provided S matrix.
- Parameters:
lossless – If
False
, estimates the actual delays; ifTrue
, estimates 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:
Dictonary of estimated delays, one per matrix element.
- 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.
- frequencies¶
S matrix frequencies (read only).
- static load_snp(cls, filename, ports=())¶
Load an S matrix from a Touchstone (snp) file.
- Parameters:
filename – Touchstone file name to load.
ports – 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:
See also
- ports¶
S matrix ports (read only).
- wavelengths¶
S matrix wavelengths (read only).
- write_snp(filename)¶
Write this S matrix in a Touchstone (snp) file.
- Parameters:
filename – Touchstone file name to write.
Note
The order of the ports in the S matrix is sorted by name and mode number, e.g., “P0@0”, “P0@1”, “P1@0”, etc.
- Returns:
This object.