source: sasview/sansmodels/src/sans/models/pluginmodel.py @ 5f89fb8

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 5f89fb8 was 5f89fb8, checked in by Gervaise Alina <gervyh@…>, 16 years ago

description field added in models not filled yet

  • Property mode set to 100644
File size: 1.4 KB
Line 
1from sans.models.BaseComponent import BaseComponent
2import math
3
4class Model1DPlugin(BaseComponent):
5    ## Name of the model
6    name = "Plugin Model"
7
8    def __init__(self):
9        """ Initialization """
10        BaseComponent.__init__(self)
11        self.details = {}
12        self.params  = {}
13        self.description=''
14    def function(self, x):
15        """
16            Function to be implemented by the plug-in writer
17        """
18        return x
19       
20    def run(self, x = 0.0):
21        """ Evaluate the model
22            @param x: input x, or [x, phi] [radian]
23            @return: function value
24        """
25        if x.__class__.__name__ == 'list':
26            x_val = x[0]*math.cos(x[1])
27            y_val = x[0]*math.sin(x[1])
28            return self.function(x_val)*self.function(y_val)
29        elif x.__class__.__name__ == 'tuple':
30            raise ValueError, "Tuples are not allowed as input to BaseComponent models"
31        else:
32            return self.function(x)
33   
34    def runXY(self, x = 0.0):
35        """ Evaluate the model
36            @param x: input x, or [x, y]
37            @return: function value
38        """
39        if x.__class__.__name__ == 'list':
40            return self.function(x[0])*self.function(x[1])
41        elif x.__class__.__name__ == 'tuple':
42            raise ValueError, "Tuples are not allowed as input to BaseComponent models"
43        else:
44            return self.function(x)
Note: See TracBrowser for help on using the repository browser.