1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
---|
2 | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
---|
3 | |
---|
4 | |
---|
5 | <html xmlns="http://www.w3.org/1999/xhtml"> |
---|
6 | <head> |
---|
7 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
---|
8 | |
---|
9 | <title>3.13. Sasview interface — Sasmodels</title> |
---|
10 | |
---|
11 | <link rel="stylesheet" href="../_static/haiku-site.css" type="text/css" /> |
---|
12 | <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> |
---|
13 | |
---|
14 | <script type="text/javascript"> |
---|
15 | var DOCUMENTATION_OPTIONS = { |
---|
16 | URL_ROOT: '../', |
---|
17 | VERSION: '0.9', |
---|
18 | COLLAPSE_INDEX: false, |
---|
19 | FILE_SUFFIX: '.html', |
---|
20 | HAS_SOURCE: true |
---|
21 | }; |
---|
22 | </script> |
---|
23 | <script type="text/javascript" src="../_static/jquery.js"></script> |
---|
24 | <script type="text/javascript" src="../_static/underscore.js"></script> |
---|
25 | <script type="text/javascript" src="../_static/doctools.js"></script> |
---|
26 | <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> |
---|
27 | <link rel="top" title="Sasmodels" href="../index.html" /> |
---|
28 | <link rel="up" title="3. Reference" href="index.html" /> |
---|
29 | <link rel="next" title="3.14. SESANS model evaluator" href="sesans.html" /> |
---|
30 | <link rel="prev" title="3.12. 2-D resolution functions" href="resolution2d.html" /> |
---|
31 | </head> |
---|
32 | <body> |
---|
33 | <div class="header"><h1 class="heading"><a href="../index.html"> |
---|
34 | <span>Home</span></a></h1> |
---|
35 | <h2 class="heading"><span>3.13. Sasview interface</span></h2> |
---|
36 | </div> |
---|
37 | <div class="topnav"> |
---|
38 | |
---|
39 | <p> |
---|
40 | «  <a href="resolution2d.html">3.12. 2-D resolution functions</a> |
---|
41 |   ::   |
---|
42 | <a class="uplink" href="../index.html">Contents</a> |
---|
43 |   ::   |
---|
44 | <a href="sesans.html">3.14. SESANS model evaluator</a>  Â» |
---|
45 | </p> |
---|
46 | |
---|
47 | </div> |
---|
48 | <div class="content"> |
---|
49 | |
---|
50 | |
---|
51 | <div class="section" id="sasview-interface"> |
---|
52 | <h1>3.13. Sasview interface<a class="headerlink" href="#sasview-interface" title="Permalink to this headline">¶</a></h1> |
---|
53 | <div class="section" id="module-sasmodels.sasview_model"> |
---|
54 | <span id="sasmodels-sasview-model"></span><h2>3.13.1. <a class="reference internal" href="#module-sasmodels.sasview_model" title="sasmodels.sasview_model"><tt class="xref py py-mod docutils literal"><span class="pre">sasmodels.sasview_model</span></tt></a><a class="headerlink" href="#module-sasmodels.sasview_model" title="Permalink to this headline">¶</a></h2> |
---|
55 | <p>Sasview model constructor.</p> |
---|
56 | <p>Given a module defining an OpenCL kernel such as sasmodels.models.cylinder, |
---|
57 | create a sasview model class to run that kernel as follows:</p> |
---|
58 | <div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">sasmodels.sasview_model</span> <span class="kn">import</span> <span class="n">make_class</span> |
---|
59 | <span class="kn">from</span> <span class="nn">sasmodels.models</span> <span class="kn">import</span> <span class="n">cylinder</span> |
---|
60 | <span class="n">CylinderModel</span> <span class="o">=</span> <span class="n">make_class</span><span class="p">(</span><span class="n">cylinder</span><span class="p">,</span> <span class="n">dtype</span><span class="o">=</span><span class="s">'single'</span><span class="p">)</span> |
---|
61 | </pre></div> |
---|
62 | </div> |
---|
63 | <p>The model parameters for sasmodels are different from those in sasview. |
---|
64 | When reloading previously saved models, the parameters should be converted |
---|
65 | using <tt class="xref py py-func docutils literal"><span class="pre">sasmodels.convert.convert()</span></tt>.</p> |
---|
66 | <dl class="class"> |
---|
67 | <dt id="sasmodels.sasview_model.SasviewModel"> |
---|
68 | <em class="property">class </em><tt class="descclassname">sasmodels.sasview_model.</tt><tt class="descname">SasviewModel</tt><big>(</big><em>model</em><big>)</big><a class="headerlink" href="#sasmodels.sasview_model.SasviewModel" title="Permalink to this definition">¶</a></dt> |
---|
69 | <dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></p> |
---|
70 | <p>Sasview wrapper for opencl/ctypes model.</p> |
---|
71 | <p>Initialization</p> |
---|
72 | <dl class="method"> |
---|
73 | <dt id="sasmodels.sasview_model.SasviewModel.calculate_ER"> |
---|
74 | <tt class="descname">calculate_ER</tt><big>(</big><big>)</big><a class="headerlink" href="#sasmodels.sasview_model.SasviewModel.calculate_ER" title="Permalink to this definition">¶</a></dt> |
---|
75 | <dd><p>Calculate the effective radius for P(q)*S(q)</p> |
---|
76 | <table class="docutils field-list" frame="void" rules="none"> |
---|
77 | <col class="field-name" /> |
---|
78 | <col class="field-body" /> |
---|
79 | <tbody valign="top"> |
---|
80 | <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">the value of the effective radius</td> |
---|
81 | </tr> |
---|
82 | </tbody> |
---|
83 | </table> |
---|
84 | </dd></dl> |
---|
85 | |
---|
86 | <dl class="method"> |
---|
87 | <dt id="sasmodels.sasview_model.SasviewModel.calculate_Iq"> |
---|
88 | <tt class="descname">calculate_Iq</tt><big>(</big><em>*args</em><big>)</big><a class="headerlink" href="#sasmodels.sasview_model.SasviewModel.calculate_Iq" title="Permalink to this definition">¶</a></dt> |
---|
89 | <dd><p>Calculate Iq for one set of q with the current parameters.</p> |
---|
90 | <p>If the model is 1D, use <em>q</em>. If 2D, use <em>qx</em>, <em>qy</em>.</p> |
---|
91 | <p>This should NOT be used for fitting since it copies the <em>q</em> vectors |
---|
92 | to the card for each evaluation.</p> |
---|
93 | </dd></dl> |
---|
94 | |
---|
95 | <dl class="method"> |
---|
96 | <dt id="sasmodels.sasview_model.SasviewModel.calculate_VR"> |
---|
97 | <tt class="descname">calculate_VR</tt><big>(</big><big>)</big><a class="headerlink" href="#sasmodels.sasview_model.SasviewModel.calculate_VR" title="Permalink to this definition">¶</a></dt> |
---|
98 | <dd><p>Calculate the volf ratio for P(q)*S(q)</p> |
---|
99 | <table class="docutils field-list" frame="void" rules="none"> |
---|
100 | <col class="field-name" /> |
---|
101 | <col class="field-body" /> |
---|
102 | <tbody valign="top"> |
---|
103 | <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">the value of the volf ratio</td> |
---|
104 | </tr> |
---|
105 | </tbody> |
---|
106 | </table> |
---|
107 | </dd></dl> |
---|
108 | |
---|
109 | <dl class="method"> |
---|
110 | <dt id="sasmodels.sasview_model.SasviewModel.clone"> |
---|
111 | <tt class="descname">clone</tt><big>(</big><big>)</big><a class="headerlink" href="#sasmodels.sasview_model.SasviewModel.clone" title="Permalink to this definition">¶</a></dt> |
---|
112 | <dd><p>Return a identical copy of self</p> |
---|
113 | </dd></dl> |
---|
114 | |
---|
115 | <dl class="method"> |
---|
116 | <dt id="sasmodels.sasview_model.SasviewModel.evalDistribution"> |
---|
117 | <tt class="descname">evalDistribution</tt><big>(</big><em>qdist</em><big>)</big><a class="headerlink" href="#sasmodels.sasview_model.SasviewModel.evalDistribution" title="Permalink to this definition">¶</a></dt> |
---|
118 | <dd><p>Evaluate a distribution of q-values.</p> |
---|
119 | <ul> |
---|
120 | <li><p class="first">For 1D, a numpy array is expected as input:</p> |
---|
121 | <div class="highlight-python"><div class="highlight"><pre><span class="n">evalDistribution</span><span class="p">(</span><span class="n">q</span><span class="p">)</span> |
---|
122 | </pre></div> |
---|
123 | </div> |
---|
124 | <p>where q is a numpy array.</p> |
---|
125 | </li> |
---|
126 | <li><p class="first">For 2D, a list of numpy arrays are expected: [qx,qy], |
---|
127 | with 1D arrays:</p> |
---|
128 | <div class="highlight-python"><div class="highlight"><pre>qx = [ qx[0], qx[1], qx[2], ....] |
---|
129 | </pre></div> |
---|
130 | </div> |
---|
131 | <p>and:</p> |
---|
132 | <div class="highlight-python"><div class="highlight"><pre>qy = [ qy[0], qy[1], qy[2], ....] |
---|
133 | </pre></div> |
---|
134 | </div> |
---|
135 | </li> |
---|
136 | </ul> |
---|
137 | <p>Then get</p> |
---|
138 | <div class="highlight-python"><div class="highlight"><pre><span class="n">q</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">sqrt</span><span class="p">(</span><span class="n">qx</span><span class="o">^</span><span class="mi">2</span><span class="o">+</span><span class="n">qy</span><span class="o">^</span><span class="mi">2</span><span class="p">)</span> |
---|
139 | </pre></div> |
---|
140 | </div> |
---|
141 | <p>that is a qr in 1D array:</p> |
---|
142 | <div class="highlight-python"><div class="highlight"><pre>q = [q[0], q[1], q[2], ....] |
---|
143 | </pre></div> |
---|
144 | </div> |
---|
145 | <table class="docutils field-list" frame="void" rules="none"> |
---|
146 | <col class="field-name" /> |
---|
147 | <col class="field-body" /> |
---|
148 | <tbody valign="top"> |
---|
149 | <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>qdist</strong> – ndarray of scalar q-values or list [qx,qy]</td> |
---|
150 | </tr> |
---|
151 | </tbody> |
---|
152 | </table> |
---|
153 | <p>where qx,qy are 1D ndarrays</p> |
---|
154 | </dd></dl> |
---|
155 | |
---|
156 | <dl class="method"> |
---|
157 | <dt id="sasmodels.sasview_model.SasviewModel.getDispParamList"> |
---|
158 | <tt class="descname">getDispParamList</tt><big>(</big><big>)</big><a class="headerlink" href="#sasmodels.sasview_model.SasviewModel.getDispParamList" title="Permalink to this definition">¶</a></dt> |
---|
159 | <dd><p>Return a list of all available parameters for the model</p> |
---|
160 | </dd></dl> |
---|
161 | |
---|
162 | <dl class="method"> |
---|
163 | <dt id="sasmodels.sasview_model.SasviewModel.getParam"> |
---|
164 | <tt class="descname">getParam</tt><big>(</big><em>name</em><big>)</big><a class="headerlink" href="#sasmodels.sasview_model.SasviewModel.getParam" title="Permalink to this definition">¶</a></dt> |
---|
165 | <dd><p>Set the value of a model parameter</p> |
---|
166 | <table class="docutils field-list" frame="void" rules="none"> |
---|
167 | <col class="field-name" /> |
---|
168 | <col class="field-body" /> |
---|
169 | <tbody valign="top"> |
---|
170 | <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>name</strong> – name of the parameter</td> |
---|
171 | </tr> |
---|
172 | </tbody> |
---|
173 | </table> |
---|
174 | </dd></dl> |
---|
175 | |
---|
176 | <dl class="method"> |
---|
177 | <dt id="sasmodels.sasview_model.SasviewModel.getParamList"> |
---|
178 | <tt class="descname">getParamList</tt><big>(</big><big>)</big><a class="headerlink" href="#sasmodels.sasview_model.SasviewModel.getParamList" title="Permalink to this definition">¶</a></dt> |
---|
179 | <dd><p>Return a list of all available parameters for the model</p> |
---|
180 | </dd></dl> |
---|
181 | |
---|
182 | <dl class="method"> |
---|
183 | <dt id="sasmodels.sasview_model.SasviewModel.getProfile"> |
---|
184 | <tt class="descname">getProfile</tt><big>(</big><big>)</big><a class="headerlink" href="#sasmodels.sasview_model.SasviewModel.getProfile" title="Permalink to this definition">¶</a></dt> |
---|
185 | <dd><p>Get SLD profile</p> |
---|
186 | <dl class="docutils"> |
---|
187 | <dt>: return: (z, beta) where z is a list of depth of the transition points</dt> |
---|
188 | <dd>beta is a list of the corresponding SLD values</dd> |
---|
189 | </dl> |
---|
190 | </dd></dl> |
---|
191 | |
---|
192 | <dl class="method"> |
---|
193 | <dt id="sasmodels.sasview_model.SasviewModel.is_fittable"> |
---|
194 | <tt class="descname">is_fittable</tt><big>(</big><em>par_name</em><big>)</big><a class="headerlink" href="#sasmodels.sasview_model.SasviewModel.is_fittable" title="Permalink to this definition">¶</a></dt> |
---|
195 | <dd><p>Check if a given parameter is fittable or not</p> |
---|
196 | <table class="docutils field-list" frame="void" rules="none"> |
---|
197 | <col class="field-name" /> |
---|
198 | <col class="field-body" /> |
---|
199 | <tbody valign="top"> |
---|
200 | <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>par_name</strong> – the parameter name to check</td> |
---|
201 | </tr> |
---|
202 | </tbody> |
---|
203 | </table> |
---|
204 | </dd></dl> |
---|
205 | |
---|
206 | <dl class="method"> |
---|
207 | <dt id="sasmodels.sasview_model.SasviewModel.run"> |
---|
208 | <tt class="descname">run</tt><big>(</big><em>x=0.0</em><big>)</big><a class="headerlink" href="#sasmodels.sasview_model.SasviewModel.run" title="Permalink to this definition">¶</a></dt> |
---|
209 | <dd><p>Evaluate the model</p> |
---|
210 | <table class="docutils field-list" frame="void" rules="none"> |
---|
211 | <col class="field-name" /> |
---|
212 | <col class="field-body" /> |
---|
213 | <tbody valign="top"> |
---|
214 | <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>x</strong> – input q, or [q,phi]</td> |
---|
215 | </tr> |
---|
216 | <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">scattering function P(q)</td> |
---|
217 | </tr> |
---|
218 | </tbody> |
---|
219 | </table> |
---|
220 | <p><strong>DEPRECATED</strong>: use calculate_Iq instead</p> |
---|
221 | </dd></dl> |
---|
222 | |
---|
223 | <dl class="method"> |
---|
224 | <dt id="sasmodels.sasview_model.SasviewModel.runXY"> |
---|
225 | <tt class="descname">runXY</tt><big>(</big><em>x=0.0</em><big>)</big><a class="headerlink" href="#sasmodels.sasview_model.SasviewModel.runXY" title="Permalink to this definition">¶</a></dt> |
---|
226 | <dd><p>Evaluate the model in cartesian coordinates</p> |
---|
227 | <table class="docutils field-list" frame="void" rules="none"> |
---|
228 | <col class="field-name" /> |
---|
229 | <col class="field-body" /> |
---|
230 | <tbody valign="top"> |
---|
231 | <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>x</strong> – input q, or [qx, qy]</td> |
---|
232 | </tr> |
---|
233 | <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">scattering function P(q)</td> |
---|
234 | </tr> |
---|
235 | </tbody> |
---|
236 | </table> |
---|
237 | <p><strong>DEPRECATED</strong>: use calculate_Iq instead</p> |
---|
238 | </dd></dl> |
---|
239 | |
---|
240 | <dl class="method"> |
---|
241 | <dt id="sasmodels.sasview_model.SasviewModel.setParam"> |
---|
242 | <tt class="descname">setParam</tt><big>(</big><em>name</em>, <em>value</em><big>)</big><a class="headerlink" href="#sasmodels.sasview_model.SasviewModel.setParam" title="Permalink to this definition">¶</a></dt> |
---|
243 | <dd><p>Set the value of a model parameter</p> |
---|
244 | <table class="docutils field-list" frame="void" rules="none"> |
---|
245 | <col class="field-name" /> |
---|
246 | <col class="field-body" /> |
---|
247 | <tbody valign="top"> |
---|
248 | <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple"> |
---|
249 | <li><strong>name</strong> – name of the parameter</li> |
---|
250 | <li><strong>value</strong> – value of the parameter</li> |
---|
251 | </ul> |
---|
252 | </td> |
---|
253 | </tr> |
---|
254 | </tbody> |
---|
255 | </table> |
---|
256 | </dd></dl> |
---|
257 | |
---|
258 | <dl class="method"> |
---|
259 | <dt id="sasmodels.sasview_model.SasviewModel.set_dispersion"> |
---|
260 | <tt class="descname">set_dispersion</tt><big>(</big><em>parameter</em>, <em>dispersion</em><big>)</big><a class="headerlink" href="#sasmodels.sasview_model.SasviewModel.set_dispersion" title="Permalink to this definition">¶</a></dt> |
---|
261 | <dd><p>Set the dispersion object for a model parameter</p> |
---|
262 | <table class="docutils field-list" frame="void" rules="none"> |
---|
263 | <col class="field-name" /> |
---|
264 | <col class="field-body" /> |
---|
265 | <tbody valign="top"> |
---|
266 | <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple"> |
---|
267 | <li><strong>parameter</strong> – name of the parameter [string]</li> |
---|
268 | <li><strong>dispersion</strong> – dispersion object of type Dispersion</li> |
---|
269 | </ul> |
---|
270 | </td> |
---|
271 | </tr> |
---|
272 | </tbody> |
---|
273 | </table> |
---|
274 | </dd></dl> |
---|
275 | |
---|
276 | </dd></dl> |
---|
277 | |
---|
278 | <dl class="function"> |
---|
279 | <dt id="sasmodels.sasview_model.make_class"> |
---|
280 | <tt class="descclassname">sasmodels.sasview_model.</tt><tt class="descname">make_class</tt><big>(</big><em>model_definition</em>, <em>dtype='single'</em>, <em>namestyle='name'</em><big>)</big><a class="headerlink" href="#sasmodels.sasview_model.make_class" title="Permalink to this definition">¶</a></dt> |
---|
281 | <dd><p>Load the sasview model defined in <em>kernel_module</em>.</p> |
---|
282 | <p>Returns a class that can be used directly as a sasview model.</p> |
---|
283 | <p>Defaults to using the new name for a model. Setting |
---|
284 | <em>namestyle=’oldname’</em> will produce a class with a name |
---|
285 | compatible with SasView.</p> |
---|
286 | </dd></dl> |
---|
287 | |
---|
288 | </div> |
---|
289 | </div> |
---|
290 | |
---|
291 | |
---|
292 | </div> |
---|
293 | <div class="bottomnav"> |
---|
294 | |
---|
295 | <p> |
---|
296 | «  <a href="resolution2d.html">3.12. 2-D resolution functions</a> |
---|
297 |   ::   |
---|
298 | <a class="uplink" href="../index.html">Contents</a> |
---|
299 |   ::   |
---|
300 | <a href="sesans.html">3.14. SESANS model evaluator</a>  Â» |
---|
301 | </p> |
---|
302 | |
---|
303 | </div> |
---|
304 | |
---|
305 | <div class="footer"> |
---|
306 | © Copyright 2014, sasview team. |
---|
307 | Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.3. |
---|
308 | </div> |
---|
309 | </body> |
---|
310 | </html> |
---|