source: sasview/src/sans/models/DisperseModel.py @ 79d5b6c

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 79d5b6c was 5777106, checked in by Mathieu Doucet <doucetm@…>, 11 years ago

Moving things around. Will definitely not build.

  • Property mode set to 100644
File size: 2.7 KB
RevLine 
[ae3ce4e]1"""
[279e371]2    Wrapper for the Disperser class extension
[ae3ce4e]3"""
4from sans.models.BaseComponent import BaseComponent
5from sans_extension.c_models import Disperser
6   
7class DisperseModel(Disperser, BaseComponent):
8    """
[279e371]9    Wrapper class for the Disperser extension
10    Python class that takes a model and averages its output
11    for a distribution of its parameters.
12     
13    The parameters to be varied are specified at instantiation time.
14    The distributions are Gaussian, with std deviations specified for
15    each parameter at instantiation time.
16   
17    Example: ::
18   
19        cyl = CylinderModel()
20        disp = DisperseModel(cyl, ['cyl_phi'], [0.3])
21        disp.run([0.01, 1.57])
22       
[ae3ce4e]23    """
24       
25    def __init__(self, model, paramList, sigmaList):
[79ac6f8]26        """
27        Initialization
28       
[279e371]29        :param model: Model to disperse [BaseComponent]
30        :param paramList: list of parameters to disperse [List of strings]
31        :param sigmaList: list of std deviations for Gaussian dispersion
32                    [List of floats]
[79ac6f8]33       
[ae3ce4e]34        """
35       
36        # Initialize BaseComponent first, then sphere
37        BaseComponent.__init__(self)
38        Disperser.__init__(self, model, paramList, sigmaList)
39        ## Name of the model
40        self.name = model.name
41        ## Keep track of the underlying model
42        self.model = model
[279e371]43        self.description =''
[988130c6]44        #list of parameter that cannot be fitted
[279e371]45        self.fixed = []
[79ac6f8]46       
[ae3ce4e]47    def clone(self):
48        """ Return a identical copy of self """
[279e371]49        return DisperseModel(self.model, self.params['paramList'], 
50                             self.params['sigmaList']) 
[ae3ce4e]51   
52    def setParam(self, name, value):
[279e371]53        """
54            Set a parameter value
55            :param name: parameter name
56        """
57        if name.lower() in self.params:
58            BaseComponent.setParam(self, name, value)
59        else:
60            self.model.setParam(name, value)
[ae3ce4e]61   
62    def getParam(self, name):
[279e371]63        """
64            Get the value of the given parameter
65            :param name: parameter name
66        """
67        if name.lower() in self.params:
68            return BaseComponent.getParam(self, name)
69        else:
70            return self.model.getParam(name)
[ae3ce4e]71   
72    def run(self, x = 0.0):
[79ac6f8]73        """
[279e371]74            Evaluate the model
75            :param x: input q, or [q,phi]
76            :return: scattering function P(q)
[ae3ce4e]77        """
78        return Disperser.run(self, x)
79           
80    def runXY(self, x = 0.0):
[79ac6f8]81        """
[279e371]82            Evaluate the model
83            :param x: input q, or [q,phi]
84            :return: scattering function P(q)
[ae3ce4e]85        """
86        return Disperser.runXY(self, x)
87   
88# End of file
Note: See TracBrowser for help on using the repository browser.