source: sasview/src/sans/models/Lorentzian.py @ 81b524f

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 81b524f was 81b524f, checked in by Jeff Krzywon <jeffery.krzywon@…>, 10 years ago

This branch is now merged with the latest trunk release. I will merge them next.

  • Property mode set to 100644
File size: 5.0 KB
Line 
1##############################################################################
2# This software was developed by the University of Tennessee as part of the
3# Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
4# project funded by the US National Science Foundation.
5#
6# If you use DANSE applications to do scientific research that leads to
7# publication, we ask that you acknowledge the use of the software with the
8# following sentence:
9#
10# This work benefited from DANSE software developed under NSF award DMR-0520547
11#
12# Copyright 2008-2011, University of Tennessee
13##############################################################################
14
15"""
16Provide functionality for a C extension model
17
18:WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
19         DO NOT MODIFY THIS FILE, MODIFY
20            src\sans\models\include\lorentzian.h
21         AND RE-RUN THE GENERATOR SCRIPT
22"""
23
24from sans.models.BaseComponent import BaseComponent
25from sans.models.sans_extension.c_models import CLorentzian
26
27def create_Lorentzian():
28    """
29       Create a model instance
30    """
31    obj = Lorentzian()
32    # CLorentzian.__init__(obj) is called by
33    # the Lorentzian constructor
34    return obj
35
36class Lorentzian(CLorentzian, BaseComponent):
37    """
38    Class that evaluates a Lorentzian model.
39    This file was auto-generated from src\sans\models\include\lorentzian.h.
40    Refer to that file and the structure it contains
41    for details of the model.
42    List of default parameters:
43         scale           = 1.0
44         gamma           = 1.0
45         center          = 0.0
46
47    """
48       
49    def __init__(self, multfactor=1):
50        """ Initialization """
51        self.__dict__ = {}
52       
53        # Initialize BaseComponent first, then sphere
54        BaseComponent.__init__(self)
55        #apply(CLorentzian.__init__, (self,))
56
57        CLorentzian.__init__(self)
58        self.is_multifunc = False
59                       
60        ## Name of the model
61        self.name = "Lorentzian"
62        ## Model description
63        self.description = """
64        f(x)=scale * 1/pi 0.5gamma / [ (x-x_0)^2 + (0.5gamma)^2 ]
65        """
66       
67        ## Parameter details [units, min, max]
68        self.details = {}
69        self.details['scale'] = ['', None, None]
70        self.details['gamma'] = ['', None, None]
71        self.details['center'] = ['', None, None]
72
73        ## fittable parameters
74        self.fixed = []
75       
76        ## non-fittable parameters
77        self.non_fittable = []
78       
79        ## parameters with orientation
80        self.orientation_params = []
81
82        ## parameters with magnetism
83        self.magnetic_params = []
84
85        self.category = None
86        self.multiplicity_info = None
87       
88    def __setstate__(self, state):
89        """
90        restore the state of a model from pickle
91        """
92        self.__dict__, self.params, self.dispersion = state
93       
94    def __reduce_ex__(self, proto):
95        """
96        Overwrite the __reduce_ex__ of PyTypeObject *type call in the init of
97        c model.
98        """
99        state = (self.__dict__, self.params, self.dispersion)
100        return (create_Lorentzian, tuple(), state, None, None)
101       
102    def clone(self):
103        """ Return a identical copy of self """
104        return self._clone(Lorentzian())   
105       
106    def run(self, x=0.0):
107        """
108        Evaluate the model
109       
110        :param x: input q, or [q,phi]
111       
112        :return: scattering function P(q)
113       
114        """
115        return CLorentzian.run(self, x)
116   
117    def runXY(self, x=0.0):
118        """
119        Evaluate the model in cartesian coordinates
120       
121        :param x: input q, or [qx, qy]
122       
123        :return: scattering function P(q)
124       
125        """
126        return CLorentzian.runXY(self, x)
127       
128    def evalDistribution(self, x):
129        """
130        Evaluate the model in cartesian coordinates
131       
132        :param x: input q[], or [qx[], qy[]]
133       
134        :return: scattering function P(q[])
135       
136        """
137        return CLorentzian.evalDistribution(self, x)
138       
139    def calculate_ER(self):
140        """
141        Calculate the effective radius for P(q)*S(q)
142       
143        :return: the value of the effective radius
144       
145        """       
146        return CLorentzian.calculate_ER(self)
147       
148    def calculate_VR(self):
149        """
150        Calculate the volf ratio for P(q)*S(q)
151       
152        :return: the value of the volf ratio
153       
154        """       
155        return CLorentzian.calculate_VR(self)
156             
157    def set_dispersion(self, parameter, dispersion):
158        """
159        Set the dispersion object for a model parameter
160       
161        :param parameter: name of the parameter [string]
162        :param dispersion: dispersion object of type DispersionModel
163       
164        """
165        return CLorentzian.set_dispersion(self,
166               parameter, dispersion.cdisp)
167       
168   
169# End of file
170
Note: See TracBrowser for help on using the repository browser.