pmrf.fitting.BaseFitter

class pmrf.fitting.BaseFitter(model, *, features=None, output_path=None, output_root=None, sparam_kind='all')[source]

Bases: ABC

An abstract base class that provides the foundation for all fitting algorithms in pmrf.

Parameters:
  • model (Model)

  • 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]]]] | None)

  • output_path (str | None)

  • output_root (str | None)

  • sparam_kind (str)

__init__(model, *, features=None, output_path=None, output_root=None, sparam_kind='all')[source]

Initializes the BaseFitter.

Parameters:
  • model (Model) – The parametric pmrf Model to be fitted.

  • features (FeatureInputT or None, optional) – Defines the features to be extracted from the model and network(s). Defaults to None, in which case real and imaginary features for all ports are used. Can be a single feature e.g. ‘s11’, a list of features (e.g., [‘s11’, ‘s11_mag’]), or a dictionary with either of the above as value. In the dictionary case, keys must be network names in the collection passed by measured during fitting, which must also correspond to submodels which are attributes of the model. For example, {‘name1’, (‘s11’), {‘name2’, (‘s21’)} can be passed. Note that if a collection of networks is passed, but a feature dictionary is not, it is assumed that those feature(s) should be extract for each networks/submodel. See extract_features(..) more details.

  • output_path (str or None) – The path for fitters to write output data to. Defaults to None.

  • output_root (str or None) – The root name to prepend (with an underscore) to output files in the output path. Defaults to None.

  • sparam_kind (str or None) – The S-parameter data kind to use for port-expansion in feature extraction. Can either be ‘transmission’, ‘reflection’ or ‘all’. See extract_features for more details.

Return type:

None

Methods

__delattr__(name, /)

Implement delattr(self, name).

__dir__()

Default dir() implementation.

__eq__(value, /)

Return self==value.

__format__(format_spec, /)

Default object formatter.

__ge__(value, /)

Return self>=value.

__getattribute__(name, /)

Return getattr(self, name).

__gt__(value, /)

Return self>value.

__hash__()

Return hash(self).

__init__(model, *[, features, output_path, ...])

Initializes the BaseFitter.

__init_subclass__

This method is called when a class is subclassed.

__le__(value, /)

Return self<=value.

__lt__(value, /)

Return self<value.

__ne__(value, /)

Return self!=value.

__new__(**kwargs)

__reduce__()

Helper for pickle.

__reduce_ex__(protocol, /)

Helper for pickle.

__repr__()

Return repr(self).

__setattr__(name, value, /)

Implement setattr(self, name, value).

__sizeof__()

Size of object in memory, in bytes.

__str__()

Return str(self).

__subclasshook__

Abstract classes can override this to customize issubclass().

_create_context(measured, *[, model, ...])

Creates a FitContext from the provided measurement and optional overrides.

_run_algorithm(context, **kwargs)

Executes the fitting algorithm.

_run_context(context, *[, load_previous, ...])

Executes the fitting context.

fit(measured, **kwargs)

Fits the model to measured data.

fit_submodels(measured, **kwargs)

Fits the submodels.

Attributes

__abstractmethods__

__annotations__

__dict__

__doc__

__module__

__slots__

__weakref__

list of weak references to the object (if defined)

_abc_impl

__init__(model, *, features=None, output_path=None, output_root=None, sparam_kind='all')[source]

Initializes the BaseFitter.

Parameters:
  • model (Model) – The parametric pmrf Model to be fitted.

  • features (FeatureInputT or None, optional) – Defines the features to be extracted from the model and network(s). Defaults to None, in which case real and imaginary features for all ports are used. Can be a single feature e.g. ‘s11’, a list of features (e.g., [‘s11’, ‘s11_mag’]), or a dictionary with either of the above as value. In the dictionary case, keys must be network names in the collection passed by measured during fitting, which must also correspond to submodels which are attributes of the model. For example, {‘name1’, (‘s11’), {‘name2’, (‘s21’)} can be passed. Note that if a collection of networks is passed, but a feature dictionary is not, it is assumed that those feature(s) should be extract for each networks/submodel. See extract_features(..) more details.

  • output_path (str or None) – The path for fitters to write output data to. Defaults to None.

  • output_root (str or None) – The root name to prepend (with an underscore) to output files in the output path. Defaults to None.

  • sparam_kind (str or None) – The S-parameter data kind to use for port-expansion in feature extraction. Can either be ‘transmission’, ‘reflection’ or ‘all’. See extract_features for more details.

Return type:

None

fit(measured, **kwargs)[source]

Fits the model to measured data.

This method fits the full model using the original features specified.

Arguments are forwarded to self.run_context(...).

Parameters:
  • measured (skrf.Network or prf.NetworkCollection) – The measured network data to fit the model against. Can be a scikit-rf Network or a paramrf NetworkCollection. For the latter case the network names should be referenced during feature extraction by specifying features as a dictionary. If networks do not have the same frequency, a common frequency is used.

  • **kwargs – Additional arguments forwarded to the underlying algorithm via self.run_context.

Returns:

The fit results object.

Return type:

FitResults

fit_submodels(measured, **kwargs)[source]

Fits the submodels.

This method fits the model to the measured data by fitting its submodels in a sequential manner.

Arguments are forwarded to self.run_context(...).

Parameters:
  • measured (prf.NetworkCollection) – The measured network data to fit the model against. Must be a ParamRF NetworkCollection. Network names should be referenced during feature extraction by specifying features as a dictionary. If networks do not have the same frequency, a common frequency is used.

  • **kwargs – Additional arguments forwarded to the underlying algorithm via self.run_context.

Returns:

The fit results object. solver_results contains a dictionary of the individual submodel results.

Return type:

FitResults