gwexpy.interop.skrf_
Interoperability with scikit-rf for RF and microwave network analysis.
Functions
|
Create TimeSeries or TimeSeriesDict from a scikit-rf Network impulse response. |
|
Create GWexpy frequency objects from a scikit-rf network. |
|
Create TimeSeries or TimeSeriesDict from a scikit-rf Network step response. |
|
Create a scikit-rf Network from a FrequencySeries or FrequencySeriesMatrix. |
- gwexpy.interop.skrf_.from_skrf_network(cls: type, ntwk: Any, *, parameter: str = 's', port_pair: tuple[int, int] | None = None, unit: Any | None = None) Any[source]
Create GWexpy frequency objects from a scikit-rf network.
- Parameters:
cls (type) – The FrequencySeries (or FrequencySeriesDict) class to instantiate.
ntwk (skrf.Network) – The scikit-rf Network object to convert.
parameter (str, default
"s") – Which network parameter to extract. One of"s"(scattering),"z"(impedance),"y"(admittance),"a"(ABCD, 2-port only),"t"(transfer scattering, 2-port only), or"h"(hybrid, 2-port only).port_pair (tuple[int, int], optional) –
Zero-based
(row, col)port indices to extract a single element of the parameter matrix, e.g.(1, 0)for S₂₁. If None:1-port networks return a
FrequencySeriesdirectly.Multi-port networks return a
FrequencySeriesMatrixwhen cls isFrequencySeries, or aFrequencySeriesDictwhen cls isFrequencySeriesDict.
unit (str or astropy.units.Unit, optional) – Unit to assign to the result. If None, a default unit is inferred from parameter:
None(dimensionless) for"s","t","a";"ohm"for"z";"S"for"y".
- Returns:
FrequencySeries – For a single port pair or a 1-port network.
FrequencySeriesMatrix – For a multi-port network when cls is
FrequencySeries.FrequencySeriesDict – When cls is
FrequencySeriesDict; keys are"P{row+1}{col+1}"or"S{row+1}{col+1}"etc.
Examples
>>> from gwexpy.frequencyseries import FrequencySeries >>> import skrf >>> ntwk = skrf.Network("myfilter.s2p") >>> fs_s21 = FrequencySeries.from_skrf_network(ntwk, port_pair=(1, 0)) >>> matrix = FrequencySeries.from_skrf_network(ntwk)
- gwexpy.interop.skrf_.to_skrf_network(fs: Any, *, parameter: str = 's', z0: float = 50.0, port_names: list[str] | None = None, name: str | None = None) Any[source]
Create a scikit-rf Network from a FrequencySeries or FrequencySeriesMatrix.
- Parameters:
fs (FrequencySeries or FrequencySeriesMatrix) – Source data. A
FrequencySeriesis treated as a 1-port network (scalar parameter). AFrequencySeriesMatrixof shape(N, N, nfreq)is treated as an N-port network.parameter (str, default
"s") – Network parameter represented by the data. Currently only"s"is supported for direct construction; other parameters require manual conversion.z0 (float, default 50.0) – Reference impedance in Ohms applied to all ports at all frequencies.
port_names (list[str], optional) – Names for each port. Defaults to
["1", "2", ...].name (str, optional) – Name for the resulting Network. If None, uses
fs.name.
- Returns:
The constructed Network object.
- Return type:
skrf.Network
Examples
>>> from gwexpy.frequencyseries import FrequencySeries >>> import numpy as np >>> fs = FrequencySeries(np.array([0.1+0j, 0.2+0j]), frequencies=[1e9, 2e9]) >>> ntwk = fs.to_skrf_network()
- gwexpy.interop.skrf_.from_skrf_impulse_response(cls: type, ntwk: Any, *, port_pair: tuple[int, int] | None = None, n: int | None = None, pad: int = 0, unit: Any | None = None) Any[source]
Create TimeSeries or TimeSeriesDict from a scikit-rf Network impulse response.
Computes the time-domain impulse response via IFFT on the S-parameters (or the selected port pair) and wraps the result in a
TimeSeries.- Parameters:
cls (type) – The TimeSeries (or TimeSeriesDict) class to instantiate.
ntwk (skrf.Network) – The scikit-rf Network object.
port_pair (tuple[int, int], optional) –
Zero-based
(row, col)port indices to compute the impulse response for. If None:1-port networks compute the single impulse response.
Multi-port networks compute all port pairs and return a
TimeSeriesDict.
n (int, optional) – Number of points for the IFFT. See
Network.impulse_response.pad (int, default 0) – Number of zero-padding points before IFFT.
unit (str or astropy.units.Unit, optional) – Unit to assign to the result.
- Returns:
TimeSeries – For a single port pair or a 1-port network.
TimeSeriesDict – For a multi-port network when no port_pair is specified.
Examples
>>> from gwexpy.timeseries import TimeSeries >>> import skrf >>> ntwk = skrf.Network("myfilter.s2p") >>> ts = TimeSeries.from_skrf_impulse_response(ntwk, port_pair=(1, 0))
- gwexpy.interop.skrf_.from_skrf_step_response(cls: type, ntwk: Any, *, port_pair: tuple[int, int] | None = None, n: int | None = None, pad: int = 0, unit: Any | None = None) Any[source]
Create TimeSeries or TimeSeriesDict from a scikit-rf Network step response.
Computes the time-domain step response via IFFT on the S-parameters (or the selected port pair) and wraps the result in a
TimeSeries.- Parameters:
cls (type) – The TimeSeries (or TimeSeriesDict) class to instantiate.
ntwk (skrf.Network) – The scikit-rf Network object.
port_pair (tuple[int, int], optional) –
Zero-based
(row, col)port indices to compute the step response for. If None:1-port networks compute the single step response.
Multi-port networks compute all port pairs and return a
TimeSeriesDict.
n (int, optional) – Number of points for the IFFT. See
Network.step_response.pad (int, default 0) – Number of zero-padding points before IFFT.
unit (str or astropy.units.Unit, optional) – Unit to assign to the result.
- Returns:
TimeSeries – For a single port pair or a 1-port network.
TimeSeriesDict – For a multi-port network when no port_pair is specified.
Examples
>>> from gwexpy.timeseries import TimeSeries >>> import skrf >>> ntwk = skrf.Network("myfilter.s2p") >>> ts = TimeSeries.from_skrf_step_response(ntwk, port_pair=(1, 0))