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.
Experiment
¶ Bases:
sasmodels.direct_model.DataMixin
Bumps wrapper for a SAS experiment.
data is a
data.Data1D
,data.Data2D
ordata.Sesans
object. Usedata.empty_data1D()
ordata.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.
-
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: Optional[str] = None) → None¶ Plot the data and residuals.
-
residuals
() → numpy.ndarray¶ Return theory minus data normalized by uncertainty.
-
save
(basename: str) → None¶ Save the model parameters and data into a file.
Not Implemented except for sesans fits.
-
simulate_data
(noise: Optional[float] = None) → None¶ Generate simulated data.
-
theory
() → numpy.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.
-
property
resolution
¶ sasmodels.Resolution
applied to the data, if any.
-
-
class
sasmodels.bumps_model.
Model
(model: KernelModel, **kwargs: Dict[str, Union[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.
-
parameters
() → Dict[str, Parameter]¶ Return a dictionary of parameters objects for the parameters, excluding polydispersity distribution type.
-
state
() → Dict[str, Union[Parameter, str]]¶ Return a dictionary of current values for all the parameters, including polydispersity distribution type.
-