2. Bumps interface

sasmodels.bumps_model

Wrap sasmodels for direct use by bumps.

Model is a wrapper for the sasmodels kernel which defines a bumps Parameter box for each kernel parameter. Model accepts keyword arguments to set the initial value for each parameter.

Experiment combines the Model function with a data file loaded by the sasview data loader. Experiment takes a cutoff parameter controlling how far the polydispersity integral extends.

class sasmodels.bumps_model.Any(*args, **kwargs)

Bases: object

Special type indicating an unconstrained type.

  • Any is compatible with every type.

  • Any assumed to have all methods.

  • All values assumed to be instances of Any.

Note that all the above statements are true from the point of view of static type checkers. At runtime, Any should not be used with instance checks.

__class__

alias of _AnyMeta

__delattr__(name, /)

Implement delattr(self, name).

__dict__ = mappingproxy({'__module__': 'typing', '__doc__': 'Special type indicating an unconstrained type.\n\n    - Any is compatible with every type.\n    - Any assumed to have all methods.\n    - All values assumed to be instances of Any.\n\n    Note that all the above statements are true from the point of view of\n    static type checkers. At runtime, Any should not be used with instance\n    checks.\n    ', '__new__': <staticmethod(<function Any.__new__>)>, '__dict__': <attribute '__dict__' of 'Any' objects>, '__weakref__': <attribute '__weakref__' of 'Any' objects>, '__annotations__': {}})
__dir__()

Default dir() implementation.

__doc__ = 'Special type indicating an unconstrained type.\n\n    - Any is compatible with every type.\n    - Any assumed to have all methods.\n    - All values assumed to be instances of Any.\n\n    Note that all the above statements are true from the point of view of\n    static type checkers. At runtime, Any should not be used with instance\n    checks.\n    '
__eq__(value, /)

Return self==value.

__format__(format_spec, /)

Default object formatter.

__ge__(value, /)

Return self>=value.

__getattribute__(name, /)

Return getattr(self, name).

__getstate__()

Helper for pickle.

__gt__(value, /)

Return self>value.

__hash__()

Return hash(self).

__init__()
classmethod __init_subclass__()

This method is called when a class is subclassed.

The default implementation does nothing. It may be overridden to extend subclasses.

__le__(value, /)

Return self<=value.

__lt__(value, /)

Return self<value.

__module__ = 'typing'
__ne__(value, /)

Return self!=value.

static __new__(cls, *args, **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).

classmethod __subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

__weakref__

list of weak references to the object

sasmodels.bumps_model.BumpsParameter

alias of Parameter

class sasmodels.bumps_model.Data1D(x: ndarray | None = None, y: ndarray | None = None, dx: ndarray | None = None, dy: ndarray | None = None)

Bases: object

1D data object.

Note that this definition matches the attributes from sasview, with some generic 1D data vectors and some SAS specific definitions. Some refactoring to allow consistent naming conventions between 1D, 2D and SESANS data would be helpful.

Attributes

x, dx: \(q\) vector and gaussian resolution

y, dy: \(I(q)\) vector and measurement uncertainty

mask: values to include in plotting/analysis

dxl: slit widths for slit smeared data, with dx ignored

qmin, qmax: range of \(q\) values in x

filename: label for the data line

_xaxis, _xunit: label and units for the x axis

_yaxis, _yunit: label and units for the y axis

__class__

alias of type

__delattr__(name, /)

Implement delattr(self, name).

__dict__ = mappingproxy({'__module__': 'sasmodels.data', '__doc__': '\n    1D data object.\n\n    Note that this definition matches the attributes from sasview, with\n    some generic 1D data vectors and some SAS specific definitions.  Some\n    refactoring to allow consistent naming conventions between 1D, 2D and\n    SESANS data would be helpful.\n\n    **Attributes**\n\n    *x*, *dx*: $q$ vector and gaussian resolution\n\n    *y*, *dy*: $I(q)$ vector and measurement uncertainty\n\n    *mask*: values to include in plotting/analysis\n\n    *dxl*: slit widths for slit smeared data, with *dx* ignored\n\n    *qmin*, *qmax*: range of $q$ values in *x*\n\n    *filename*: label for the data line\n\n    *_xaxis*, *_xunit*: label and units for the *x* axis\n\n    *_yaxis*, *_yunit*: label and units for the *y* axis\n    ', '__init__': <function Data1D.__init__>, 'xaxis': <function Data1D.xaxis>, 'yaxis': <function Data1D.yaxis>, '__dict__': <attribute '__dict__' of 'Data1D' objects>, '__weakref__': <attribute '__weakref__' of 'Data1D' objects>, '__annotations__': {}})
__dir__()

Default dir() implementation.

__doc__ = '\n    1D data object.\n\n    Note that this definition matches the attributes from sasview, with\n    some generic 1D data vectors and some SAS specific definitions.  Some\n    refactoring to allow consistent naming conventions between 1D, 2D and\n    SESANS data would be helpful.\n\n    **Attributes**\n\n    *x*, *dx*: $q$ vector and gaussian resolution\n\n    *y*, *dy*: $I(q)$ vector and measurement uncertainty\n\n    *mask*: values to include in plotting/analysis\n\n    *dxl*: slit widths for slit smeared data, with *dx* ignored\n\n    *qmin*, *qmax*: range of $q$ values in *x*\n\n    *filename*: label for the data line\n\n    *_xaxis*, *_xunit*: label and units for the *x* axis\n\n    *_yaxis*, *_yunit*: label and units for the *y* axis\n    '
__eq__(value, /)

Return self==value.

__format__(format_spec, /)

Default object formatter.

__ge__(value, /)

Return self>=value.

__getattribute__(name, /)

Return getattr(self, name).

__getstate__()

Helper for pickle.

__gt__(value, /)

Return self>value.

__hash__()

Return hash(self).

__init__(x: ndarray | None = None, y: ndarray | None = None, dx: ndarray | None = None, dy: ndarray | None = None) None
classmethod __init_subclass__()

This method is called when a class is subclassed.

The default implementation does nothing. It may be overridden to extend subclasses.

__le__(value, /)

Return self<=value.

__lt__(value, /)

Return self<value.

__module__ = 'sasmodels.data'
__ne__(value, /)

Return self!=value.

