DataModel¶
- class photonforge.DataModel(s_matrix=None, s_array=None, frequencies=None, ports=None, interpolation_method='linear', interpolation_coords='mag_phase')¶
Model based on existing S matrix data.
- Parameters:
s_matrix (SMatrix | None) – Model data as an
SMatrix
instance.s_array (ndarray | None) – Complex array with dimensions
(F, N, N)
, in whichN
is the number of ports.frequencies (ndarray | None) – Frequency array with length
F
.ports (Sequence[str] | None) – List of port names. If not set, the sorted list of port components is used.
interpolation_method (Literal['linear', 'barycentric', 'cubicspline', 'pchip', 'akima', 'makima']) – Interpolation method used for sampling frequencies. See table below for options.
interpolation_coords (Literal['real_imag', 'mag_phase']) – Coordinate system used for interpolation. One of
"mag_phase"
or"real_imag"
.
When
s_matrix
is provided,s_array
,frequencies
, andports
should beNone
, otherwise onlyports
is optional.Interpolation method
Description
"linear"
Linear interpolation between neighboring points
"barycentric"
Barycentric Lagrange interpolation
"cubicspline"
Cubic spline interpolation
"pchip"
Piecewise cubic Hermite interpolating polynomial
"akima"
Akima interpolation
"makima"
Modified Akima interpolation
Important
Use of any interpolation method other than
"linear"
requires scipy >= 1.7, and"makima"
requires scipy >= 1.13.Note
The conversion from array to dictionary for
s_data
is equivalent tos_dict[(ports[i], ports[j])] = s_array[:, j, i]
.See also
Methods
from_bytes
(byte_repr)De-serialize this model.
s_matrix
(component, frequencies[, ...])Compute the S matrix for a component using this model.
start
(component, frequencies, **kwargs)Start computing the S matrix response from a component.
update
(*args, **kwargs)Update this model.
Attributes
Serialize this model.
parametric_function
Function used to update a parametric component.
parametric_kwargs
Keyword arguments used to update a parametric component.
random_variables
List of
monte_carlo.RandomVariable
associated to this component's parameters.- property as_bytes: bytes¶
Serialize this model.
- classmethod from_bytes(byte_repr)¶
De-serialize this model.
- Parameters:
byte_repr (bytes)
- Return type:
- start(component, frequencies, **kwargs)¶
Start computing the S matrix response from a component.
- Parameters:
component (Component) – Component from which to compute the S matrix.
frequencies (Sequence[float]) – Sequence of frequencies at which to perform the computation.
**kwargs – Unused.
- Returns:
Model result with attributes
status
ands_matrix
.- Return type: