source: sasview/sansmodels/src/sans/models/DisperseModel.py @ 42f193a

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 42f193a was 988130c6, checked in by Gervaise Alina <gervyh@…>, 16 years ago

self.fixed field added in models but need to change wrapper generator

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