classmethod __new__(*args, **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).

classmethod __subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

__weakref__

list of weak references to the object

xaxis(label: str, unit: str) None

set the x axis label and unit

yaxis(label: str, unit: str) None

set the y axis label and unit

class sasmodels.bumps_model.Data2D(x: ndarray | None = None, y: ndarray | None = None, z: ndarray | None = None, dx: ndarray | None = None, dy: ndarray | None = None, dz: ndarray | None = None)

Bases: object

2D data object.

Note that this definition matches the attributes from sasview. Some refactoring to allow consistent naming conventions between 1D, 2D and SESANS data would be helpful.

Attributes

qx_data, dqx_data: \(q_x\) matrix and gaussian resolution

qy_data, dqy_data: \(q_y\) matrix and gaussian resolution

data, err_data: \(I(q)\) matrix and measurement uncertainty

mask: values to exclude from plotting/analysis

qmin, qmax: range of \(q\) values in x

filename: label for the data line

_xaxis, _xunit: label and units for the x axis

_yaxis, _yunit: label and units for the y axis

_zaxis, _zunit: label and units for the y axis

Q_unit, I_unit: units for Q and intensity

x_bins, y_bins: grid steps in x and y directions

__class__

alias of type

__delattr__(name, /)

Implement delattr(self, name).

__dict__ = mappingproxy({'__module__': 'sasmodels.data', '__doc__': '\n    2D data object.\n\n    Note that this definition matches the attributes from sasview. Some\n    refactoring to allow consistent naming conventions between 1D, 2D and\n    SESANS data would be helpful.\n\n    **Attributes**\n\n    *qx_data*, *dqx_data*: $q_x$ matrix and gaussian resolution\n\n    *qy_data*, *dqy_data*: $q_y$ matrix and gaussian resolution\n\n    *data*, *err_data*: $I(q)$ matrix and measurement uncertainty\n\n    *mask*: values to exclude from plotting/analysis\n\n    *qmin*, *qmax*: range of $q$ values in *x*\n\n    *filename*: label for the data line\n\n    *_xaxis*, *_xunit*: label and units for the *x* axis\n\n    *_yaxis*, *_yunit*: label and units for the *y* axis\n\n    *_zaxis*, *_zunit*: label and units for the *y* axis\n\n    *Q_unit*, *I_unit*: units for Q and intensity\n\n    *x_bins*, *y_bins*: grid steps in *x* and *y* directions\n    ', '__init__': <function Data2D.__init__>, 'xaxis': <function Data2D.xaxis>, 'yaxis': <function Data2D.yaxis>, 'zaxis': <function Data2D.zaxis>, '__dict__': <attribute '__dict__' of 'Data2D' objects>, '__weakref__': <attribute '__weakref__' of 'Data2D' objects>, '__annotations__': {}})
__dir__()

Default dir() implementation.

__doc__ = '\n    2D data object.\n\n    Note that this definition matches the attributes from sasview. Some\n    refactoring to allow consistent naming conventions between 1D, 2D and\n    SESANS data would be helpful.\n\n    **Attributes**\n\n    *qx_data*, *dqx_data*: $q_x$ matrix and gaussian resolution\n\n    *qy_data*, *dqy_data*: $q_y$ matrix and gaussian resolution\n\n    *data*, *err_data*: $I(q)$ matrix and measurement uncertainty\n\n    *mask*: values to exclude from plotting/analysis\n\n    *qmin*, *qmax*: range of $q$ values in *x*\n\n    *filename*: label for the data line\n\n    *_xaxis*, *_xunit*: label and units for the *x* axis\n\n    *_yaxis*, *_yunit*: label and units for the *y* axis\n\n    *_zaxis*, *_zunit*: label and units for the *y* axis\n\n    *Q_unit*, *I_unit*: units for Q and intensity\n\n    *x_bins*, *y_bins*: grid steps in *x* and *y* directions\n    '
__eq__(value, /)

Return self==value.

__format__(format_spec, /)

Default object formatter.

__ge__(value, /)

Return self>=value.

__getattribute__(name, /)

Return getattr(self, name).

__getstate__()

Helper for pickle.

__gt__(value, /)

Return self>value.

__hash__()

Return hash(self).

__init__(x: ndarray | None = None, y: ndarray | None = None, z: ndarray | None = None, dx: ndarray | None = None, dy: ndarray | None = None, dz: ndarray | None = None) None
classmethod __init_subclass__()

This method is called when a class is subclassed.

The default implementation does nothing. It may be overridden to extend subclasses.

__le__(value, /)

Return self<=value.

__lt__(value, /)

Return self<value.

__module__ = 'sasmodels.data'
__ne__(value, /)

Return self!=value.

classmethod __new__(*args, **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).

classmethod __subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

__weakref__

list of weak references to the object

xaxis(label: str, unit: str) None

set the x axis label and unit

yaxis(label: str, unit: str) None

set the y axis label and unit

zaxis(label: str, unit: str) None

set the y axis label and unit

class sasmodels.bumps_model.DataMixin

Bases: object

DataMixin captures the common aspects of evaluating a SAS model for a particular data set, including calculating Iq and evaluating the resolution function. It is used in particular by DirectModel, which evaluates a SAS model parameters as key word arguments to the calculator method, and by bumps_model.Experiment, which wraps the model and data for use with the Bumps fitting engine. It is not currently used by sasview_model.SasviewModel since this will require a number of changes to SasView before we can do it.

_interpret_data initializes the data structures necessary to manage the calculations. This sets attributes in the child class such as data_type and resolution.

_calc_theory evaluates the model at the given control values.

_set_data sets the intensity data in the data object, possibly with random noise added. This is useful for simulating a dataset with the results from _calc_theory.

__class__

alias of type

__delattr__(name, /)

Implement delattr(self, name).

