source: sasview/sansview/plugins/testmodel.py @ 97dea6c

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 97dea6c was 5062bbf, checked in by Gervaise Alina <gervyh@…>, 15 years ago

working on documentation

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