# source:sasview/src/sas/models/Sin.py@79492222

Last change on this file since 79492222 was 79492222, checked in by krzywon, 8 years ago

Changed the file and folder names to remove all SANS references.

• Property mode set to `100644`
File size: 1.7 KB
Line
1#!/usr/bin/env python
2""" Provide sin(x) function as a BaseComponent model
3"""
4
5from sas.models.BaseComponent import BaseComponent
6import math
7
8class Sin(BaseComponent):
9    """ Class that evaluates a sin(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 = "Sin"
20        self.description=""" the sin model
21        F(x)=sin(x)
22        """
23        ## Parameter details [units, min, max]
24        self.details = {}
25        #list of parameter that cannot be fitted
26        self.fixed= []
27    def clone(self):
28        """ Return a identical copy of self """
29        return Sin()
30
31    def run(self, x = 0.0):
32        """ Evaluate the model
33            @param x: input x, or [x, phi] [radian]
34            @return: sin(x) or sin(x*cos(phi))*sin(x*sin(phi))
35        """
36        if x.__class__.__name__ == 'list':
37            return math.sin(x[0]*math.cos(x[1]))*math.sin(x[0]*math.sin(x[1]))
38        elif x.__class__.__name__ == 'tuple':
39            raise ValueError, "Tuples are not allowed as input to BaseComponent models"
40        else:
41            return math.sin(x)
42
43    def runXY(self, x = 0.0):
44        """ Evaluate the model
45            @param x: input x, or [x, y] [radian]
46            @return: sin(x) or sin(x)*sin(y)
47        """
48        if x.__class__.__name__ == 'list':
49            return math.sin(x[0])*math.sin(x[1])
50        elif x.__class__.__name__ == 'tuple':
51            raise ValueError, "Tuples are not allowed as input to BaseComponent models"
52        else:
53            return math.sin(x)
54
55# End of file
Note: See TracBrowser for help on using the repository browser.