__dict__ = mappingproxy({'__module__': 'sasmodels.direct_model', '__doc__': '\n    DataMixin captures the common aspects of evaluating a SAS model for a\n    particular data set, including calculating Iq and evaluating the\n    resolution function.  It is used in particular by :class:`DirectModel`,\n    which evaluates a SAS model parameters as key word arguments to the\n    calculator method, and by :class:`.bumps_model.Experiment`, which wraps the\n    model and data for use with the Bumps fitting engine.  It is not\n    currently used by :class:`.sasview_model.SasviewModel` since this will\n    require a number of changes to SasView before we can do it.\n\n    *_interpret_data* initializes the data structures necessary\n    to manage the calculations.  This sets attributes in the child class\n    such as *data_type* and *resolution*.\n\n    *_calc_theory* evaluates the model at the given control values.\n\n    *_set_data* sets the intensity data in the data object,\n    possibly with random noise added.  This is useful for simulating a\n    dataset with the results from *_calc_theory*.\n    ', '_interpret_data': <function DataMixin._interpret_data>, '_set_data': <function DataMixin._set_data>, '_calc_theory': <function DataMixin._calc_theory>, '__dict__': <attribute '__dict__' of 'DataMixin' objects>, '__weakref__': <attribute '__weakref__' of 'DataMixin' objects>, '__annotations__': {}})
__dir__()

Default dir() implementation.

__doc__ = '\n    DataMixin captures the common aspects of evaluating a SAS model for a\n    particular data set, including calculating Iq and evaluating the\n    resolution function.  It is used in particular by :class:`DirectModel`,\n    which evaluates a SAS model parameters as key word arguments to the\n    calculator method, and by :class:`.bumps_model.Experiment`, which wraps the\n    model and data for use with the Bumps fitting engine.  It is not\n    currently used by :class:`.sasview_model.SasviewModel` since this will\n    require a number of changes to SasView before we can do it.\n\n    *_interpret_data* initializes the data structures necessary\n    to manage the calculations.  This sets attributes in the child class\n    such as *data_type* and *resolution*.\n\n    *_calc_theory* evaluates the model at the given control values.\n\n    *_set_data* sets the intensity data in the data object,\n    possibly with random noise added.  This is useful for simulating a\n    dataset with the results from *_calc_theory*.\n    '
__eq__(value, /)

Return self==value.

__format__(format_spec, /)

Default object formatter.

__ge__(value, /)

Return self>=value.

__getattribute__(name, /)

Return getattr(self, name).

__getstate__()

Helper for pickle.

__gt__(value, /)

Return self>value.

__hash__()

Return hash(self).

__init__()
classmethod __init_subclass__()

This method is called when a class is subclassed.

The default implementation does nothing. It may be overridden to extend subclasses.

__le__(value, /)

Return self<=value.

__lt__(value, /)

Return self<value.

__module__ = 'sasmodels.direct_model'
__ne__(value, /)

Return self!=value.

classmethod __new__(*args, **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).

classmethod __subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

__weakref__

list of weak references to the object

_calc_theory(pars: ParameterSet, cutoff: float = 0.0) np.ndarray
_interpret_data(data: Data1D | Data2D | SesansData, model: KernelModel) None
_set_data(Iq: np.ndarray, noise: float | None = None) None
class sasmodels.bumps_model.Experiment(data: Data1D | Data2D, model: Model, cutoff: float = 1e-05, name: str | None = None, extra_pars: dict[str, Parameter] | None = None)

Bases: DataMixin

Bumps wrapper for a SAS experiment.

data is a data.Data1D, data.Data2D or data.SesansData object. Use data.empty_data1D() or data.empty_data2D() to define \(q, \Delta q\) calculation points for displaying the SANS curve when there is no measured data.

model is a Model object.

cutoff is the integration cutoff, which avoids computing the the SAS model where the polydispersity weight is low.

The resulting model can be used directly in a Bumps FitProblem call.

__annotations__ = {}
__class__

alias of type

__delattr__(name, /)

Implement delattr(self, name).

__dict__ = mappingproxy({'__module__': 'sasmodels.bumps_model', '__doc__': '\n    Bumps wrapper for a SAS experiment.\n\n    *data* is a :class:`.data.Data1D`, :class:`.data.Data2D` or\n    :class:`.data.SesansData` object.  Use :func:`.data.empty_data1D` or\n    :func:`.data.empty_data2D` to define $q, \\Delta q$ calculation\n    points for displaying the SANS curve when there is no measured data.\n\n    *model* is a :class:`Model` object.\n\n    *cutoff* is the integration cutoff, which avoids computing the\n    the SAS model where the polydispersity weight is low.\n\n    The resulting model can be used directly in a Bumps FitProblem call.\n    ', '_cache': None, '__init__': <function Experiment.__init__>, 'update': <function Experiment.update>, 'numpoints': <function Experiment.numpoints>, 'resolution': <property object>, 'parameters': <function Experiment.parameters>, 'theory': <function Experiment.theory>, 'residuals': <function Experiment.residuals>, 'nllf': <function Experiment.nllf>, 'plot': <function Experiment.plot>, 'simulate_data': <function Experiment.simulate_data>, 'save': <function Experiment.save>, '__getstate__': <function Experiment.__getstate__>, '__setstate__': <function Experiment.__setstate__>, '__annotations__': {'_cache': 'dict[str, np.ndarray]'}})
__dir__()

Default dir() implementation.

__doc__ = '\n    Bumps wrapper for a SAS experiment.\n\n    *data* is a :class:`.data.Data1D`, :class:`.data.Data2D` or\n    :class:`.data.SesansData` object.  Use :func:`.data.empty_data1D` or\n    :func:`.data.empty_data2D` to define $q, \\Delta q$ calculation\n    points for displaying the SANS curve when there is no measured data.\n\n    *model* is a :class:`Model` object.\n\n    *cutoff* is the integration cutoff, which avoids computing the\n    the SAS model where the polydispersity weight is low.\n\n    The resulting model can be used directly in a Bumps FitProblem call.\n    '
__eq__(value, /)

Return self==value.

__format__(format_spec, /)

Default object formatter.

__ge__(value, /)

Return self>=value.

__getattribute__(name, /)

Return getattr(self, name).

__getstate__() dict[str, Any]

Helper for pickle.

__gt__(value, /)

Return self>value.

__hash__()

Return hash(self).

__init__(data: Data1D | Data2D, model: Model, cutoff: float = 1e-05, name: str | None = None, extra_pars: dict[str, Parameter] | None = None) None
classmethod __init_subclass__()

This method is called when a class is subclassed.

The default implementation does nothing. It may be overridden to extend subclasses.

__le__(value, /)

Return self<=value.

__lt__(value, /)

