source: sasview/sansview/plugins/testmodel.py @ aa92772

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

moving plugins folder

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