source: sasview/sansmodels/src/sans/models/DisperseModel.py @ 643a82a

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 643a82a was 79ac6f8, checked in by Gervaise Alina <gervyh@…>, 14 years ago

working on documentation

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