Return self<value.

__module__ = 'sasmodels.bumps_model'
__ne__(value, /)

Return self!=value.

classmethod __new__(*args, **kwargs)
__reduce__()

Helper for pickle.

__reduce_ex__(protocol, /)

Helper for pickle.

__repr__()

Return repr(self).

__setattr__(name, value, /)

Implement setattr(self, name, value).

__setstate__(state: dict[str, Any]) None
__sizeof__()

Size of object in memory, in bytes.

__str__()

Return str(self).

classmethod __subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

__weakref__

list of weak references to the object

_cache: dict[str, ndarray] = None
_calc_theory(pars: ParameterSet, cutoff: float = 0.0) np.ndarray
_interpret_data(data: Data1D | Data2D | SesansData, model: KernelModel) None
_set_data(Iq: np.ndarray, noise: float | None = None) None
nllf() float

Return the negative log likelihood of seeing data given the model parameters, up to a normalizing constant which depends on the data uncertainty.

numpoints() float

Return the number of data points

parameters() dict[str, Parameter]

Return a dictionary of parameters

plot(view: str = None) None

Plot the data and residuals.

residuals() ndarray

Return theory minus data normalized by uncertainty.

property resolution: None | Resolution

resolution.Resolution applied to the data, if any.

save(basename: str) None

Save the model parameters and data into a file.

Not Implemented except for sesans fits.

simulate_data(noise: float = None) None

Generate simulated data. noise is the fractional uncertainty in percent.

theory() ndarray

Return the theory corresponding to the model parameters.

This method uses lazy evaluation, and requires model.update() to be called when the parameters have changed.

update() None

Call when model parameters have changed and theory needs to be recalculated.

class sasmodels.bumps_model.KernelModel

Bases: object

Model definition for the compute engine.

__class__

alias of type

__delattr__(name, /)

Implement delattr(self, name).

__dict__ = mappingproxy({'__module__': 'sasmodels.kernel', '__doc__': '\n    Model definition for the compute engine.\n    ', 'info': None, 'dtype': None, 'make_kernel': <function KernelModel.make_kernel>, 'release': <function KernelModel.release>, '__dict__': <attribute '__dict__' of 'KernelModel' objects>, '__weakref__': <attribute '__weakref__' of 'KernelModel' objects>, '__annotations__': {'info': 'ModelInfo', 'dtype': 'np.dtype'}})
__dir__()

Default dir() implementation.

__doc__ = '\n    Model definition for the compute engine.\n    '
__eq__(value, /)

Return self==value.

__format__(format_spec, /)

Default object formatter.

__ge__(value, /)

Return self>=value.

__getattribute__(name, /)

Return getattr(self, name).

__getstate__()

Helper for pickle.

__gt__(value, /)

Return self>value.

__hash__()

Return hash(self).

__init__()
classmethod __init_subclass__()

This method is called when a class is subclassed.

The default implementation does nothing. It may be overridden to extend subclasses.

__le__(value, /)

Return self<=value.

__lt__(value, /)

Return self<value.

__module__ = 'sasmodels.kernel'
__ne__(value, /)

Return self!=value.

classmethod __new__(*args, **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).

classmethod __subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

__weakref__

list of weak references to the object

dtype: np.dtype = None
info: ModelInfo = None
make_kernel(q_vectors: List[np.ndarray]) Kernel

Instantiate a kernel for evaluating the model at q_vectors.

release() None

Free resources associated with the kernel.

class sasmodels.bumps_model.Model(model: KernelModel, **kwargs: dict[str, float | Parameter])

Bases: object

Bumps wrapper for a SAS model.

model is a runnable module as returned from core.load_model().

cutoff is the polydispersity weight cutoff.

Any additional key=value pairs are model dependent parameters.

__class__

alias of type

__delattr__(name, /)

Implement delattr(self, name).

__dict__ = mappingproxy({'__module__': 'sasmodels.bumps_model', '__doc__': '\n    Bumps wrapper for a SAS model.\n\n    *model* is a runnable module as returned from :func:`.core.load_model`.\n\n    *cutoff* is the polydispersity weight cutoff.\n\n    Any additional *key=value* pairs are model dependent parameters.\n    ', '__init__': <function Model.__init__>, 'parameters': <function Model.parameters>, 'state': <function Model.state>, '__dict__': <attribute '__dict__' of 'Model' objects>, '__weakref__': <attribute '__weakref__' of 'Model' objects>, '__annotations__': {}})
__dir__()

Default dir() implementation.

__doc__ = '\n    Bumps wrapper for a SAS model.\n\n    *model* is a runnable module as returned from :func:`.core.load_model`.\n\n    *cutoff* is the polydispersity weight cutoff.\n\n    Any additional *key=value* pairs are model dependent parameters.\n    '
__eq__(value, /)

Return self==value.

__format__(format_spec, /)

Default object formatter.

__ge__(value, /)

Return self>=value.

__getattribute__(name, /)

Return getattr(self, name).

__getstate__()

Helper for pickle.

__gt__(value, /)

Return self>value.

__hash__()

Return hash(self).

__init__(model: KernelModel, **kwargs: dict[str, float | Parameter]) None
classmethod __init_subclass__()

This method is called when a class is subclassed.

The default implementation does nothing. It may be overridden to extend subclasses.

__le__(value, /)

Return self<=value.

__lt__(value, /)

Return self<value.

__module__ = 'sasmodels.bumps_model'
__ne__(value, /)

Return self!=value.

classmethod __new__(*args, **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).

classmethod __subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

__weakref__

list of weak references to the object

parameters() dict[str, Parameter]

Return a dictionary of parameters objects for the parameters, excluding polydispersity distribution type.

state() dict[str, Parameter | str]

Return a dictionary of current values for all the parameters, including polydispersity distribution type.

class sasmodels.bumps_model.ModelInfo

Bases: object

Interpret the model definition file, categorizing the parameters.

The module can be loaded with a normal python import statement if you know which module you need, or with __import__(‘sasmodels.model.’+name) if the name is in a string.

The structure should be mostly static, other than the delayed definition of Iq, Iqac and Iqabc if they need to be defined.

Imagnetic: None | str | Callable[[...], ndarray] = None

Returns I(qx, qy, a, b, …). The interface follows Iq.

