3.13. Sasview interface¶
3.13.1. sasmodels.sasview_model¶
Sasview model constructor.
Given a module defining an OpenCL kernel such as sasmodels.models.cylinder, create a sasview model class to run that kernel as follows:
from sasmodels.sasview_model import make_class
from sasmodels.models import cylinder
CylinderModel = make_class(cylinder, dtype='single')
The model parameters for sasmodels are different from those in sasview. When reloading previously saved models, the parameters should be converted using sasmodels.convert.convert().
- class sasmodels.sasview_model.SasviewModel(model)¶
Bases: object
Sasview wrapper for opencl/ctypes model.
Initialization
- calculate_ER()¶
Calculate the effective radius for P(q)*S(q)
Returns: the value of the effective radius
- calculate_Iq(*args)¶
Calculate Iq for one set of q with the current parameters.
If the model is 1D, use q. If 2D, use qx, qy.
This should NOT be used for fitting since it copies the q vectors to the card for each evaluation.
- calculate_VR()¶
Calculate the volf ratio for P(q)*S(q)
Returns: the value of the volf ratio
- clone()¶
Return a identical copy of self
- evalDistribution(qdist)¶
Evaluate a distribution of q-values.
For 1D, a numpy array is expected as input:
evalDistribution(q)
where q is a numpy array.
For 2D, a list of numpy arrays are expected: [qx,qy], with 1D arrays:
qx = [ qx[0], qx[1], qx[2], ....]
and:
qy = [ qy[0], qy[1], qy[2], ....]
Then get
q = numpy.sqrt(qx^2+qy^2)
that is a qr in 1D array:
q = [q[0], q[1], q[2], ....]
Parameters: qdist – ndarray of scalar q-values or list [qx,qy] where qx,qy are 1D ndarrays
- getDispParamList()¶
Return a list of all available parameters for the model
- getParam(name)¶
Set the value of a model parameter
Parameters: name – name of the parameter
- getParamList()¶
Return a list of all available parameters for the model
- getProfile()¶
Get SLD profile
- : return: (z, beta) where z is a list of depth of the transition points
- beta is a list of the corresponding SLD values
- is_fittable(par_name)¶
Check if a given parameter is fittable or not
Parameters: par_name – the parameter name to check
- run(x=0.0)¶
Evaluate the model
Parameters: x – input q, or [q,phi] Returns: scattering function P(q) DEPRECATED: use calculate_Iq instead
- runXY(x=0.0)¶
Evaluate the model in cartesian coordinates
Parameters: x – input q, or [qx, qy] Returns: scattering function P(q) DEPRECATED: use calculate_Iq instead
- setParam(name, value)¶
Set the value of a model parameter
Parameters: - name – name of the parameter
- value – value of the parameter
- set_dispersion(parameter, dispersion)¶
Set the dispersion object for a model parameter
Parameters: - parameter – name of the parameter [string]
- dispersion – dispersion object of type Dispersion
- sasmodels.sasview_model.make_class(model_definition, dtype='single', namestyle='name')¶
Load the sasview model defined in kernel_module.
Returns a class that can be used directly as a sasview model.
Defaults to using the new name for a model. Setting namestyle=’oldname’ will produce a class with a name compatible with SasView.