# Home

## 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: `object`

  See parameter.Parameter in the bumps documentation.

class sasmodels.bumps_model.Experiment(data: Data1D | Data2D, model: Model, cutoff: float = 1e-05, name: str | None = None, extra_pars: dict[str, BumpsParameter] | 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.

  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, BumpsParameter]

    Return a dictionary of parameters

  plot(view=None)
  plotly(view=None)
  residuals() → 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: 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.

  property resolution: None | Resolution

    `resolution.Resolution` applied to the data, if any.

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

  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, BumpsParameter]

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

  state() → dict[str, BumpsParameter | str]

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