Iq: None | str | Callable[[...], ndarray] = None

Returns I(q, a, b, …) for parameters a, b, etc. defined by the parameter table. Iq can be defined as a python function, or as a C function. If it is defined in C, then set Iq to the body of the C function, including the return statement. This function takes values for q and each of the parameters as separate double values (which may be converted to float or long double by sasmodels). All source code files listed in source will be loaded before the Iq function is defined. If Iq is not present, then sources should define static double Iq(double q, double a, double b, …) which will return I(q, a, b, …). Multiplicity parameters are sent as pointers to doubles. Constants in floating point expressions should include the decimal point. See generate for more details. If have_Fq is True, then Iq should return an interleaved array of \([\sum F(q_1), \sum F^2(q_1), \ldots, \sum F(q_n), \sum F^2(q_n)]\).

Iqabc: None | str | Callable[[...], ndarray] = None

Returns I(qa, qb, qc, a, b, …). The interface follows Iq.

Iqac: None | str | Callable[[...], ndarray] = None

Returns I(qab, qc, a, b, …). The interface follows Iq.

Iqxy: None | str | Callable[[...], ndarray] = None

Returns I(qx, qy, a, b, …). The interface follows Iq.

__class__

alias of type

__delattr__(name, /)

Implement delattr(self, name).

__dict__ = mappingproxy({'__module__': 'sasmodels.modelinfo', '__doc__': "\n    Interpret the model definition file, categorizing the parameters.\n\n    The module can be loaded with a normal python import statement if you\n    know which module you need, or with __import__('sasmodels.model.'+name)\n    if the name is in a string.\n\n    The structure should be mostly static, other than the delayed definition\n    of *Iq*, *Iqac* and *Iqabc* if they need to be defined.\n    ", 'filename': None, 'basefile': None, 'id': None, 'name': None, 'title': None, 'description': None, 'parameters': None, 'base': None, 'translation': None, 'composition': None, 'hidden': None, 'docs': None, 'category': None, 'single': None, 'opencl': None, 'structure_factor': None, 'have_Fq': False, 'radius_effective_modes': None, 'source': None, 'c_code': None, 'valid': None, 'form_volume': None, 'shell_volume': None, 'radius_effective': None, 'Iq': None, 'Iqxy': None, 'Iqac': None, 'Iqabc': None, 'Imagnetic': None, 'profile': None, 'profile_axes': None, 'sesans': None, 'random': None, 'lineno': None, 'tests': None, '__init__': <function ModelInfo.__init__>, 'get_hidden_parameters': <function ModelInfo.get_hidden_parameters>, '__dict__': <attribute '__dict__' of 'ModelInfo' objects>, '__weakref__': <attribute '__weakref__' of 'ModelInfo' objects>, '__annotations__': {'filename': 'Optional[str]', 'basefile': 'Optional[str]', 'id': 'str', 'name': 'str', 'title': 'str', 'description': 'str', 'parameters': 'ParameterTable', 'base': 'ParameterTable', 'translation': 'Optional[str]', 'composition': 'Optional[tuple[str, list[ModelInfo]]]', 'hidden': 'Optional[Callable[[int], set[str]]]', 'docs': 'str', 'category': 'Optional[str]', 'single': 'bool', 'opencl': 'bool', 'structure_factor': 'bool', 'radius_effective_modes': 'list[str]', 'source': 'list[str]', 'c_code': 'Optional[str]', 'valid': 'str', 'form_volume': 'Union[None, str, Callable[[np.ndarray], float]]', 'shell_volume': 'Union[None, str, Callable[[np.ndarray], float]]', 'radius_effective': 'Union[None, Callable[[int, np.ndarray], float]]', 'Iq': 'Union[None, str, Callable[[...], np.ndarray]]', 'Iqxy': 'Union[None, str, Callable[[...], np.ndarray]]', 'Iqac': 'Union[None, str, Callable[[...], np.ndarray]]', 'Iqabc': 'Union[None, str, Callable[[...], np.ndarray]]', 'Imagnetic': 'Union[None, str, Callable[[...], np.ndarray]]', 'profile': 'Optional[Callable[[np.ndarray], None]]', 'profile_axes': 'tuple[str, str]', 'sesans': 'Optional[Callable[[np.ndarray], np.ndarray]]', 'random': 'Optional[Callable[[], dict[str, float]]]', 'lineno': 'dict[str, int]', 'tests': 'list[TestCondition]'}})
__dir__()

Default dir() implementation.

__doc__ = "\n    Interpret the model definition file, categorizing the parameters.\n\n    The module can be loaded with a normal python import statement if you\n    know which module you need, or with __import__('sasmodels.model.'+name)\n    if the name is in a string.\n\n    The structure should be mostly static, other than the delayed definition\n    of *Iq*, *Iqac* and *Iqabc* if they need to be defined.\n    "
__eq__(value, /)

Return self==value.

__format__(format_spec, /)

Default object formatter.

__ge__(value, /)

Return self>=value.

__getattribute__(name, /)

Return getattr(self, name).

__getstate__()

Helper for pickle.

__gt__(value, /)

Return self>value.

__hash__()

Return hash(self).

__init__() None
classmethod __init_subclass__()

This method is called when a class is subclassed.

The default implementation does nothing. It may be overridden to extend subclasses.

__le__(value, /)

Return self<=value.

__lt__(value, /)

Return self<value.

__module__ = 'sasmodels.modelinfo'
__ne__(value, /)

Return self!=value.

classmethod __new__(*args, **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).

classmethod __subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

__weakref__

list of weak references to the object

base: ParameterTable = None

For reparameterized systems, base is the base parameter table. For normal systems it is simply a copy of parameters.

basefile: str | None = None

Base file is usually filename, but not when a model has been reparameterized, in which case it is the file containing the original model definition. This is needed to signal an additional dependency for the model time stamp, and so that the compiler reports correct file for syntax errors.

c_code: str | None = None

inline source code, added after all elements of source

category: str | None = None

Location of the model description in the documentation. This takes the form of “section” or “section:subsection”. So for example, porod uses category=”shape-independent” so it is in the Shape-Independent Functions section whereas capped_cylinder uses: category=”shape:cylinder”, which puts it in the Cylinder Functions section.

composition: tuple[str, list[ModelInfo]] | None = None

