Ramsey2fSeparableModel#

Module: exa.core.model_selection_fitter.models.ramsey2f_separable_model

class Ramsey2fSeparableModel(independent_vars=None, **kwargs)#

Bases: BaseModel

Parameters:
  • independent_vars (list of str, optional) – Arguments to the model function that are independent variables default is [‘x’]).

  • prefix (str, optional) – String to prepend to parameter names, needed to add two Models that have parameter names in common.

  • nan_policy ({'raise', 'propagate', 'omit'}, optional) – How to handle NaN and missing values in data. See Notes below.

  • **kwargs (optional) – Keyword arguments to pass to Model.

Notes

1. nan_policy sets what to do when a NaN or missing value is seen in the data. Should be one of:

  • ‘raise’ : raise a ValueError (default)

  • ‘propagate’ : do nothing

  • ‘omit’ : drop missing data

The model function will normally take an independent variable (generally, the first argument) and a series of arguments that are meant to be parameters for the model. It will return an array of data to model some data as for a curve-fitting problem.

Parameters:
  • func (callable) – Function to be wrapped.

  • independent_vars (list of str, optional) – Arguments to func that are independent variables (default is None).

  • param_names (list of str, optional) – Names of arguments to func that are to be made into parameters (default is None).

  • nan_policy ({'raise', 'propagate', 'omit'}, optional) – How to handle NaN and missing values in data. See Notes below.

  • prefix (str, optional) – Prefix used for the model.

  • name (str, optional) – Name for the model. When None (default) the name is the same as the model function (func).

  • **kws (dict, optional) – Additional keyword arguments to pass to model function.

Notes

1. The model function must return an array that will be the same size as the data being modeled.

2. Parameter names are inferred from the function arguments by default, and a residual function is automatically constructed.

3. Specifying independent_vars here will explicitly name the independent variables for the Model. in contrast, param_names is meant to help infer Parameter names for keyword arguments defined with **kws in the Model function.

4. nan_policy sets what to do when a NaN or missing value is seen in the data. Should be one of:

  • ‘raise’ : raise a ValueError (default)

  • ‘propagate’ : do nothing

  • ‘omit’ : drop missing data

Examples

The model function will normally take an independent variable (generally, the first argument) and a series of arguments that are meant to be parameters for the model. Thus, a simple peak using a Gaussian defined as:

>>> import numpy as np
>>> def gaussian(x, amp, cen, wid):
...     return amp * np.exp(-(x-cen)**2 / wid)

can be turned into a Model with:

>>> gmodel = Model(gaussian)

this will automatically discover the names of the independent variables and parameters:

>>> print(gmodel.param_names, gmodel.independent_vars)
['amp', 'cen', 'wid'], ['x']

Attributes

linear_parameter_names

The parameters the response is linear in, in the column order of ramsey_2f_basis().

Methods

guess

Initial guess for the model.

post_fit

Converts the quadratures back to amplitude and phase.

separable_basis

Basis the linear parameters multiply, for a solver that eliminates them.

linear_parameter_names: ClassVar[tuple[str, ...]] = ('c_cos', 'c_sin', 'offset_1', 'offset_2')#

The parameters the response is linear in, in the column order of ramsey_2f_basis().

separable_basis(t, f_d, f_q, tau, T_exp)#

Basis the linear parameters multiply, for a solver that eliminates them.

See ramsey_2f_basis() for the arguments and the layout of the returned matrix.

Parameters:
Return type:

ndarray

guess(data, t, f_d, **kws)#

Initial guess for the model.

Delegates to Ramsey2fModel, whose guess is in an amplitude and a phase, and converts those to the two quadratures.

Parameters:
  • data (ndarray) – 2D array to fit.

  • t (ndarray) – The time coordinate values.

  • f_d (ndarray) – Frequencies of the two drive tones.

  • kws – Values for the model parameters.

Return type:

Parameters

post_fit(fitresult)#

Converts the quadratures back to amplitude and phase.

Parameters:

fitresult (ModelResult)

Return type:

None

Inheritance

Inheritance diagram of exa.core.model_selection_fitter.models.ramsey2f_separable_model.Ramsey2fSeparableModel