pmrf.fitting.BaseFitter

class pmrf.fitting.BaseFitter(model, measured, frequency=None, features=None, output_path='output', output_root='fit', sparam_kind='both')[source]

Bases: ABC

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

Initializes the BaseFitter.

Args:

model (Model): The parametric pmrf Model to be fitted. measured (skrf.Network | 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. See the documentation for the features argument below.

features (FeatureInputT | 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, 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.

frequency (Frequency | None, optional): The frequency axis to perform the fit on. Defaults to None, in which case

the measured frequency is used. Note that if a NetworkCollection is passed, all networks must have the same frequency.

output_path (str | None): The path for fitters to write output data to. Not used by all fitters. Defaults to None. output_root (str | None): The root name used for output files in the output path. Not used by all fitters. Defaults to None. sparam_kind (str | None): The S-parameter data kind to use for port-expansion in feature extraction. Can either be ‘transmission’, ‘reflection’ or ‘both’.

See extract_features for more details.

Parameters:
  • model (Model)

  • measured (str | Network | NetworkCollection)

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

  • output_path (str)

  • output_root (str)

  • sparam_kind (str)

__init__(model, measured, frequency=None, features=None, output_path='output', output_root='fit', sparam_kind='both')[source]

Initializes the BaseFitter.

Args:

model (Model): The parametric pmrf Model to be fitted. measured (skrf.Network | 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. See the documentation for the features argument below.

features (FeatureInputT | 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, 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.

frequency (Frequency | None, optional): The frequency axis to perform the fit on. Defaults to None, in which case

the measured frequency is used. Note that if a NetworkCollection is passed, all networks must have the same frequency.

output_path (str | None): The path for fitters to write output data to. Not used by all fitters. Defaults to None. output_root (str | None): The root name used for output files in the output path. Not used by all fitters. Defaults to None. sparam_kind (str | None): The S-parameter data kind to use for port-expansion in feature extraction. Can either be ‘transmission’, ‘reflection’ or ‘both’.

See extract_features for more details.

Parameters:
  • model (Model)

  • measured (str | Network | NetworkCollection)

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

  • output_path (str)

  • output_root (str)

  • sparam_kind (str)

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, measured[, frequency, ...])

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().

_make_feature_function([as_numpy])

_settings([solver_kwargs, fitter_kwargs])

run(*args, **kwargs)

Executes the fitting algorithm.

Attributes

__abstractmethods__

__annotations__

__dict__

__doc__

__module__

__slots__

__weakref__

list of weak references to the object (if defined)

_abc_impl

abstract run(*args, **kwargs)[source]

Executes the fitting algorithm.

This method must be implemented by all concrete subclasses. It is the main entry point to start the optimization or sampling process.

Returns:

FitResults: An object containing the results of the fit.

Return type:

FitResults