Composition is None if this is an independent model, or it is a tuple with comoposition type (‘product’ or ‘misture’) and a list of ModelInfo blocks for the composed objects. This allows us to rebuild a complete mixture or product model from the info block. composition is not given in the model definition file, but instead arises when the model is constructed using names such as sphere*hardsphere or cylinder+sphere.

description: str = None

Long description of the model.

docs: str = None

Doc string from the top of the model file. This should be formatted using ReStructuredText format, with latex markup in “.. math” environments, or in dollar signs. This will be automatically extracted to a .rst file by generate.make_doc(), then converted to HTML or PDF by Sphinx.

filename: str | None = None

Full path to the file defining the kernel, if any.

form_volume: None | str | Callable[[ndarray], float] = None

Returns the form volume for python-based models. Form volume is needed for volume normalization in the polydispersity integral. If no parameters are volume parameters, then form volume is not needed. For C-based models, (with source defined, or with Iq defined using a string containing C code), form_volume must also be C code, either defined as a string, or in the sources.

get_hidden_parameters(control)

Returns the set of hidden parameters for the model. control is the value of the control parameter. Note that multiplicity models have an implicit control parameter, which is the parameter that controls the multiplicity.

have_Fq = False

True if the model defines an Fq function with signature void Fq(double q, double *F1, double *F2, ...)

hidden: Callable[[int], set[str]] | None = None

Different variants require different parameters. In order to show just the parameters needed for the variant selected, you should provide a function hidden(control) -> set([‘a’, ‘b’, …]) indicating which parameters need to be hidden. For multiplicity models, you need to use the complete name of the parameter, including its number. So for example, if variant “a” uses only sld1 and sld2, then sld3, sld4 and sld5 of multiplicity parameter sld[5] should be in the hidden set.

id: str = None

Id of the kernel used to load it from the filesystem.

lineno: dict[str, int] = None

Line numbers for symbols defining C code

name: str = None

Display name of the model, which defaults to the model id but with capitalization of the parts so for example core_shell defaults to “Core Shell”.

opencl: bool = None

True if the model can be run as an opencl model. If for some reason the model cannot be run in opencl (e.g., because the model passes functions by reference), then set this to false.

parameters: ParameterTable = None

Model parameter table. Parameters are defined using a list of parameter definitions, each of which is contains parameter name, units, default value, limits, type and description. See Parameter for details on the individual parameters. The parameters are gathered into a ParameterTable, which provides various views into the parameter list.

profile: Callable[[ndarray], None] | None = None

Returns a model profile curve x, y. If profile is defined, this curve will appear in response to the Show button in SasView. Use profile_axes to set the axis labels. Note that y values will be scaled by 1e6 before plotting.

profile_axes: tuple[str, str] = None

Axis labels for the profile plot. The default is [‘x’, ‘y’]. Only the x component is used for now.

radius_effective: None | Callable[[int, ndarray], float] = None

Computes the effective radius of the shape given the volume parameters. Only needed for models defined in python that can be used for monodisperse approximation for non-dilute solutions, P@S. The first argument is the integer effective radius mode, with default 0.

radius_effective_modes: list[str] = None

List of options for computing the effective radius of the shape, or None if the model is not usable as a form factor model.

random: Callable[[], dict[str, float]] | None = None

Returns a random parameter set for the model

sesans: Callable[[ndarray], ndarray] | None = None

Returns sesans(z, a, b, …) for models which can directly compute the SESANS correlation function. Note: not currently implemented.

shell_volume: None | str | Callable[[ndarray], float] = None

Returns the shell volume for python-based models. Form volume and shell volume are needed for volume normalization in the polydispersity integral and structure interactions for hollow shapes. If no parameters are volume parameters, then shell volume is not needed. For C-based models, (with source defined, or with Iq defined using a string containing C code), shell_volume must also be C code, either defined as a string, or in the sources.

single: bool = None

True if the model can be computed accurately with single precision. This is True by default, but models such as bcc_paracrystal set it to False because they require double precision calculations.

source: list[str] = None

List of C source files used to define the model. The source files should define the Iq function, and possibly Iqac or Iqabc if the model defines orientation parameters. Files containing the most basic functions must appear first in the list, followed by the files that use those functions.

structure_factor: bool = None

True if the model is a structure factor used to model the interaction between form factor models. This will default to False if it is not provided in the file.

tests: list[tuple[Mapping[str, float | list[float]], str | float | list[float] | tuple[float, float] | list[tuple[float, float]], float | list[float]]] = None

The set of tests that must pass. The format of the tests is described in model_test.

title: str = None

Short description of the model.

translation: str | None = None

Parameter translation code to convert from parameters table from caller to the base table used to evaluate the model.

valid: str = None

Expression which evaluates to True if the input parameters are valid and the model can be computed, or False otherwise. Invalid parameter sets will not be included in the weighted \(I(Q)\) calculation or its volume normalization. Use C syntax for the expressions, with || for or && for and and ! for not. Any non-magnetic parameter can be used.

class sasmodels.bumps_model.Reference(obj, attr, **kw)

Bases: Parameter

Create an adaptor so that a model attribute can be treated as if it were a parameter. This allows only direct access, wherein the storage for the parameter value is provided by the underlying model.

Indirect access, wherein the storage is provided by the parameter, cannot be supported since the parameter has no way to detect that the model is asking for the value of the attribute. This means that model attributes cannot be assigned to parameter expressions without some trigger to update the values of the attributes in the model.

NOTE: this class can not be serialized with a dataclass schema TODO: can sasmodels just use Parameter directly?

__abs__()
__add__(other)
__annotations__ = {}
__bool__()
__bumps_schema__ = {'exclude': None, 'include': None}
__call__()

Call self as a function.

__class__

alias of type

__copy__()

copy will only be called when a new instance is desired, with a different id

