source: sasview/sansmodels/src/sans/models/CSParallelepipedModel.py @ 5f43ff9

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 5f43ff9 was c7a7e1b, checked in by Gervaise Alina <gervyh@…>, 14 years ago

working on model pickle

  • Property mode set to 100644
File size: 6.7 KB
Line 
1#!/usr/bin/env python
2
3##############################################################################
4#       This software was developed by the University of Tennessee as part of the
5#       Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
6#       project funded by the US National Science Foundation.
7#
8#       If you use DANSE applications to do scientific research that leads to
9#       publication, we ask that you acknowledge the use of the software with the
10#       following sentence:
11#
12#       "This work benefited from DANSE software developed under NSF award DMR-0520547."
13#
14#       copyright 2008, University of Tennessee
15##############################################################################
16
17
18"""
19Provide functionality for a C extension model
20
21:WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
22         DO NOT MODIFY THIS FILE, MODIFY ..\c_extensions\csparallelepiped.h
23         AND RE-RUN THE GENERATOR SCRIPT
24
25"""
26
27from sans.models.BaseComponent import BaseComponent
28from sans_extension.c_models import CCSParallelepipedModel
29import copy   
30
31def create_CSParallelepipedModel():
32    obj = CSParallelepipedModel()
33    #CCSParallelepipedModel.__init__(obj) is called by CSParallelepipedModel constructor
34    return obj
35
36class CSParallelepipedModel(CCSParallelepipedModel, BaseComponent):
37    """
38    Class that evaluates a CSParallelepipedModel model.
39    This file was auto-generated from ..\c_extensions\csparallelepiped.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         shortA          = 35.0 [A]
45         midB            = 75.0 [A]
46         longC           = 400.0 [A]
47         rimA            = 10.0 [A]
48         rimB            = 10.0 [A]
49         rimC            = 10.0 [A]
50         sld_rimA        = 2e-006 [1/A^(2)]
51         sld_rimB        = 4e-006 [1/A^(2)]
52         sld_rimC        = 2e-006 [1/A^(2)]
53         sld_pcore       = 1e-006 [1/A^(2)]
54         sld_solv        = 6e-006 [1/A^(2)]
55         background      = 0.06 [1/cm]
56         parallel_theta  = 0.0 [deg]
57         parallel_phi    = 0.0 [deg]
58         parallel_psi    = 0.0 [deg]
59
60    """
61       
62    def __init__(self):
63        """ Initialization """
64       
65        # Initialize BaseComponent first, then sphere
66        BaseComponent.__init__(self)
67        #apply(CCSParallelepipedModel.__init__, (self,))
68        CCSParallelepipedModel.__init__(self)
69       
70        ## Name of the model
71        self.name = "CSParallelepipedModel"
72        ## Model description
73        self.description =""" Form factor for a rectangular Shell. Below are the Parameters.
74                scale: scale factor
75                shortA: length of short edge  [A]
76                midB: length of another short edge [A]
77                longC: length of long edge  of the parallelepiped [A]
78                rimA: length of short edge  [A]
79                rimB: length of another short edge [A]
80                rimC: length of long edge  of the parallelepiped [A]
81                sld_rimA: sld of rimA [1/A^(2)]
82                sld_rimB: sld of rimB [1/A^(2)]
83                sld_rimC: sld of rimC [1/A^(2)]
84                sld_core: Pipe_sld [1/A^(2)]
85                sld_solv: solvent_sld [1/A^(2)]
86                background: incoherent Background [1/cm]"""
87       
88        ## Parameter details [units, min, max]
89        self.details = {}
90        self.details['scale'] = ['', None, None]
91        self.details['shortA'] = ['[A]', None, None]
92        self.details['midB'] = ['[A]', None, None]
93        self.details['longC'] = ['[A]', None, None]
94        self.details['rimA'] = ['[A]', None, None]
95        self.details['rimB'] = ['[A]', None, None]
96        self.details['rimC'] = ['[A]', None, None]
97        self.details['sld_rimA'] = ['[1/A^(2)]', None, None]
98        self.details['sld_rimB'] = ['[1/A^(2)]', None, None]
99        self.details['sld_rimC'] = ['[1/A^(2)]', None, None]
100        self.details['sld_pcore'] = ['[1/A^(2)]', None, None]
101        self.details['sld_solv'] = ['[1/A^(2)]', None, None]
102        self.details['background'] = ['[1/cm]', None, None]
103        self.details['parallel_theta'] = ['[deg]', None, None]
104        self.details['parallel_phi'] = ['[deg]', None, None]
105        self.details['parallel_psi'] = ['[deg]', None, None]
106
107        ## fittable parameters
108        self.fixed=['shortA.width', 'midB.width', 'longC.width', 'parallel_phi.width', 'parallel_psi.width', 'parallel_theta.width']
109       
110        ## non-fittable parameters
111        self.non_fittable = []
112       
113        ## parameters with orientation
114        self.orientation_params = ['parallel_phi', 'parallel_psi', 'parallel_theta', 'parallel_phi.width', 'parallel_psi.width', 'parallel_theta.width']
115
116    def __setstate__(self, state):
117        """
118        restore the state of a model from pickle
119        """
120        self.__dict__, self.params, self.dispersion = state
121       
122    def __reduce_ex__(self, proto):
123        """
124        Overwrite the __reduce_ex__ of PyTypeObject *type call in the init of
125        c model.
126        """
127        state = (self.__dict__, self.params, self.dispersion)
128        return (create_CSParallelepipedModel,tuple(), state, None, None)
129       
130    def clone(self):
131        """ Return a identical copy of self """
132        return self._clone(CSParallelepipedModel())   
133       
134   
135    def run(self, x=0.0):
136        """
137        Evaluate the model
138       
139        :param x: input q, or [q,phi]
140       
141        :return: scattering function P(q)
142       
143        """
144       
145        return CCSParallelepipedModel.run(self, x)
146   
147    def runXY(self, x=0.0):
148        """
149        Evaluate the model in cartesian coordinates
150       
151        :param x: input q, or [qx, qy]
152       
153        :return: scattering function P(q)
154       
155        """
156       
157        return CCSParallelepipedModel.runXY(self, x)
158       
159    def evalDistribution(self, x=[]):
160        """
161        Evaluate the model in cartesian coordinates
162       
163        :param x: input q[], or [qx[], qy[]]
164       
165        :return: scattering function P(q[])
166       
167        """
168        return CCSParallelepipedModel.evalDistribution(self, x)
169       
170    def calculate_ER(self):
171        """
172        Calculate the effective radius for P(q)*S(q)
173       
174        :return: the value of the effective radius
175       
176        """       
177        return CCSParallelepipedModel.calculate_ER(self)
178       
179    def set_dispersion(self, parameter, dispersion):
180        """
181        Set the dispersion object for a model parameter
182       
183        :param parameter: name of the parameter [string]
184        :param dispersion: dispersion object of type DispersionModel
185       
186        """
187        return CCSParallelepipedModel.set_dispersion(self, parameter, dispersion.cdisp)
188       
189   
190# End of file
Note: See TracBrowser for help on using the repository browser.