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.BumpsParameter¶
Bases:
objectSee parameter.Parameter in the bumps documentation.
- class sasmodels.bumps_model.Experiment(data: Union[sasmodels.data.Data1D, sasmodels.data.Data2D], model: sasmodels.bumps_model.Model, cutoff: float = 1e-05, name: Optional[str] = None, extra_pars: Optional[Dict[str, sasmodels.bumps_model.BumpsParameter]] = None)¶
Bases:
sasmodels.direct_model.DataMixinBumps wrapper for a SAS experiment.
data is a
data.Data1D,data.Data2Dordata.SesansDataobject. 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
Modelobject.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, sasmodels.bumps_model.BumpsParameter]¶
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¶
resolution.Resolutionapplied to the data, if any.
- class sasmodels.bumps_model.Model(model: sasmodels.kernel.KernelModel, **kwargs: Dict[str, Union[float, sasmodels.bumps_model.BumpsParameter]])¶
Bases:
objectBumps 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, sasmodels.bumps_model.BumpsParameter]¶
Return a dictionary of parameters objects for the parameters, excluding polydispersity distribution type.
- state() Dict[str, Union[sasmodels.bumps_model.BumpsParameter, str]]¶
Return a dictionary of current values for all the parameters, including polydispersity distribution type.