__dataclass_fields__ = {'_fixed': Field(name='_fixed',type=<class 'bool'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'bounds': Field(name='bounds',type=typing.Optional[typing.Tuple[typing.Union[float, typing.Literal['-inf']], typing.Union[float, typing.Literal['inf']]]],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'discrete': Field(name='discrete',type=<class 'bool'>,default=False,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'distribution': Field(name='distribution',type=typing.Union[bumps.parameter.Uniform, bumps.parameter.Normal],default=<dataclasses._MISSING_TYPE object>,default_factory=<class 'bumps.parameter.Uniform'>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'fixed': Field(name='fixed',type=<class 'bool'>,default=<property object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'id': Field(name='id',type=<class 'str'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'format': 'uuid'}),kw_only=False,_field_type=_FIELD), 'limits': Field(name='limits',type=typing.Tuple[typing.Union[float, typing.Literal['-inf']], typing.Union[float, typing.Literal['inf']]],default=(-inf, inf),default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'name': Field(name='name',type=typing.Optional[str],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=False,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'slot': Field(name='slot',type=typing.Union[ForwardRef('Variable'), ForwardRef('Expression'), ForwardRef('Parameter'), ForwardRef('Calculation'), float],default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'tags': Field(name='tags',type=typing.List[str],default=<dataclasses._MISSING_TYPE object>,default_factory=<class 'list'>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD)}
__dataclass_params__ = _DataclassParams(init=False,repr=True,eq=True,order=False,unsafe_hash=False,frozen=False)
__delattr__(name, /)

Implement delattr(self, name).

__dict__ = mappingproxy({'__module__': 'bumps.parameter', '__doc__': '\n    Create an adaptor so that a model attribute can be treated as if it\n    were a parameter.  This allows only direct access, wherein the\n    storage for the parameter value is provided by the underlying model.\n\n    Indirect access, wherein the storage is provided by the parameter, cannot\n    be supported since the parameter has no way to detect that the model\n    is asking for the value of the attribute.  This means that model\n    attributes cannot be assigned to parameter expressions without some\n    trigger to update the values of the attributes in the model.\n\n    NOTE: this class can not be serialized with a dataclass schema\n    TODO: can sasmodels just use Parameter directly?\n    ', '__init__': <function Reference.__init__>, 'value': <property object>, '__annotations__': {'id': 'str', 'name': 'Optional[str]', 'fixed': 'bool', 'slot': "Union['Variable', ValueType]", 'limits': "Tuple[Union[float, Literal['-inf']], Union[float, Literal['inf']]]", 'bounds': "Optional[Tuple[Union[float, Literal['-inf']], Union[float, Literal['inf']]]]", 'distribution': 'DistributionType', 'discrete': 'bool', 'tags': 'List[str]', '_fixed': 'bool', 'fittable': 'bool', 'value': 'float', 'prior': 'Optional[BoundsType]'}})
__dir__()

Default dir() implementation.

__doc__ = '\n    Create an adaptor so that a model attribute can be treated as if it\n    were a parameter.  This allows only direct access, wherein the\n    storage for the parameter value is provided by the underlying model.\n\n    Indirect access, wherein the storage is provided by the parameter, cannot\n    be supported since the parameter has no way to detect that the model\n    is asking for the value of the attribute.  This means that model\n    attributes cannot be assigned to parameter expressions without some\n    trigger to update the values of the attributes in the model.\n\n    NOTE: this class can not be serialized with a dataclass schema\n    TODO: can sasmodels just use Parameter directly?\n    '
__eq__(other)

Return self==value.

__float__()
__floordiv__(other)
__format__(format_spec, /)

Default object formatter.

__ge__(other)

Return self>=value.

__getattribute__(name, /)

Return getattr(self, name).

__getstate__()

Helper for pickle.

__gt__(other)

Return self>value.

__hash__ = None
__init__(obj, attr, **kw)
classmethod __init_subclass__()

This method is called when a class is subclassed.

The default implementation does nothing. It may be overridden to extend subclasses.

__int__()
__le__(other)

Return self<=value.

__lt__(other)

Return self<value.

__match_args__ = ('id', 'fixed', 'slot', 'limits', 'bounds', 'distribution', 'discrete', 'tags', '_fixed')
__module__ = 'bumps.parameter'
__mul__(other)
__ne__(value, /)

Return self!=value.

__neg__()
classmethod __new__(*args, **kwargs)
__pos__()
__pow__(other)
__radd__(other)
__reduce__()

Helper for pickle.

__reduce_ex__(protocol, /)

Helper for pickle.

__repr__()

Return repr(self).

__rfloordiv__(other)
__rmul__(other)
__rpow__(other)
__rsub__(other)
__rtruediv__(other)
__setattr__(name, value, /)

Implement setattr(self, name, value).

__sizeof__()

Size of object in memory, in bytes.

__str__()

Return str(self).

__sub__(other)
classmethod __subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

__truediv__(other)
__weakref__

list of weak references to the object

_fixed: bool
add_prior(distribution: Uniform | Normal | None = None, bounds: Unbounded | Bounded | BoundedAbove | BoundedBelow | BoundedNormal | SoftBounded | Normal | None = None, limits: Tuple[float, float] | None = None)
add_tag(tag: str)
arccos()
arccosh()
arcsin()
arcsinh()
arctan()
arctan2()
arctanh()
bounds: Tuple[float | Literal['-inf'], float | Literal['inf']] | None = None
static calculation(obj: Parameter | None, name: str, function: Callable[[], float]) Parameter

Create a parameter to hold a value derived from the model. This can be used in parameter expressions, for example to constrain total thickness or to set the value in the next segment equal to the value at the end of a freeform segment.

Note that this function should be called in the __init__ or __post_init__ methods of the class where the parameter is defined, in order to bind the Calculation function to the newly created (or deserialized) Parameter before it is used.

If obj is a Parameter, use it - otherwise create a new Parameter obj with the given name.

Then create a Calculation object and attach the evaluator function to the Calculation, and put the Calculation in obj.slot

Returns obj: Parameter

ceil()
clip_set(value)

Set a new value for the parameter, clipping it to the bounds.

cos()
cosh()
classmethod default(value: float | Tuple[float, float] | Expression | Parameter | Calculation, **kw) Parameter

Create a new parameter with the value and kw attributes. If value is already a parameter or expression, set it to that value.

degrees()
dev(std, mean=None, limits=None, sigma=None, mu=None)

Allow the parameter to vary according to a normal distribution, with deviations from the mean added to the overall cost function for the model.

If mean is None, then it defaults to the current parameter value.

If limits are provide, then use a truncated normal distribution.

Note: sigma and mu have been replaced by std and mean, but are left in for backward compatibility.

discrete: bool = False
distribution: Uniform | Normal
equals(expression: Expression | Parameter | Calculation | float)

Set a parameter equal to another parameter or expression.

Use unlink() to convert from an expression to a variable.

exp()
expm1()
feasible()

Value is within the limits defined by the model

property fittable

bool(x) -> bool

Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.

property fixed

bool(x) -> bool

Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.

floor()
format()

Format the parameter, value and range as a string.

has_prior()
id: str
limits: Tuple[float | Literal['-inf'], float | Literal['inf']] = (-inf, inf)
log()
log10()
log1p()
max()
min()
name: str | None = None
nllf() float

Return -log(P) for the current parameter value.

parameters()
pm(plus, minus=None, limits=None)

Allow the parameter to vary as value +/- delta.

pm(delta) -> [value-delta, value+delta]

pm(plus, minus) -> [value+minus, value+plus]

In the plus/minus form, one of the numbers should be plus and the other minus, but it doesn’t matter which.

If limits are provided, bound the end points of the range to lie within the limits.

The resulting range is converted to “nice” numbers.

pmp(plus, minus=None, limits=None)

Allow the parameter to vary as value +/- percent.

pmp(percent) -> [value*(1-percent/100), value*(1+percent/100)]

pmp(plus, minus) -> [value*(1+minus/100), value*(1+plus/100)]

In the plus/minus form, one of the numbers should be plus and the other minus, but it doesn’t matter which.

If limits are provided, bound the end points of the range to lie within the limits.

The resulting range is converted to “nice” numbers.

prior: Unbounded | Bounded | BoundedAbove | BoundedBelow | BoundedNormal | SoftBounded | Normal | None
radians()
randomize(rng=None)

Set a random value for the parameter.

range(low, high)

Allow the parameter to vary within the given range.

remove_tag(tag: str | None = None)
reset_prior()
residual() float

Return the z score equivalent for the current parameter value.

That is, the given the value of the parameter in the underlying distribution, find the equivalent value in the standard normal. For a gaussian, this is the z score, in which you subtract the mean and divide by the standard deviation to get the number of sigmas away from the mean. For other distributions, you need to compute the cdf of value in the parameter distribution and invert it using the ppf from the standard normal distribution.

rint()
round()
set(value)

Set a new value for the parameter, ignoring the bounds.

sin()
sinh()
slot: Variable | Parameter | Expression | Calculation | float
soft_range(low, high, std)

Allow the parameter to vary within the given range, or with Gaussian probability, stray from the range.

sqrt()
tags: List[str]
tan()
tanh()
trunc()
valid()

Return true if the parameter is within the valid range.

property value
class sasmodels.bumps_model.Resolution

Bases: object

Abstract base class defining a 1D resolution function.

q is the set of q values at which the data is measured.

q_calc is the set of q values at which the theory needs to be evaluated. This may extend and interpolate the q values.

apply is the method to call with I(q_calc) to compute the resolution smeared theory I(q).

__class__

alias of type

__delattr__(name, /)

Implement delattr(self, name).

__dict__ = mappingproxy({'__module__': 'sasmodels.resolution', '__doc__': '\n    Abstract base class defining a 1D resolution function.\n\n    *q* is the set of q values at which the data is measured.\n\n    *q_calc* is the set of q values at which the theory needs to be evaluated.\n    This may extend and interpolate the q values.\n\n    *apply* is the method to call with I(q_calc) to compute the resolution\n    smeared theory I(q).\n\n    ', 'q': None, 'q_calc': None, 'apply': <function Resolution.apply>, '__dict__': <attribute '__dict__' of 'Resolution' objects>, '__weakref__': <attribute '__weakref__' of 'Resolution' objects>, '__annotations__': {'q': 'np.ndarray', 'q_calc': 'np.ndarray'}})
__dir__()

Default dir() implementation.

__doc__ = '\n    Abstract base class defining a 1D resolution function.\n\n    *q* is the set of q values at which the data is measured.\n\n    *q_calc* is the set of q values at which the theory needs to be evaluated.\n    This may extend and interpolate the q values.\n\n    *apply* is the method to call with I(q_calc) to compute the resolution\n    smeared theory I(q).\n\n    '
__eq__(value, /)

Return self==value.

__format__(format_spec, /)

Default object formatter.

__ge__(value, /)

Return self>=value.

__getattribute__(name, /)

Return getattr(self, name).

__getstate__()

Helper for pickle.

__gt__(value, /)

Return self>value.

__hash__()

Return hash(self).

__init__()
classmethod __init_subclass__()

This method is called when a class is subclassed.

The default implementation does nothing. It may be overridden to extend subclasses.

__le__(value, /)

Return self<=value.

__lt__(value, /)

Return self<value.

__module__ = 'sasmodels.resolution'
__ne__(value, /)

Return self!=value.

classmethod __new__(*args, **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).

classmethod __subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

__weakref__

list of weak references to the object

apply(theory)

Smear theory by the resolution function, returning Iq.

q: ndarray = None
q_calc: ndarray = None
sasmodels.bumps_model.create_parameters(model_info: ModelInfo, **kwargs: float | str | Parameter) tuple[dict[str, Parameter], dict[str, str]]

Generate Bumps parameters from the model info.

model_info is returned from generate.model_info() on the model definition module.

Any additional key=value pairs are initial values for the parameters to the models. Uninitialized parameters will use the model default value. The value can be a float, a bumps parameter, or in the case of the distribution type parameter, a string.

Returns a dictionary of {name: BumpsParameter} containing the bumps parameters for each model parameter, and a dictionary of {name: str} containing the polydispersity distribution types.

sasmodels.bumps_model.plot_theory(data: Data1D | Data2D | SesansData, theory: ndarray | None, resid: ndarray | None = None, view: str | None = None, use_data: bool = True, limits: tuple[float, float] | None = None, Iq_calc: ndarray | None = None) None

Plot theory calculation.

data is needed to define the graph properties such as labels and units, and to define the data mask.

theory is a matrix of the same shape as the data.

view is log, linear or normed

use_data is True if the data should be plotted as well as the theory.

limits sets the intensity limits on the plot; if None then the limits are inferred from the data. If (-inf, inf) then use auto limits.

Iq_calc is the raw theory values without resolution smearing