pmrf.fitting.FitContext

class pmrf.fitting.FitContext(model, measured, frequency, features, measured_features, output_path=None, output_root=None, sparam_kind=None, logger=None)[source]

Bases: object

Context object holding the state and data required for a fit execution.

Parameters:
  • model (Model)

  • measured (Network | NetworkCollection)

  • frequency (Frequency)

  • features (list[tuple[str, str, tuple[int, int]]])

  • measured_features (ndarray)

  • output_path (str | None)

  • output_root (str | None)

  • sparam_kind (str | None)

  • logger (Logger | None)

model

The parametric model being fitted.

Type:

Model

measured

The target measured data.

Type:

skrf.Network or NetworkCollection

frequency

The frequency object defining the domain.

Type:

Frequency

features

The specific features to match against.

Type:

list of FeatureT

measured_features

The values of the features extracted from the measured data.

Type:

np.ndarray

output_path

Directory path for output files.

Type:

str or None

output_root

Root filename for outputs.

Type:

str or None

sparam_kind

The S-parameter representation kind (e.g., ‘all’, ‘transmission’).

Type:

str or None

logger

Logger instance for tracking progress.

Type:

logging.Logger or None

__init__(model, measured, frequency, features, measured_features, output_path=None, output_root=None, sparam_kind=None, logger=None)
Parameters:
  • model (Model)

  • measured (Network | NetworkCollection)

  • frequency (Frequency)

  • features (list[tuple[str, str, tuple[int, int]]])

  • measured_features (ndarray)

  • output_path (str | None)

  • output_root (str | None)

  • sparam_kind (str | None)

  • logger (Logger | None)

Return type:

None

Methods

__delattr__(name, /)

Implement delattr(self, name).

__dir__()

Default dir() implementation.

__eq__(other)

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.

__init__(model, measured, frequency, ...[, ...])

__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])

Create a JIT-compiled function to extract features from model parameters.

model_param_names()

Get the names of the flat parameters of the model.

settings([solver_kwargs, fitter_kwargs])

Create a FitSettings object from the current context.

Attributes

__annotations__

__dataclass_fields__

__dataclass_params__

__dict__

__doc__

__hash__

__match_args__

__module__

__weakref__

list of weak references to the object (if defined)

logger

output_path

output_root

sparam_kind

model

measured

frequency

features

measured_features

model: Model
measured: Network | NetworkCollection
frequency: Frequency
features: list[tuple[str, str, tuple[int, int]]]
measured_features: ndarray
output_path: str | None = None
output_root: str | None = None
sparam_kind: str | None = None
logger: Logger | None = None
model_param_names()[source]

Get the names of the flat parameters of the model.

Returns:

The list of parameter names.

Return type:

list of str

make_feature_function(as_numpy=False)[source]

Create a JIT-compiled function to extract features from model parameters.

Parameters:

as_numpy (bool, default=False) – If True, the returned function handles NumPy arrays; otherwise JAX arrays.

Returns:

A function taking theta and returning feature values.

Return type:

callable

settings(solver_kwargs=None, fitter_kwargs=None)[source]

Create a FitSettings object from the current context.

Parameters:
  • solver_kwargs (dict, optional) – Solver specific arguments.

  • fitter_kwargs (dict, optional) – Fitter specific arguments.

Returns:

The populated settings object.

Return type:

FitSettings

__init__(model, measured, frequency, features, measured_features, output_path=None, output_root=None, sparam_kind=None, logger=None)
Parameters:
  • model (Model)

  • measured (Network | NetworkCollection)

  • frequency (Frequency)

  • features (list[tuple[str, str, tuple[int, int]]])

  • measured_features (ndarray)

  • output_path (str | None)

  • output_root (str | None)

  • sparam_kind (str | None)

  • logger (Logger | None)

Return type:

None