bayes : Fit simulated profiles against experiment

class idpflex.bayes.TabulatedFunctionModel(xdata, ydata, interpolator_kind='linear', prefix='', missing=None, name=None, **kwargs)[source]

Bases: lmfit.model.Model

A fit model that uses a table of (x, y) values to interpolate

Uses interp1d

Fitting parameters:
  • integrated intensity amplitude \(A\)

  • position of the peak center \(E_0\)

  • nominal relaxation time tau \(\tau\)

  • stretching exponent beta \(\beta\)

Parameters
  • xdata (ndarray) – X-values to construct the interpolator

  • ydata (ndarray) – Y-values to construct the interpolator

  • interpolator_kind (str) – Interpolator that interp1d should use

guess(y, x=None, **kwargs)[source]

Estimate fitting parameters from input data

Parameters
  • y (ndarray) – Values to fit to, e.g., SANS or SAXS intensity values

  • x (ndarray) – independent variable, e.g., momentum transfer

Returns

Parameters with estimated initial values.

Return type

Parameters

idpflex.bayes.fit_at_depth(tree, experiment, property_name, depth)[source]

Fit at a particular tree depth from the root node

Fit experiment against the property stored in the nodes. The fit model is generated by model_at_depth()

Parameters
  • tree (Tree) – Hierarchical tree

  • experiment (ProfileProperty) – A property containing the experimental info.

  • property_name (str) – The name of the simulated property to compare against experiment

  • max_depth (int) – Fit at each depth up to (and including) max_depth

Returns

Results of the fit

Return type

ModelResult

idpflex.bayes.fit_to_depth(tree, experiment, property_name, max_depth=5)[source]

Fit at each tree depth from the root node up to a maximum depth

Fit experiment against the property stored in the nodes. The fit model is generated by model_at_depth()

Parameters
  • tree (Tree) – Hierarchical tree

  • experiment (ProfileProperty) – A property containing the experimental info.

  • property_name (str) – The name of the simulated property to compare against experiment

  • max_depth (int) – Fit at each depth up to (and including) max_depth

Returns

A list of ModelResult items containing the fit at each level of the tree up to and including max_depth

Return type

list

idpflex.bayes.model_at_depth(tree, depth, property_name)[source]

Generate a fit model at a particular tree depth

Parameters
  • tree (Tree) – Hierarchical tree

  • depth (int) – depth level, starting from the tree’s root (depth=0)

  • property_name (str) – Name of the property to create the model for

Returns

A model composed of a TabulatedFunctionModel for each node plus a ConstantModel accounting for a flat background

Return type

CompositeModel

idpflex.bayes.model_at_node(node, property_name)[source]

Generate fit model as a tabulated function with a scaling parameter, plus a flat background

Parameters
  • node (ClusterNodeX) – One node of the hierarchical Tree

  • property_name (str) – Name of the property to create the model for

Returns

A model composed of a TabulatedFunctionModel and a ConstantModel

Return type

CompositeModel