source: sasview/pr_inversion/docs/sphinx/html/api/invertor.html @ 8884996

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 8884996 was 8884996, checked in by Gervaise Alina <gervyh@…>, 13 years ago

edit doc

  • Property mode set to 100644
File size: 38.3 KB
Line 
1
2
3<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
6
7<html xmlns="http://www.w3.org/1999/xhtml">
8  <head>
9    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
10   
11    <title>invertor &mdash; pr_inversion 0.1.0 documentation</title>
12   
13    <link rel="stylesheet" href="../_static/default.css" type="text/css" />
14    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
15   
16    <script type="text/javascript">
17      var DOCUMENTATION_OPTIONS = {
18        URL_ROOT:    '../',
19        VERSION:     '0.1.0',
20        COLLAPSE_INDEX: false,
21        FILE_SUFFIX: '.html',
22        HAS_SOURCE:  true
23      };
24    </script>
25    <script type="text/javascript" src="../_static/jquery.js"></script>
26    <script type="text/javascript" src="../_static/underscore.js"></script>
27    <script type="text/javascript" src="../_static/doctools.js"></script>
28    <link rel="top" title="pr_inversion 0.1.0 documentation" href="../index.html" />
29    <link rel="up" title="Reference" href="index.html" />
30    <link rel="next" title="num_term" href="num_term.html" />
31    <link rel="prev" title="distance_explorer" href="distance_explorer.html" /> 
32  </head>
33  <body>
34    <div class="related">
35      <h3>Navigation</h3>
36      <ul>
37        <li class="right" style="margin-right: 10px">
38          <a href="../genindex.html" title="General Index"
39             accesskey="I">index</a></li>
40        <li class="right" >
41          <a href="../py-modindex.html" title="Python Module Index"
42             >modules</a> |</li>
43        <li class="right" >
44          <a href="num_term.html" title="num_term"
45             accesskey="N">next</a> |</li>
46        <li class="right" >
47          <a href="distance_explorer.html" title="distance_explorer"
48             accesskey="P">previous</a> |</li>
49        <li><a href="../index.html">pr_inversion 0.1.0 documentation</a> &raquo;</li>
50          <li><a href="index.html" accesskey="U">Reference</a> &raquo;</li> 
51      </ul>
52    </div> 
53
54    <div class="document">
55      <div class="documentwrapper">
56        <div class="bodywrapper">
57          <div class="body">
58           
59  <div class="section" id="invertor">
60<h1>invertor<a class="headerlink" href="#invertor" title="Permalink to this headline">¶</a></h1>
61<div class="section" id="sans-pr-invertor">
62<h2><a class="reference internal" href="#module-sans.pr.invertor" title="sans.pr.invertor"><tt class="xref py py-mod docutils literal"><span class="pre">sans.pr.invertor</span></tt></a><a class="headerlink" href="#sans-pr-invertor" title="Permalink to this headline">¶</a></h2>
63<span class="target" id="module-sans.pr.invertor"></span><p>Module to perform P(r) inversion.
64The module contains the Invertor class.</p>
65<dl class="class">
66<dt id="sans.pr.invertor.Invertor">
67<em class="property">class </em><tt class="descclassname">sans.pr.invertor.</tt><tt class="descname">Invertor</tt><a class="headerlink" href="#sans.pr.invertor.Invertor" title="Permalink to this definition">¶</a></dt>
68<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">Cinvertor</span></tt></p>
69<p>Invertor class to perform P(r) inversion</p>
70<p>The problem is solved by posing the problem as  Ax = b,
71where x is the set of coefficients we are looking for.</p>
72<p>Npts is the number of points.</p>
73<p>In the following i refers to the ith base function coefficient.
74The matrix has its entries j in its first Npts rows set to</p>
75<blockquote>
76<div>A[j][i] = (Fourier transformed base function for point j)</div></blockquote>
77<p>We them choose a number of r-points, n_r, to evaluate the second
78derivative of P(r) at. This is used as our regularization term.
79For a vector r of length n_r, the following n_r rows are set to</p>
80<blockquote>
81<div>A[j+Npts][i] = (2nd derivative of P(r), d**2(P(r))/d(r)**2,
82evaluated at r[j])</div></blockquote>
83<dl class="docutils">
84<dt>The vector b has its first Npts entries set to</dt>
85<dd>b[j] = (I(q) observed for point j)</dd>
86</dl>
87<p>The following n_r entries are set to zero.</p>
88<p>The result is found by using scipy.linalg.basic.lstsq to invert
89the matrix and find the coefficients x.</p>
90<p>Methods inherited from Cinvertor:
91- get_peaks(pars): returns the number of P(r) peaks
92- oscillations(pars): returns the oscillation parameters for the output P(r)
93- get_positive(pars): returns the fraction of P(r) that is above zero
94- get_pos_err(pars): returns the fraction of P(r) that is 1-sigma above zero</p>
95<dl class="attribute">
96<dt id="sans.pr.invertor.Invertor.__class__">
97<tt class="descname">__class__</tt><a class="headerlink" href="#sans.pr.invertor.Invertor.__class__" title="Permalink to this definition">¶</a></dt>
98<dd><p>alias of <tt class="xref py py-class docutils literal"><span class="pre">type</span></tt></p>
99</dd></dl>
100
101<dl class="attribute">
102<dt id="sans.pr.invertor.Invertor.__delattr__">
103<tt class="descname">__delattr__</tt><a class="headerlink" href="#sans.pr.invertor.Invertor.__delattr__" title="Permalink to this definition">¶</a></dt>
104<dd><p>x.__delattr__(&#8216;name&#8217;) &lt;==&gt; del x.name</p>
105</dd></dl>
106
107<dl class="attribute">
108<dt id="sans.pr.invertor.Invertor.__dict__">
109<tt class="descname">__dict__</tt><em class="property"> = &lt;dictproxy object at 0x01CA22F0&gt;</em><a class="headerlink" href="#sans.pr.invertor.Invertor.__dict__" title="Permalink to this definition">¶</a></dt>
110<dd></dd></dl>
111
112<dl class="method">
113<dt id="sans.pr.invertor.Invertor.__getattr__">
114<tt class="descname">__getattr__</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.__getattr__" title="Permalink to this definition">¶</a></dt>
115<dd><p>Return the value of an attribute</p>
116</dd></dl>
117
118<dl class="attribute">
119<dt id="sans.pr.invertor.Invertor.__getattribute__">
120<tt class="descname">__getattribute__</tt><a class="headerlink" href="#sans.pr.invertor.Invertor.__getattribute__" title="Permalink to this definition">¶</a></dt>
121<dd><p>x.__getattribute__(&#8216;name&#8217;) &lt;==&gt; x.name</p>
122</dd></dl>
123
124<dl class="attribute">
125<dt id="sans.pr.invertor.Invertor.__hash__">
126<tt class="descname">__hash__</tt><a class="headerlink" href="#sans.pr.invertor.Invertor.__hash__" title="Permalink to this definition">¶</a></dt>
127<dd><p>x.__hash__() &lt;==&gt; hash(x)</p>
128</dd></dl>
129
130<dl class="method">
131<dt id="sans.pr.invertor.Invertor.__init__">
132<tt class="descname">__init__</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.__init__" title="Permalink to this definition">¶</a></dt>
133<dd></dd></dl>
134
135<dl class="attribute">
136<dt id="sans.pr.invertor.Invertor.__module__">
137<tt class="descname">__module__</tt><em class="property"> = 'sans.pr.invertor'</em><a class="headerlink" href="#sans.pr.invertor.Invertor.__module__" title="Permalink to this definition">¶</a></dt>
138<dd></dd></dl>
139
140<dl class="staticmethod">
141<dt id="sans.pr.invertor.Invertor.__new__">
142<em class="property">static </em><tt class="descname">__new__</tt><big>(</big><em>S</em>, <em>...</em><big>)</big> &rarr; a new object with type S, a subtype of T<a class="headerlink" href="#sans.pr.invertor.Invertor.__new__" title="Permalink to this definition">¶</a></dt>
143<dd></dd></dl>
144
145<dl class="method">
146<dt id="sans.pr.invertor.Invertor.__reduce__">
147<tt class="descname">__reduce__</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.__reduce__" title="Permalink to this definition">¶</a></dt>
148<dd><p>helper for pickle</p>
149</dd></dl>
150
151<dl class="method">
152<dt id="sans.pr.invertor.Invertor.__reduce_ex__">
153<tt class="descname">__reduce_ex__</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.__reduce_ex__" title="Permalink to this definition">¶</a></dt>
154<dd><p>Overwrite the __reduce_ex__</p>
155</dd></dl>
156
157<dl class="attribute">
158<dt id="sans.pr.invertor.Invertor.__repr__">
159<tt class="descname">__repr__</tt><a class="headerlink" href="#sans.pr.invertor.Invertor.__repr__" title="Permalink to this definition">¶</a></dt>
160<dd><p>x.__repr__() &lt;==&gt; repr(x)</p>
161</dd></dl>
162
163<dl class="method">
164<dt id="sans.pr.invertor.Invertor.__setattr__">
165<tt class="descname">__setattr__</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.__setattr__" title="Permalink to this definition">¶</a></dt>
166<dd><p>Set the value of an attribute.
167Access the parent class methods for
168x, y, err, d_max, q_min, q_max and alpha</p>
169</dd></dl>
170
171<dl class="method">
172<dt id="sans.pr.invertor.Invertor.__setstate__">
173<tt class="descname">__setstate__</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.__setstate__" title="Permalink to this definition">¶</a></dt>
174<dd><p>restore the state of invertor for pickle</p>
175</dd></dl>
176
177<dl class="attribute">
178<dt id="sans.pr.invertor.Invertor.__str__">
179<tt class="descname">__str__</tt><a class="headerlink" href="#sans.pr.invertor.Invertor.__str__" title="Permalink to this definition">¶</a></dt>
180<dd><p>x.__str__() &lt;==&gt; str(x)</p>
181</dd></dl>
182
183<dl class="attribute">
184<dt id="sans.pr.invertor.Invertor.__weakref__">
185<tt class="descname">__weakref__</tt><a class="headerlink" href="#sans.pr.invertor.Invertor.__weakref__" title="Permalink to this definition">¶</a></dt>
186<dd><p>list of weak references to the object (if defined)</p>
187</dd></dl>
188
189<dl class="method">
190<dt id="sans.pr.invertor.Invertor._accept_q">
191<tt class="descname">_accept_q</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor._accept_q" title="Permalink to this definition">¶</a></dt>
192<dd><p>Check q-value against user-defined range</p>
193</dd></dl>
194
195<dl class="method">
196<dt id="sans.pr.invertor.Invertor._get_invcov_matrix">
197<tt class="descname">_get_invcov_matrix</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor._get_invcov_matrix" title="Permalink to this definition">¶</a></dt>
198<dd><p>Compute the inverse covariance matrix, defined as inv_cov = a_transposed x a.
199&#64;param nfunc: number of base functions
200&#64;param nr: number of r-points used when evaluating reg term.
201&#64;param a: A array to fill
202&#64;param inv_cov: inverse covariance array to be filled
203&#64;return: 0</p>
204</dd></dl>
205
206<dl class="method">
207<dt id="sans.pr.invertor.Invertor._get_matrix">
208<tt class="descname">_get_matrix</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor._get_matrix" title="Permalink to this definition">¶</a></dt>
209<dd><p>Returns A matrix and b vector for least square problem.
210&#64;param nfunc: number of base functions
211&#64;param nr: number of r-points used when evaluating reg term.
212&#64;param a: A array to fill
213&#64;param b: b vector to fill
214&#64;return: 0</p>
215</dd></dl>
216
217<dl class="method">
218<dt id="sans.pr.invertor.Invertor._get_reg_size">
219<tt class="descname">_get_reg_size</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor._get_reg_size" title="Permalink to this definition">¶</a></dt>
220<dd><p>Compute the covariance matrix, defined as inv_cov = a_transposed x a.
221&#64;param nfunc: number of base functions
222&#64;param nr: number of r-points used when evaluating reg term.
223&#64;param a: A array to fill
224&#64;param inv_cov: inverse covariance array to be filled
225&#64;return: 0</p>
226</dd></dl>
227
228<dl class="attribute">
229<dt id="sans.pr.invertor.Invertor.background">
230<tt class="descname">background</tt><em class="property"> = 0</em><a class="headerlink" href="#sans.pr.invertor.Invertor.background" title="Permalink to this definition">¶</a></dt>
231<dd></dd></dl>
232
233<dl class="method">
234<dt id="sans.pr.invertor.Invertor.basefunc_ft">
235<tt class="descname">basefunc_ft</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.basefunc_ft" title="Permalink to this definition">¶</a></dt>
236<dd><p>Returns the value of the nth Fourier transofrmed base function
237&#64;param args: c-parameters, n and q
238&#64;return: nth Fourier transformed base function, evaluated at q</p>
239</dd></dl>
240
241<dl class="attribute">
242<dt id="sans.pr.invertor.Invertor.chi2">
243<tt class="descname">chi2</tt><em class="property"> = 0</em><a class="headerlink" href="#sans.pr.invertor.Invertor.chi2" title="Permalink to this definition">¶</a></dt>
244<dd></dd></dl>
245
246<dl class="method">
247<dt id="sans.pr.invertor.Invertor.clone">
248<tt class="descname">clone</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.clone" title="Permalink to this definition">¶</a></dt>
249<dd><p>Return a clone of this instance</p>
250</dd></dl>
251
252<dl class="attribute">
253<dt id="sans.pr.invertor.Invertor.cov">
254<tt class="descname">cov</tt><em class="property"> = None</em><a class="headerlink" href="#sans.pr.invertor.Invertor.cov" title="Permalink to this definition">¶</a></dt>
255<dd></dd></dl>
256
257<dl class="attribute">
258<dt id="sans.pr.invertor.Invertor.elapsed">
259<tt class="descname">elapsed</tt><em class="property"> = 0</em><a class="headerlink" href="#sans.pr.invertor.Invertor.elapsed" title="Permalink to this definition">¶</a></dt>
260<dd></dd></dl>
261
262<dl class="method">
263<dt id="sans.pr.invertor.Invertor.estimate_alpha">
264<tt class="descname">estimate_alpha</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.estimate_alpha" title="Permalink to this definition">¶</a></dt>
265<dd><p>Returns a reasonable guess for the
266regularization constant alpha</p>
267<table class="docutils field-list" frame="void" rules="none">
268<col class="field-name" />
269<col class="field-body" />
270<tbody valign="top">
271<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>nfunc</strong> &#8211; number of terms to use in the expansion.</td>
272</tr>
273<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">alpha, message, elapsed</td>
274</tr>
275</tbody>
276</table>
277<p>where alpha is the estimate for alpha,
278message is a message for the user,
279elapsed is the computation time</p>
280</dd></dl>
281
282<dl class="method">
283<dt id="sans.pr.invertor.Invertor.estimate_numterms">
284<tt class="descname">estimate_numterms</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.estimate_numterms" title="Permalink to this definition">¶</a></dt>
285<dd><p>Returns a reasonable guess for the
286number of terms</p>
287<table class="docutils field-list" frame="void" rules="none">
288<col class="field-name" />
289<col class="field-body" />
290<tbody valign="top">
291<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>isquit_func</strong> &#8211; reference to thread function to call to
292check whether the computation needs to
293be stopped.</td>
294</tr>
295<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">number of terms, alpha, message</td>
296</tr>
297</tbody>
298</table>
299</dd></dl>
300
301<dl class="method">
302<dt id="sans.pr.invertor.Invertor.from_file">
303<tt class="descname">from_file</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.from_file" title="Permalink to this definition">¶</a></dt>
304<dd><p>Load the state of the Invertor from a file,
305to be able to generate P(r) from a set of
306parameters.</p>
307<table class="docutils field-list" frame="void" rules="none">
308<col class="field-name" />
309<col class="field-body" />
310<tbody valign="top">
311<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>path</strong> &#8211; path of the file to load</td>
312</tr>
313</tbody>
314</table>
315</dd></dl>
316
317<dl class="method">
318<dt id="sans.pr.invertor.Invertor.get_alpha">
319<tt class="descname">get_alpha</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.get_alpha" title="Permalink to this definition">¶</a></dt>
320<dd><p>Gets the alpha parameter</p>
321</dd></dl>
322
323<dl class="method">
324<dt id="sans.pr.invertor.Invertor.get_dmax">
325<tt class="descname">get_dmax</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.get_dmax" title="Permalink to this definition">¶</a></dt>
326<dd><p>Gets the maximum distance</p>
327</dd></dl>
328
329<dl class="method">
330<dt id="sans.pr.invertor.Invertor.get_err">
331<tt class="descname">get_err</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.get_err" title="Permalink to this definition">¶</a></dt>
332<dd><p>Function to get the err data
333Takes an array of doubles as input.
334&#64;return: number of entries found</p>
335</dd></dl>
336
337<dl class="method">
338<dt id="sans.pr.invertor.Invertor.get_has_bck">
339<tt class="descname">get_has_bck</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.get_has_bck" title="Permalink to this definition">¶</a></dt>
340<dd><p>Gets background flag</p>
341</dd></dl>
342
343<dl class="method">
344<dt id="sans.pr.invertor.Invertor.get_nerr">
345<tt class="descname">get_nerr</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.get_nerr" title="Permalink to this definition">¶</a></dt>
346<dd><p>Gets the number of err points</p>
347</dd></dl>
348
349<dl class="method">
350<dt id="sans.pr.invertor.Invertor.get_nx">
351<tt class="descname">get_nx</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.get_nx" title="Permalink to this definition">¶</a></dt>
352<dd><p>Gets the number of x points</p>
353</dd></dl>
354
355<dl class="method">
356<dt id="sans.pr.invertor.Invertor.get_ny">
357<tt class="descname">get_ny</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.get_ny" title="Permalink to this definition">¶</a></dt>
358<dd><p>Gets the number of y points</p>
359</dd></dl>
360
361<dl class="method">
362<dt id="sans.pr.invertor.Invertor.get_peaks">
363<tt class="descname">get_peaks</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.get_peaks" title="Permalink to this definition">¶</a></dt>
364<dd><p>Returns the number of peaks in the output P(r) distrubution
365for the given set of coefficients.
366&#64;param args: c-parameters
367&#64;return: number of P(r) peaks</p>
368</dd></dl>
369
370<dl class="method">
371<dt id="sans.pr.invertor.Invertor.get_pos_err">
372<tt class="descname">get_pos_err</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.get_pos_err" title="Permalink to this definition">¶</a></dt>
373<dd><p>Returns the fraction of P(r) that is 1 standard deviation
374above zero over the full range of r for the given set of coefficients.
375&#64;param args: c-parameters
376&#64;return: fraction of P(r) that is positive</p>
377</dd></dl>
378
379<dl class="method">
380<dt id="sans.pr.invertor.Invertor.get_positive">
381<tt class="descname">get_positive</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.get_positive" title="Permalink to this definition">¶</a></dt>
382<dd><p>Returns the fraction of P(r) that is positive over
383the full range of r for the given set of coefficients.
384&#64;param args: c-parameters
385&#64;return: fraction of P(r) that is positive</p>
386</dd></dl>
387
388<dl class="method">
389<dt id="sans.pr.invertor.Invertor.get_pr_err">
390<tt class="descname">get_pr_err</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.get_pr_err" title="Permalink to this definition">¶</a></dt>
391<dd><p>Function to call to evaluate P(r) with errors
392&#64;param args: c-parameters and r
393&#64;return: (P(r),dP(r))</p>
394</dd></dl>
395
396<dl class="method">
397<dt id="sans.pr.invertor.Invertor.get_qmax">
398<tt class="descname">get_qmax</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.get_qmax" title="Permalink to this definition">¶</a></dt>
399<dd><p>Gets the maximum q</p>
400</dd></dl>
401
402<dl class="method">
403<dt id="sans.pr.invertor.Invertor.get_qmin">
404<tt class="descname">get_qmin</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.get_qmin" title="Permalink to this definition">¶</a></dt>
405<dd><p>Gets the minimum q</p>
406</dd></dl>
407
408<dl class="method">
409<dt id="sans.pr.invertor.Invertor.get_slit_height">
410<tt class="descname">get_slit_height</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.get_slit_height" title="Permalink to this definition">¶</a></dt>
411<dd><p>Gets the slit height</p>
412</dd></dl>
413
414<dl class="method">
415<dt id="sans.pr.invertor.Invertor.get_slit_width">
416<tt class="descname">get_slit_width</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.get_slit_width" title="Permalink to this definition">¶</a></dt>
417<dd><p>Gets the slit width</p>
418</dd></dl>
419
420<dl class="method">
421<dt id="sans.pr.invertor.Invertor.get_x">
422<tt class="descname">get_x</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.get_x" title="Permalink to this definition">¶</a></dt>
423<dd><p>Function to get the x data
424Takes an array of doubles as input.
425&#64;return: number of entries found</p>
426</dd></dl>
427
428<dl class="method">
429<dt id="sans.pr.invertor.Invertor.get_y">
430<tt class="descname">get_y</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.get_y" title="Permalink to this definition">¶</a></dt>
431<dd><p>Function to get the y data
432Takes an array of doubles as input.
433&#64;return: number of entries found</p>
434</dd></dl>
435
436<dl class="attribute">
437<dt id="sans.pr.invertor.Invertor.info">
438<tt class="descname">info</tt><em class="property"> = {}</em><a class="headerlink" href="#sans.pr.invertor.Invertor.info" title="Permalink to this definition">¶</a></dt>
439<dd></dd></dl>
440
441<dl class="method">
442<dt id="sans.pr.invertor.Invertor.invert">
443<tt class="descname">invert</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.invert" title="Permalink to this definition">¶</a></dt>
444<dd><p>Perform inversion to P(r)</p>
445<p>The problem is solved by posing the problem as  Ax = b,
446where x is the set of coefficients we are looking for.</p>
447<p>Npts is the number of points.</p>
448<p>In the following i refers to the ith base function coefficient.
449The matrix has its entries j in its first Npts rows set to</p>
450<blockquote>
451<div>A[i][j] = (Fourier transformed base function for point j)</div></blockquote>
452<p>We them choose a number of r-points, n_r, to evaluate the second
453derivative of P(r) at. This is used as our regularization term.
454For a vector r of length n_r, the following n_r rows are set to</p>
455<blockquote>
456<div>A[i+Npts][j] = (2nd derivative of P(r), d**2(P(r))/d(r)**2, evaluated at r[j])</div></blockquote>
457<dl class="docutils">
458<dt>The vector b has its first Npts entries set to</dt>
459<dd>b[j] = (I(q) observed for point j)</dd>
460</dl>
461<p>The following n_r entries are set to zero.</p>
462<p>The result is found by using scipy.linalg.basic.lstsq to invert
463the matrix and find the coefficients x.</p>
464<table class="docutils field-list" frame="void" rules="none">
465<col class="field-name" />
466<col class="field-body" />
467<tbody valign="top">
468<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
469<li><strong>nfunc</strong> &#8211; number of base functions to use.</li>
470<li><strong>nr</strong> &#8211; number of r points to evaluate the 2nd derivative at for the reg. term.</li>
471</ul>
472</td>
473</tr>
474<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">c_out, c_cov - the coefficients with covariance matrix</p>
475</td>
476</tr>
477</tbody>
478</table>
479</dd></dl>
480
481<dl class="method">
482<dt id="sans.pr.invertor.Invertor.invert_optimize">
483<tt class="descname">invert_optimize</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.invert_optimize" title="Permalink to this definition">¶</a></dt>
484<dd><p>Slower version of the P(r) inversion that uses scipy.optimize.leastsq.</p>
485<p>This probably produce more reliable results, but is much slower.
486The minimization function is set to
487sum_i[ (I_obs(q_i) - I_theo(q_i))/err**2 ] + alpha * reg_term,
488where the reg_term is given by Svergun: it is the integral of
489the square of the first derivative
490of P(r), d(P(r))/dr, integrated over the full range of r.</p>
491<table class="docutils field-list" frame="void" rules="none">
492<col class="field-name" />
493<col class="field-body" />
494<tbody valign="top">
495<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
496<li><strong>nfunc</strong> &#8211; number of base functions to use.</li>
497<li><strong>nr</strong> &#8211; number of r points to evaluate the 2nd derivative at
498for the reg. term.</li>
499</ul>
500</td>
501</tr>
502<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">c_out, c_cov - the coefficients with covariance matrix</p>
503</td>
504</tr>
505</tbody>
506</table>
507</dd></dl>
508
509<dl class="method">
510<dt id="sans.pr.invertor.Invertor.iq">
511<tt class="descname">iq</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.iq" title="Permalink to this definition">¶</a></dt>
512<dd><p>Function to call to evaluate the scattering intensity</p>
513<table class="docutils field-list" frame="void" rules="none">
514<col class="field-name" />
515<col class="field-body" />
516<tbody valign="top">
517<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>args</strong> &#8211; c-parameters, and q</td>
518</tr>
519<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">I(q)</td>
520</tr>
521</tbody>
522</table>
523</dd></dl>
524
525<dl class="method">
526<dt id="sans.pr.invertor.Invertor.iq0">
527<tt class="descname">iq0</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.iq0" title="Permalink to this definition">¶</a></dt>
528<dd><p>Returns the value of I(q=0).
529&#64;param args: c-parameters
530&#64;return: I(q=0)</p>
531</dd></dl>
532
533<dl class="method">
534<dt id="sans.pr.invertor.Invertor.iq_smeared">
535<tt class="descname">iq_smeared</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.iq_smeared" title="Permalink to this definition">¶</a></dt>
536<dd><p>Function to call to evaluate the scattering intensity.
537The scattering intensity is slit-smeared. &#64;param args: c-parameters, and q
538&#64;return: I(q)</p>
539</dd></dl>
540
541<dl class="method">
542<dt id="sans.pr.invertor.Invertor.is_valid">
543<tt class="descname">is_valid</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.is_valid" title="Permalink to this definition">¶</a></dt>
544<dd><p>Check the validity of the stored data
545&#64;return: Returns the number of points if it&#8217;s all good, -1 otherwise</p>
546</dd></dl>
547
548<dl class="method">
549<dt id="sans.pr.invertor.Invertor.lstsq">
550<tt class="descname">lstsq</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.lstsq" title="Permalink to this definition">¶</a></dt>
551<dd><p>The problem is solved by posing the problem as  Ax = b,
552where x is the set of coefficients we are looking for.</p>
553<p>Npts is the number of points.</p>
554<p>In the following i refers to the ith base function coefficient.
555The matrix has its entries j in its first Npts rows set to</p>
556<blockquote>
557<div>A[i][j] = (Fourier transformed base function for point j)</div></blockquote>
558<p>We them choose a number of r-points, n_r, to evaluate the second
559derivative of P(r) at. This is used as our regularization term.
560For a vector r of length n_r, the following n_r rows are set to</p>
561<blockquote>
562<div>A[i+Npts][j] = (2nd derivative of P(r), d**2(P(r))/d(r)**2,
563evaluated at r[j])</div></blockquote>
564<dl class="docutils">
565<dt>The vector b has its first Npts entries set to</dt>
566<dd>b[j] = (I(q) observed for point j)</dd>
567</dl>
568<p>The following n_r entries are set to zero.</p>
569<p>The result is found by using scipy.linalg.basic.lstsq to invert
570the matrix and find the coefficients x.</p>
571<table class="docutils field-list" frame="void" rules="none">
572<col class="field-name" />
573<col class="field-body" />
574<tbody valign="top">
575<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
576<li><strong>nfunc</strong> &#8211; number of base functions to use.</li>
577<li><strong>nr</strong> &#8211; number of r points to evaluate the 2nd derivative at
578for the reg. term.</li>
579</ul>
580</td>
581</tr>
582</tbody>
583</table>
584<p>If the result does not allow us to compute the covariance matrix,
585a matrix filled with zeros will be returned.</p>
586</dd></dl>
587
588<dl class="attribute">
589<dt id="sans.pr.invertor.Invertor.nfunc">
590<tt class="descname">nfunc</tt><em class="property"> = 10</em><a class="headerlink" href="#sans.pr.invertor.Invertor.nfunc" title="Permalink to this definition">¶</a></dt>
591<dd></dd></dl>
592
593<dl class="method">
594<dt id="sans.pr.invertor.Invertor.oscillations">
595<tt class="descname">oscillations</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.oscillations" title="Permalink to this definition">¶</a></dt>
596<dd><p>Returns the value of the oscillation figure of merit for
597the given set of coefficients. For a sphere, the oscillation
598figure of merit is 1.1.</p>
599<blockquote>
600<div>&#64;param args: c-parameters
601&#64;return: oscillation figure of merit</div></blockquote>
602</dd></dl>
603
604<dl class="attribute">
605<dt id="sans.pr.invertor.Invertor.out">
606<tt class="descname">out</tt><em class="property"> = None</em><a class="headerlink" href="#sans.pr.invertor.Invertor.out" title="Permalink to this definition">¶</a></dt>
607<dd></dd></dl>
608
609<dl class="method">
610<dt id="sans.pr.invertor.Invertor.pr">
611<tt class="descname">pr</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.pr" title="Permalink to this definition">¶</a></dt>
612<dd><p>Function to call to evaluate P(r)
613&#64;param args: c-parameters and r
614&#64;return: P(r)</p>
615</dd></dl>
616
617<dl class="method">
618<dt id="sans.pr.invertor.Invertor.pr_err">
619<tt class="descname">pr_err</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.pr_err" title="Permalink to this definition">¶</a></dt>
620<dd><p>Returns the value of P(r) for a given r, and base function
621coefficients, with error.</p>
622<table class="docutils field-list" frame="void" rules="none">
623<col class="field-name" />
624<col class="field-body" />
625<tbody valign="top">
626<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
627<li><strong>c</strong> &#8211; base function coefficients</li>
628<li><strong>c_cov</strong> &#8211; covariance matrice of the base function coefficients</li>
629<li><strong>r</strong> &#8211; r-value to evaluate P(r) at</li>
630</ul>
631</td>
632</tr>
633<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">P(r)</p>
634</td>
635</tr>
636</tbody>
637</table>
638</dd></dl>
639
640<dl class="method">
641<dt id="sans.pr.invertor.Invertor.pr_fit">
642<tt class="descname">pr_fit</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.pr_fit" title="Permalink to this definition">¶</a></dt>
643<dd><p>This is a direct fit to a given P(r). It assumes that the y data
644is set to some P(r) distribution that we are trying to reproduce
645with a set of base functions.</p>
646<p>This method is provided as a test.</p>
647</dd></dl>
648
649<dl class="method">
650<dt id="sans.pr.invertor.Invertor.pr_residuals">
651<tt class="descname">pr_residuals</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.pr_residuals" title="Permalink to this definition">¶</a></dt>
652<dd><p>Function to call to evaluate the residuals
653for P(r) minimization (for testing purposes)
654&#64;param args: input parameters
655&#64;return: list of residuals</p>
656</dd></dl>
657
658<dl class="method">
659<dt id="sans.pr.invertor.Invertor.residuals">
660<tt class="descname">residuals</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.residuals" title="Permalink to this definition">¶</a></dt>
661<dd><p>Function to call to evaluate the residuals
662for P(r) inversion
663&#64;param args: input parameters
664&#64;return: list of residuals</p>
665</dd></dl>
666
667<dl class="method">
668<dt id="sans.pr.invertor.Invertor.rg">
669<tt class="descname">rg</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.rg" title="Permalink to this definition">¶</a></dt>
670<dd><p>Returns the value of the radius of gyration Rg.
671&#64;param args: c-parameters
672&#64;return: Rg</p>
673</dd></dl>
674
675<dl class="method">
676<dt id="sans.pr.invertor.Invertor.set_alpha">
677<tt class="descname">set_alpha</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.set_alpha" title="Permalink to this definition">¶</a></dt>
678<dd><p>Sets the alpha parameter</p>
679</dd></dl>
680
681<dl class="method">
682<dt id="sans.pr.invertor.Invertor.set_dmax">
683<tt class="descname">set_dmax</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.set_dmax" title="Permalink to this definition">¶</a></dt>
684<dd><p>Sets the maximum distance</p>
685</dd></dl>
686
687<dl class="method">
688<dt id="sans.pr.invertor.Invertor.set_err">
689<tt class="descname">set_err</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.set_err" title="Permalink to this definition">¶</a></dt>
690<dd><p>Function to set the err data
691Takes an array of doubles as input.
692&#64;return: number of entries found</p>
693</dd></dl>
694
695<dl class="method">
696<dt id="sans.pr.invertor.Invertor.set_has_bck">
697<tt class="descname">set_has_bck</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.set_has_bck" title="Permalink to this definition">¶</a></dt>
698<dd><p>Sets background flag</p>
699</dd></dl>
700
701<dl class="method">
702<dt id="sans.pr.invertor.Invertor.set_qmax">
703<tt class="descname">set_qmax</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.set_qmax" title="Permalink to this definition">¶</a></dt>
704<dd><p>Sets the maximum q</p>
705</dd></dl>
706
707<dl class="method">
708<dt id="sans.pr.invertor.Invertor.set_qmin">
709<tt class="descname">set_qmin</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.set_qmin" title="Permalink to this definition">¶</a></dt>
710<dd><p>Sets the minimum q</p>
711</dd></dl>
712
713<dl class="method">
714<dt id="sans.pr.invertor.Invertor.set_slit_height">
715<tt class="descname">set_slit_height</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.set_slit_height" title="Permalink to this definition">¶</a></dt>
716<dd><p>Sets the slit height in units of q [A-1]</p>
717</dd></dl>
718
719<dl class="method">
720<dt id="sans.pr.invertor.Invertor.set_slit_width">
721<tt class="descname">set_slit_width</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.set_slit_width" title="Permalink to this definition">¶</a></dt>
722<dd><p>Sets the slit width in units of q [A-1]</p>
723</dd></dl>
724
725<dl class="method">
726<dt id="sans.pr.invertor.Invertor.set_x">
727<tt class="descname">set_x</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.set_x" title="Permalink to this definition">¶</a></dt>
728<dd><p>Function to set the x data
729Takes an array of doubles as input.
730&#64;return: number of entries found</p>
731</dd></dl>
732
733<dl class="method">
734<dt id="sans.pr.invertor.Invertor.set_y">
735<tt class="descname">set_y</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.set_y" title="Permalink to this definition">¶</a></dt>
736<dd><p>Function to set the y data
737Takes an array of doubles as input.
738&#64;return: number of entries found</p>
739</dd></dl>
740
741<dl class="attribute">
742<dt id="sans.pr.invertor.Invertor.suggested_alpha">
743<tt class="descname">suggested_alpha</tt><em class="property"> = 0</em><a class="headerlink" href="#sans.pr.invertor.Invertor.suggested_alpha" title="Permalink to this definition">¶</a></dt>
744<dd></dd></dl>
745
746<dl class="method">
747<dt id="sans.pr.invertor.Invertor.to_file">
748<tt class="descname">to_file</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.to_file" title="Permalink to this definition">¶</a></dt>
749<dd><p>Save the state to a file that will be readable
750by SliceView.</p>
751<table class="docutils field-list" frame="void" rules="none">
752<col class="field-name" />
753<col class="field-body" />
754<tbody valign="top">
755<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
756<li><strong>path</strong> &#8211; path of the file to write</li>
757<li><strong>npts</strong> &#8211; number of P(r) points to be written</li>
758</ul>
759</td>
760</tr>
761</tbody>
762</table>
763</dd></dl>
764
765</dd></dl>
766
767<dl class="function">
768<dt id="sans.pr.invertor.help">
769<tt class="descclassname">sans.pr.invertor.</tt><tt class="descname">help</tt><big>(</big><big>)</big><a class="headerlink" href="#sans.pr.invertor.help" title="Permalink to this definition">¶</a></dt>
770<dd><p>Provide general online help text
771Future work: extend this function to allow topic selection</p>
772</dd></dl>
773
774</div>
775</div>
776
777
778          </div>
779        </div>
780      </div>
781      <div class="sphinxsidebar">
782        <div class="sphinxsidebarwrapper">
783  <h3><a href="../index.html">Table Of Contents</a></h3>
784  <ul>
785<li><a class="reference internal" href="#">invertor</a><ul>
786<li><a class="reference internal" href="#sans-pr-invertor"><tt class="docutils literal"><span class="pre">sans.pr.invertor</span></tt></a></li>
787</ul>
788</li>
789</ul>
790
791  <h4>Previous topic</h4>
792  <p class="topless"><a href="distance_explorer.html"
793                        title="previous chapter">distance_explorer</a></p>
794  <h4>Next topic</h4>
795  <p class="topless"><a href="num_term.html"
796                        title="next chapter">num_term</a></p>
797  <h3>This Page</h3>
798  <ul class="this-page-menu">
799    <li><a href="../_sources/api/invertor.txt"
800           rel="nofollow">Show Source</a></li>
801  </ul>
802<div id="searchbox" style="display: none">
803  <h3>Quick search</h3>
804    <form class="search" action="../search.html" method="get">
805      <input type="text" name="q" />
806      <input type="submit" value="Go" />
807      <input type="hidden" name="check_keywords" value="yes" />
808      <input type="hidden" name="area" value="default" />
809    </form>
810    <p class="searchtip" style="font-size: 90%">
811    Enter search terms or a module, class or function name.
812    </p>
813</div>
814<script type="text/javascript">$('#searchbox').show(0);</script>
815        </div>
816      </div>
817      <div class="clearer"></div>
818    </div>
819    <div class="related">
820      <h3>Navigation</h3>
821      <ul>
822        <li class="right" style="margin-right: 10px">
823          <a href="../genindex.html" title="General Index"
824             >index</a></li>
825        <li class="right" >
826          <a href="../py-modindex.html" title="Python Module Index"
827             >modules</a> |</li>
828        <li class="right" >
829          <a href="num_term.html" title="num_term"
830             >next</a> |</li>
831        <li class="right" >
832          <a href="distance_explorer.html" title="distance_explorer"
833             >previous</a> |</li>
834        <li><a href="../index.html">pr_inversion 0.1.0 documentation</a> &raquo;</li>
835          <li><a href="index.html" >Reference</a> &raquo;</li> 
836      </ul>
837    </div>
838    <div class="footer">
839        &copy; Copyright 2010, sans group.
840      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.
841    </div>
842  </body>
843</html>
Note: See TracBrowser for help on using the repository browser.