source: sasview/sansview/plugins/testmodel.py @ 1350c87

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 1350c87 was f99a6b1, checked in by Jae Cho <jhjcho@…>, 16 years ago

changed initial values

  • Property mode set to 100644
File size: 1.1 KB
Line 
1"""
2    Test plug-in model
3"""
4from sans.models.pluginmodel import Model1DPlugin
5
6import math
7
8
9# Your model HAS to be called Model
10class Model(Model1DPlugin):
11    """ Class that evaluates a cos(x) model.
12    """
13   
14    ## Name of the model
15    name = "A+Bcos(2x)+Csin(2x)"
16   
17    def __init__(self):
18        """ Initialization """
19        Model1DPlugin.__init__(self, name= self.name)
20       
21        ## Parameters definition and defaults
22        self.params = {}
23        self.params['A'] = 1.0
24        self.params['B'] = 1.0
25        self.params['C'] = 10.0
26
27        ## Parameter details [units, min, max]
28        self.details = {}
29        self.details['A'] = ['', -1e16, 1e16]
30        self.details['B'] = ['', -1e16, 1e16]
31        self.details['C'] = ['', -1e16, 1e16]
32        self.description = "F(x)=A+Bcos(2x)+Csin(2x) "
33   
34    def function(self, x = 0.0):
35        """ Evaluate the model
36            @param x: input x
37            @return: function value
38        """
39        return self.params['A']+self.params['B']*math.cos(2.0*x)+self.params['C']*math.sin(2.0*x)
40   
Note: See TracBrowser for help on using the repository browser.