pmrf.extract_features

pmrf.extract_features(source, frequency, features, dtype=<class 'jax.numpy.complex128'>)[source]

Extracts features from a model or a network.

This function allows for an arbitrary number of features (e.g. [‘s11’, ‘a21_mag’]) to be easily extracted from a model or a measured network. The resultant features are combined column-by-column into a matrix with frequency in the row dimension.

Features can either be specified by convenient aliases using strings, or by their full structure. As some examples to demonstrate the possibilities: - To extract S11 magnitude, specify either the alias ‘s11_db’ or the full tuple (‘’, ‘s_db’ (0, 0)).

Note that, for the tuple, the empty string at the beginning represents the base model (expanded on below).

  • To extract e.g. the phase of the B parameter of the ABCD matrix, specify ‘a21_deg’.

  • To extract any other feature in the model that is a function of frequency (e.g. a custom user function), simply use ‘myfeature’ instead of ‘s11’.

  • To extract features from a submodel or specific network, specify a dictionary with the submodel as a key e.g. {‘submodel’: ‘s11_db’}. For models, this extracts a feature from a submodel that must be retrievable via getattr. Submodels can also be nested e.g. {‘src1.submodel1.submodel2’: ‘s11_db’}. For measured networks, this extracts a feature from the corresponding network with that label in the dictionary. For the above example, is is converted to the feature tuple (‘src_name’, ‘s_db’, (0, 0)’).

  • For a list of features, specify a list of any of the above (or, equivalently, a dictionary of lists).

Args:
source (Model | skrf.Network | dict[str, skrf.Network]): The source model or network(s) to extract the features from,

with missing networks specified using integers for the number of ports at that index. Lists of networks are treated as forming one, stack network with isolated ports.

features (FeatureInputT): The features to extract, as described in detail above. frequency (pmrf.Frequency | skrf.Frequency, optional): The frequency to extract the features at. This will become the row dimension of the resultant matrix.

This must be passed for Model sources. Defaults to None e.g. for measured networks, in which case the network’s internal frequency is used. Otherwise, the network is i508e76ad-05af-4e71-8c22-053f37e3a62dnterpolated.

dtype (jnp.dtype, optional): The data type of the final out feature matrix.

Returns:

np.ndarray: The feature matrix of size M x N, where M is the number of frequencies and N is the number of features.

Parameters:
  • source (Model | Network | dict[str, Network])

  • frequency (Frequency | None)

  • features (str | tuple[str, str] | tuple[str, str, tuple[int, int]] | Sequence[str | tuple[str, str] | tuple[str, str, tuple[int, int]]] | dict[str, str | tuple[str, str] | tuple[str, str, tuple[int, int]] | Sequence[str | tuple[str, str] | tuple[str, str, tuple[int, int]]]])

  • dtype (dtype)

Return type:

Array