edges.modeling.composite

Module defining composite models.

class edges.modeling.composite.ComplexMagPhaseModel(mag: Model | FixedLinearModel, phs: Model | FixedLinearModel)[source]

A composite model that is specifically for complex functions in mag/phase.

at(**kwargs) FixedLinearModel[source]

Get an evaluated linear model.

fit(ydata: ndarray, weights: ndarray | float = 1.0, xdata: ndarray | None = None, **kwargs)[source]

Create a linear-regression fit object.

classmethod from_file(path: str | Path | Group)

Load an HDF5 file as a given type.

write(path: str | Path | Group)

Write an attrs class to HDF5.

class edges.modeling.composite.ComplexRealImagModel(real: Model | FixedLinearModel, imag: Model | FixedLinearModel)[source]

A composite model that is specifically for complex functions in real/imag.

at(**kwargs) FixedLinearModel[source]

Get an evaluated linear model.

fit(ydata: ndarray, weights: ndarray | float = 1.0, xdata: ndarray | None = None, **kwargs)[source]

Create a linear-regression fit object.

classmethod from_file(path: str | Path | Group)

Load an HDF5 file as a given type.

write(path: str | Path | Group)

Write an attrs class to HDF5.

class edges.modeling.composite.CompositeModel(*, models: dict[str, Model], data_transform: DataTransform = NOTHING)[source]

Define a composite model from a set of sub-models.

In totality, the resulting model is still

at(**kwargs) FixedLinearModel[source]

Get an evaluated linear model.

fit(xdata: ndarray, ydata: ndarray, weights: ndarray | float = 1.0, **kwargs) ModelFit[source]

Create a linear-regression fit object.

classmethod from_file(path: str | Path | Group)

Load an HDF5 file as a given type.

get_basis_term(indx: int, x: ndarray) ndarray[source]

Define the basis terms for the model.

get_basis_term_transformed(indx: int, x: ndarray, with_scaler: bool = True) ndarray[source]

Get the basis function term after coordinate tranformation.

get_basis_terms(x: ndarray, with_scaler: bool = True) ndarray[source]

Get a 2D array of all basis terms at x.

get_model(model: str, parameters: ndarray = None, x: ndarray | None = None, with_scaler: bool = True)[source]

Calculate a sub-model.

property model_idx: dict[str, slice]

Dictionary of parameter indices correponding to each model.

property n_terms: int

The number of terms in the full composite model.

property parameters: ndarray | None

The read-only list of parameters of all sub-models.

with_nterms(model: str, n_terms: int | None = None, parameters: Sequence | None = None) Model[source]

Return a new Model with given nterms and parameters.

with_params(parameters: Sequence)[source]

Get a new model with specified parameters.

write(path: str | Path | Group)

Write an attrs class to HDF5.