source: sasview/sansmodels/src/sans/models/Cos.py @ 0d86fecb

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

code for description modified

  • Property mode set to 100644
File size: 1.6 KB
RevLine 
[ae3ce4e]1#!/usr/bin/env python
2""" Provide cos(x) function as a BaseComponent model
3"""
4
5from sans.models.BaseComponent import BaseComponent
6import math
7 
8class Cos(BaseComponent):
9    """ Class that evaluates a cos(x) model.
10    """
11       
12    def __init__(self):
13        """ Initialization """
14       
15        # Initialize BaseComponent first, then sphere
16        BaseComponent.__init__(self)
17       
18        ## Name of the model
19        self.name = "Cos"
[96672c0]20        self.description='F(x)=cos(x)'
[ae3ce4e]21        ## Parameter details [units, min, max]
22        self.details = {}
23   
24    def clone(self):
25        """ Return a identical copy of self """
26        return Cos()
27   
28    def run(self, x = 0.0):
29        """ Evaluate the model
30            @param x: input x, or [x, phi] [radian]
31            @return: cos(x) or cos(x*cos(phi))*cos(x*cos(phi))
32        """
33        if x.__class__.__name__ == 'list':
34            return math.cos(x[0]*math.cos(x[1]))*math.cos(x[0]*math.sin(x[1]))
35        elif x.__class__.__name__ == 'tuple':
36            raise ValueError, "Tuples are not allowed as input to BaseComponent models"
37        else:
38            return math.cos(x)
39   
40    def runXY(self, x = 0.0):
41        """ Evaluate the model
42            @param x: input x, or [x, y] [radian]
43            @return: cos(x) or cos(x)*cos(y)
44        """
45        if x.__class__.__name__ == 'list':
46            return math.cos(x[0])*math.cos(x[1])
47        elif x.__class__.__name__ == 'tuple':
48            raise ValueError, "Tuples are not allowed as input to BaseComponent models"
49        else:
50            return math.cos(x)
51   
52# End of file
Note: See TracBrowser for help on using the repository browser.