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 | <html xmlns="http://www.w3.org/1999/xhtml"> |
---|
7 | <head> |
---|
8 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
---|
9 | |
---|
10 | <title>invertor — pr_inversion v0.1.0 documentation</title> |
---|
11 | <link rel="stylesheet" href="../_static/default.css" type="text/css" /> |
---|
12 | <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> |
---|
13 | <script type="text/javascript"> |
---|
14 | var DOCUMENTATION_OPTIONS = { |
---|
15 | URL_ROOT: '../', |
---|
16 | VERSION: '0.1.0', |
---|
17 | COLLAPSE_INDEX: false, |
---|
18 | FILE_SUFFIX: '.html', |
---|
19 | HAS_SOURCE: true |
---|
20 | }; |
---|
21 | </script> |
---|
22 | <script type="text/javascript" src="../_static/jquery.js"></script> |
---|
23 | <script type="text/javascript" src="../_static/underscore.js"></script> |
---|
24 | <script type="text/javascript" src="../_static/doctools.js"></script> |
---|
25 | <link rel="top" title="pr_inversion v0.1.0 documentation" href="../index.html" /> |
---|
26 | <link rel="up" title="Reference" href="index.html" /> |
---|
27 | <link rel="next" title="num_term" href="num_term.html" /> |
---|
28 | <link rel="prev" title="distance_explorer" href="distance_explorer.html" /> |
---|
29 | </head> |
---|
30 | <body> |
---|
31 | <div class="related"> |
---|
32 | <h3>Navigation</h3> |
---|
33 | <ul> |
---|
34 | <li class="right" style="margin-right: 10px"> |
---|
35 | <a href="../genindex.html" title="General Index" |
---|
36 | accesskey="I">index</a></li> |
---|
37 | <li class="right" > |
---|
38 | <a href="../py-modindex.html" title="Python Module Index" |
---|
39 | >modules</a> |</li> |
---|
40 | <li class="right" > |
---|
41 | <a href="num_term.html" title="num_term" |
---|
42 | accesskey="N">next</a> |</li> |
---|
43 | <li class="right" > |
---|
44 | <a href="distance_explorer.html" title="distance_explorer" |
---|
45 | accesskey="P">previous</a> |</li> |
---|
46 | <li><a href="../index.html">pr_inversion v0.1.0 documentation</a> »</li> |
---|
47 | <li><a href="index.html" accesskey="U">Reference</a> »</li> |
---|
48 | </ul> |
---|
49 | </div> |
---|
50 | |
---|
51 | <div class="document"> |
---|
52 | <div class="documentwrapper"> |
---|
53 | <div class="bodywrapper"> |
---|
54 | <div class="body"> |
---|
55 | |
---|
56 | <div class="section" id="invertor"> |
---|
57 | <h1>invertor<a class="headerlink" href="#invertor" title="Permalink to this headline">¶</a></h1> |
---|
58 | <div class="section" id="module-sans.pr.invertor"> |
---|
59 | <span id="sans-pr-invertor"></span><h2><a class="reference internal" href="#module-sans.pr.invertor"><tt class="xref py py-mod docutils literal"><span class="pre">sans.pr.invertor</span></tt></a><a class="headerlink" href="#module-sans.pr.invertor" title="Permalink to this headline">¶</a></h2> |
---|
60 | <p>Module to perform P(r) inversion. |
---|
61 | The module contains the Invertor class.</p> |
---|
62 | <dl class="class"> |
---|
63 | <dt id="sans.pr.invertor.Invertor"> |
---|
64 | <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> |
---|
65 | <dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">Cinvertor</span></tt></p> |
---|
66 | <p>Invertor class to perform P(r) inversion</p> |
---|
67 | <p>The problem is solved by posing the problem as Ax = b, |
---|
68 | where x is the set of coefficients we are looking for.</p> |
---|
69 | <p>Npts is the number of points.</p> |
---|
70 | <p>In the following i refers to the ith base function coefficient. |
---|
71 | The matrix has its entries j in its first Npts rows set to</p> |
---|
72 | <blockquote> |
---|
73 | A[j][i] = (Fourier transformed base function for point j)</blockquote> |
---|
74 | <p>We them choose a number of r-points, n_r, to evaluate the second |
---|
75 | derivative of P(r) at. This is used as our regularization term. |
---|
76 | For a vector r of length n_r, the following n_r rows are set to</p> |
---|
77 | <blockquote> |
---|
78 | A[j+Npts][i] = (2nd derivative of P(r), d**2(P(r))/d(r)**2, evaluated at r[j])</blockquote> |
---|
79 | <dl class="docutils"> |
---|
80 | <dt>The vector b has its first Npts entries set to</dt> |
---|
81 | <dd>b[j] = (I(q) observed for point j)</dd> |
---|
82 | </dl> |
---|
83 | <p>The following n_r entries are set to zero.</p> |
---|
84 | <p>The result is found by using scipy.linalg.basic.lstsq to invert |
---|
85 | the matrix and find the coefficients x.</p> |
---|
86 | <p>Methods inherited from Cinvertor: |
---|
87 | - get_peaks(pars): returns the number of P(r) peaks |
---|
88 | - oscillations(pars): returns the oscillation parameters for the output P(r) |
---|
89 | - get_positive(pars): returns the fraction of P(r) that is above zero |
---|
90 | - get_pos_err(pars): returns the fraction of P(r) that is 1-sigma above zero</p> |
---|
91 | <dl class="attribute"> |
---|
92 | <dt id="sans.pr.invertor.Invertor.basefunc_ft"> |
---|
93 | <tt class="descname">basefunc_ft</tt><a class="headerlink" href="#sans.pr.invertor.Invertor.basefunc_ft" title="Permalink to this definition">¶</a></dt> |
---|
94 | <dd>Returns the value of the nth Fourier transofrmed base function |
---|
95 | @param args: c-parameters, n and q |
---|
96 | @return: nth Fourier transformed base function, evaluated at q</dd></dl> |
---|
97 | |
---|
98 | <dl class="method"> |
---|
99 | <dt id="sans.pr.invertor.Invertor.clone"> |
---|
100 | <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> |
---|
101 | <dd>Return a clone of this instance</dd></dl> |
---|
102 | |
---|
103 | <dl class="method"> |
---|
104 | <dt id="sans.pr.invertor.Invertor.estimate_alpha"> |
---|
105 | <tt class="descname">estimate_alpha</tt><big>(</big><em>nfunc</em><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.estimate_alpha" title="Permalink to this definition">¶</a></dt> |
---|
106 | <dd><p>Returns a reasonable guess for the |
---|
107 | regularization constant alpha</p> |
---|
108 | <table class="docutils field-list" frame="void" rules="none"> |
---|
109 | <col class="field-name" /> |
---|
110 | <col class="field-body" /> |
---|
111 | <tbody valign="top"> |
---|
112 | <tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> |
---|
113 | <li><strong>nfunc</strong> – number of terms to use in the expansion.</li> |
---|
114 | </ul> |
---|
115 | </td> |
---|
116 | </tr> |
---|
117 | <tr class="field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">alpha, message, elapsed</p> |
---|
118 | </td> |
---|
119 | </tr> |
---|
120 | </tbody> |
---|
121 | </table> |
---|
122 | <p>where alpha is the estimate for alpha, |
---|
123 | message is a message for the user, |
---|
124 | elapsed is the computation time</p> |
---|
125 | </dd></dl> |
---|
126 | |
---|
127 | <dl class="method"> |
---|
128 | <dt id="sans.pr.invertor.Invertor.estimate_numterms"> |
---|
129 | <tt class="descname">estimate_numterms</tt><big>(</big><em>isquit_func=None</em><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.estimate_numterms" title="Permalink to this definition">¶</a></dt> |
---|
130 | <dd><p>Returns a reasonable guess for the |
---|
131 | number of terms</p> |
---|
132 | <table class="docutils field-list" frame="void" rules="none"> |
---|
133 | <col class="field-name" /> |
---|
134 | <col class="field-body" /> |
---|
135 | <tbody valign="top"> |
---|
136 | <tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> |
---|
137 | <li><strong>isquit_func</strong> – reference to thread function to call to |
---|
138 | check whether the computation needs to |
---|
139 | be stopped.</li> |
---|
140 | </ul> |
---|
141 | </td> |
---|
142 | </tr> |
---|
143 | <tr class="field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">number of terms, alpha, message</p> |
---|
144 | </td> |
---|
145 | </tr> |
---|
146 | </tbody> |
---|
147 | </table> |
---|
148 | </dd></dl> |
---|
149 | |
---|
150 | <dl class="method"> |
---|
151 | <dt id="sans.pr.invertor.Invertor.from_file"> |
---|
152 | <tt class="descname">from_file</tt><big>(</big><em>path</em><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.from_file" title="Permalink to this definition">¶</a></dt> |
---|
153 | <dd><p>Load the state of the Invertor from a file, |
---|
154 | to be able to generate P(r) from a set of |
---|
155 | parameters.</p> |
---|
156 | <table class="docutils field-list" frame="void" rules="none"> |
---|
157 | <col class="field-name" /> |
---|
158 | <col class="field-body" /> |
---|
159 | <tbody valign="top"> |
---|
160 | <tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple"> |
---|
161 | <li><strong>path</strong> – path of the file to load</li> |
---|
162 | </ul> |
---|
163 | </td> |
---|
164 | </tr> |
---|
165 | </tbody> |
---|
166 | </table> |
---|
167 | </dd></dl> |
---|
168 | |
---|
169 | <dl class="attribute"> |
---|
170 | <dt id="sans.pr.invertor.Invertor.get_alpha"> |
---|
171 | <tt class="descname">get_alpha</tt><a class="headerlink" href="#sans.pr.invertor.Invertor.get_alpha" title="Permalink to this definition">¶</a></dt> |
---|
172 | <dd>Gets the alpha parameter</dd></dl> |
---|
173 | |
---|
174 | <dl class="attribute"> |
---|
175 | <dt id="sans.pr.invertor.Invertor.get_dmax"> |
---|
176 | <tt class="descname">get_dmax</tt><a class="headerlink" href="#sans.pr.invertor.Invertor.get_dmax" title="Permalink to this definition">¶</a></dt> |
---|
177 | <dd>Gets the maximum distance</dd></dl> |
---|
178 | |
---|
179 | <dl class="attribute"> |
---|
180 | <dt id="sans.pr.invertor.Invertor.get_err"> |
---|
181 | <tt class="descname">get_err</tt><a class="headerlink" href="#sans.pr.invertor.Invertor.get_err" title="Permalink to this definition">¶</a></dt> |
---|
182 | <dd><p>Function to get the err data |
---|
183 | Takes an array of doubles as input.</p> |
---|
184 | <blockquote> |
---|
185 | @return: number of entries found</blockquote> |
---|
186 | </dd></dl> |
---|
187 | |
---|
188 | <dl class="attribute"> |
---|
189 | <dt id="sans.pr.invertor.Invertor.get_has_bck"> |
---|
190 | <tt class="descname">get_has_bck</tt><a class="headerlink" href="#sans.pr.invertor.Invertor.get_has_bck" title="Permalink to this definition">¶</a></dt> |
---|
191 | <dd>Gets background flag</dd></dl> |
---|
192 | |
---|
193 | <dl class="attribute"> |
---|
194 | <dt id="sans.pr.invertor.Invertor.get_nerr"> |
---|
195 | <tt class="descname">get_nerr</tt><a class="headerlink" href="#sans.pr.invertor.Invertor.get_nerr" title="Permalink to this definition">¶</a></dt> |
---|
196 | <dd>Gets the number of err points</dd></dl> |
---|
197 | |
---|
198 | <dl class="attribute"> |
---|
199 | <dt id="sans.pr.invertor.Invertor.get_nx"> |
---|
200 | <tt class="descname">get_nx</tt><a class="headerlink" href="#sans.pr.invertor.Invertor.get_nx" title="Permalink to this definition">¶</a></dt> |
---|
201 | <dd>Gets the number of x points</dd></dl> |
---|
202 | |
---|
203 | <dl class="attribute"> |
---|
204 | <dt id="sans.pr.invertor.Invertor.get_ny"> |
---|
205 | <tt class="descname">get_ny</tt><a class="headerlink" href="#sans.pr.invertor.Invertor.get_ny" title="Permalink to this definition">¶</a></dt> |
---|
206 | <dd>Gets the number of y points</dd></dl> |
---|
207 | |
---|
208 | <dl class="attribute"> |
---|
209 | <dt id="sans.pr.invertor.Invertor.get_peaks"> |
---|
210 | <tt class="descname">get_peaks</tt><a class="headerlink" href="#sans.pr.invertor.Invertor.get_peaks" title="Permalink to this definition">¶</a></dt> |
---|
211 | <dd><p>Returns the number of peaks in the output P(r) distrubution |
---|
212 | for the given set of coefficients.</p> |
---|
213 | <blockquote> |
---|
214 | @param args: c-parameters |
---|
215 | @return: number of P(r) peaks</blockquote> |
---|
216 | </dd></dl> |
---|
217 | |
---|
218 | <dl class="attribute"> |
---|
219 | <dt id="sans.pr.invertor.Invertor.get_pos_err"> |
---|
220 | <tt class="descname">get_pos_err</tt><a class="headerlink" href="#sans.pr.invertor.Invertor.get_pos_err" title="Permalink to this definition">¶</a></dt> |
---|
221 | <dd><p>Returns the fraction of P(r) that is 1 standard deviation |
---|
222 | above zero over the full range of r for the given set of coefficients.</p> |
---|
223 | <blockquote> |
---|
224 | @param args: c-parameters |
---|
225 | @return: fraction of P(r) that is positive</blockquote> |
---|
226 | </dd></dl> |
---|
227 | |
---|
228 | <dl class="attribute"> |
---|
229 | <dt id="sans.pr.invertor.Invertor.get_positive"> |
---|
230 | <tt class="descname">get_positive</tt><a class="headerlink" href="#sans.pr.invertor.Invertor.get_positive" title="Permalink to this definition">¶</a></dt> |
---|
231 | <dd><p>Returns the fraction of P(r) that is positive over |
---|
232 | the full range of r for the given set of coefficients.</p> |
---|
233 | <blockquote> |
---|
234 | @param args: c-parameters |
---|
235 | @return: fraction of P(r) that is positive</blockquote> |
---|
236 | </dd></dl> |
---|
237 | |
---|
238 | <dl class="attribute"> |
---|
239 | <dt id="sans.pr.invertor.Invertor.get_pr_err"> |
---|
240 | <tt class="descname">get_pr_err</tt><a class="headerlink" href="#sans.pr.invertor.Invertor.get_pr_err" title="Permalink to this definition">¶</a></dt> |
---|
241 | <dd>Function to call to evaluate P(r) with errors |
---|
242 | @param args: c-parameters and r |
---|
243 | @return: (P(r),dP(r))</dd></dl> |
---|
244 | |
---|
245 | <dl class="attribute"> |
---|
246 | <dt id="sans.pr.invertor.Invertor.get_qmax"> |
---|
247 | <tt class="descname">get_qmax</tt><a class="headerlink" href="#sans.pr.invertor.Invertor.get_qmax" title="Permalink to this definition">¶</a></dt> |
---|
248 | <dd>Gets the maximum q</dd></dl> |
---|
249 | |
---|
250 | <dl class="attribute"> |
---|
251 | <dt id="sans.pr.invertor.Invertor.get_qmin"> |
---|
252 | <tt class="descname">get_qmin</tt><a class="headerlink" href="#sans.pr.invertor.Invertor.get_qmin" title="Permalink to this definition">¶</a></dt> |
---|
253 | <dd>Gets the minimum q</dd></dl> |
---|
254 | |
---|
255 | <dl class="attribute"> |
---|
256 | <dt id="sans.pr.invertor.Invertor.get_slit_height"> |
---|
257 | <tt class="descname">get_slit_height</tt><a class="headerlink" href="#sans.pr.invertor.Invertor.get_slit_height" title="Permalink to this definition">¶</a></dt> |
---|
258 | <dd>Gets the slit height</dd></dl> |
---|
259 | |
---|
260 | <dl class="attribute"> |
---|
261 | <dt id="sans.pr.invertor.Invertor.get_slit_width"> |
---|
262 | <tt class="descname">get_slit_width</tt><a class="headerlink" href="#sans.pr.invertor.Invertor.get_slit_width" title="Permalink to this definition">¶</a></dt> |
---|
263 | <dd>Gets the slit width</dd></dl> |
---|
264 | |
---|
265 | <dl class="attribute"> |
---|
266 | <dt id="sans.pr.invertor.Invertor.get_x"> |
---|
267 | <tt class="descname">get_x</tt><a class="headerlink" href="#sans.pr.invertor.Invertor.get_x" title="Permalink to this definition">¶</a></dt> |
---|
268 | <dd><p>Function to get the x data |
---|
269 | Takes an array of doubles as input.</p> |
---|
270 | <blockquote> |
---|
271 | @return: number of entries found</blockquote> |
---|
272 | </dd></dl> |
---|
273 | |
---|
274 | <dl class="attribute"> |
---|
275 | <dt id="sans.pr.invertor.Invertor.get_y"> |
---|
276 | <tt class="descname">get_y</tt><a class="headerlink" href="#sans.pr.invertor.Invertor.get_y" title="Permalink to this definition">¶</a></dt> |
---|
277 | <dd><p>Function to get the y data |
---|
278 | Takes an array of doubles as input.</p> |
---|
279 | <blockquote> |
---|
280 | @return: number of entries found</blockquote> |
---|
281 | </dd></dl> |
---|
282 | |
---|
283 | <dl class="method"> |
---|
284 | <dt id="sans.pr.invertor.Invertor.invert"> |
---|
285 | <tt class="descname">invert</tt><big>(</big><em>nfunc=10</em>, <em>nr=20</em><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.invert" title="Permalink to this definition">¶</a></dt> |
---|
286 | <dd><p>Perform inversion to P(r)</p> |
---|
287 | <p>The problem is solved by posing the problem as Ax = b, |
---|
288 | where x is the set of coefficients we are looking for.</p> |
---|
289 | <p>Npts is the number of points.</p> |
---|
290 | <p>In the following i refers to the ith base function coefficient. |
---|
291 | The matrix has its entries j in its first Npts rows set to</p> |
---|
292 | <blockquote> |
---|
293 | A[i][j] = (Fourier transformed base function for point j)</blockquote> |
---|
294 | <p>We them choose a number of r-points, n_r, to evaluate the second |
---|
295 | derivative of P(r) at. This is used as our regularization term. |
---|
296 | For a vector r of length n_r, the following n_r rows are set to</p> |
---|
297 | <blockquote> |
---|
298 | A[i+Npts][j] = (2nd derivative of P(r), d**2(P(r))/d(r)**2, evaluated at r[j])</blockquote> |
---|
299 | <dl class="docutils"> |
---|
300 | <dt>The vector b has its first Npts entries set to</dt> |
---|
301 | <dd>b[j] = (I(q) observed for point j)</dd> |
---|
302 | </dl> |
---|
303 | <p>The following n_r entries are set to zero.</p> |
---|
304 | <p>The result is found by using scipy.linalg.basic.lstsq to invert |
---|
305 | the matrix and find the coefficients x.</p> |
---|
306 | <table class="docutils field-list" frame="void" rules="none"> |
---|
307 | <col class="field-name" /> |
---|
308 | <col class="field-body" /> |
---|
309 | <tbody valign="top"> |
---|
310 | <tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> |
---|
311 | <li><strong>nfunc</strong> – number of base functions to use.</li> |
---|
312 | <li><strong>nr</strong> – number of r points to evaluate the 2nd derivative at for the reg. term.</li> |
---|
313 | </ul> |
---|
314 | </td> |
---|
315 | </tr> |
---|
316 | <tr class="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> |
---|
317 | </td> |
---|
318 | </tr> |
---|
319 | </tbody> |
---|
320 | </table> |
---|
321 | </dd></dl> |
---|
322 | |
---|
323 | <dl class="method"> |
---|
324 | <dt id="sans.pr.invertor.Invertor.invert_optimize"> |
---|
325 | <tt class="descname">invert_optimize</tt><big>(</big><em>nfunc=10</em>, <em>nr=20</em><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.invert_optimize" title="Permalink to this definition">¶</a></dt> |
---|
326 | <dd><p>Slower version of the P(r) inversion that uses scipy.optimize.leastsq.</p> |
---|
327 | <p>This probably produce more reliable results, but is much slower. |
---|
328 | The minimization function is set to sum_i[ (I_obs(q_i) - I_theo(q_i))/err**2 ] + alpha * reg_term, |
---|
329 | where the reg_term is given by Svergun: it is the integral of the square of the first derivative |
---|
330 | of P(r), d(P(r))/dr, integrated over the full range of r.</p> |
---|
331 | <table class="docutils field-list" frame="void" rules="none"> |
---|
332 | <col class="field-name" /> |
---|
333 | <col class="field-body" /> |
---|
334 | <tbody valign="top"> |
---|
335 | <tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> |
---|
336 | <li><strong>nfunc</strong> – number of base functions to use.</li> |
---|
337 | <li><strong>nr</strong> – number of r points to evaluate the 2nd derivative at for the reg. term.</li> |
---|
338 | </ul> |
---|
339 | </td> |
---|
340 | </tr> |
---|
341 | <tr class="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> |
---|
342 | </td> |
---|
343 | </tr> |
---|
344 | </tbody> |
---|
345 | </table> |
---|
346 | </dd></dl> |
---|
347 | |
---|
348 | <dl class="method"> |
---|
349 | <dt id="sans.pr.invertor.Invertor.iq"> |
---|
350 | <tt class="descname">iq</tt><big>(</big><em>out</em>, <em>q</em><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.iq" title="Permalink to this definition">¶</a></dt> |
---|
351 | <dd><p>Function to call to evaluate the scattering intensity</p> |
---|
352 | <table class="docutils field-list" frame="void" rules="none"> |
---|
353 | <col class="field-name" /> |
---|
354 | <col class="field-body" /> |
---|
355 | <tbody valign="top"> |
---|
356 | <tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> |
---|
357 | <li><strong>args</strong> – c-parameters, and q</li> |
---|
358 | </ul> |
---|
359 | </td> |
---|
360 | </tr> |
---|
361 | <tr class="field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">I(q)</p> |
---|
362 | </td> |
---|
363 | </tr> |
---|
364 | </tbody> |
---|
365 | </table> |
---|
366 | </dd></dl> |
---|
367 | |
---|
368 | <dl class="attribute"> |
---|
369 | <dt id="sans.pr.invertor.Invertor.iq0"> |
---|
370 | <tt class="descname">iq0</tt><a class="headerlink" href="#sans.pr.invertor.Invertor.iq0" title="Permalink to this definition">¶</a></dt> |
---|
371 | <dd>Returns the value of I(q=0). |
---|
372 | @param args: c-parameters |
---|
373 | @return: I(q=0)</dd></dl> |
---|
374 | |
---|
375 | <dl class="attribute"> |
---|
376 | <dt id="sans.pr.invertor.Invertor.iq_smeared"> |
---|
377 | <tt class="descname">iq_smeared</tt><a class="headerlink" href="#sans.pr.invertor.Invertor.iq_smeared" title="Permalink to this definition">¶</a></dt> |
---|
378 | <dd><p>Function to call to evaluate the scattering intensity. |
---|
379 | The scattering intensity is slit-smeared. @param args: c-parameters, and q</p> |
---|
380 | <blockquote> |
---|
381 | @return: I(q)</blockquote> |
---|
382 | </dd></dl> |
---|
383 | |
---|
384 | <dl class="attribute"> |
---|
385 | <dt id="sans.pr.invertor.Invertor.is_valid"> |
---|
386 | <tt class="descname">is_valid</tt><a class="headerlink" href="#sans.pr.invertor.Invertor.is_valid" title="Permalink to this definition">¶</a></dt> |
---|
387 | <dd>Check the validity of the stored data |
---|
388 | @return: Returns the number of points if it’s all good, -1 otherwise</dd></dl> |
---|
389 | |
---|
390 | <dl class="method"> |
---|
391 | <dt id="sans.pr.invertor.Invertor.lstsq"> |
---|
392 | <tt class="descname">lstsq</tt><big>(</big><em>nfunc=5</em>, <em>nr=20</em><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.lstsq" title="Permalink to this definition">¶</a></dt> |
---|
393 | <dd><p>The problem is solved by posing the problem as Ax = b, |
---|
394 | where x is the set of coefficients we are looking for.</p> |
---|
395 | <p>Npts is the number of points.</p> |
---|
396 | <p>In the following i refers to the ith base function coefficient. |
---|
397 | The matrix has its entries j in its first Npts rows set to</p> |
---|
398 | <blockquote> |
---|
399 | A[i][j] = (Fourier transformed base function for point j)</blockquote> |
---|
400 | <p>We them choose a number of r-points, n_r, to evaluate the second |
---|
401 | derivative of P(r) at. This is used as our regularization term. |
---|
402 | For a vector r of length n_r, the following n_r rows are set to</p> |
---|
403 | <blockquote> |
---|
404 | A[i+Npts][j] = (2nd derivative of P(r), d**2(P(r))/d(r)**2, evaluated at r[j])</blockquote> |
---|
405 | <dl class="docutils"> |
---|
406 | <dt>The vector b has its first Npts entries set to</dt> |
---|
407 | <dd>b[j] = (I(q) observed for point j)</dd> |
---|
408 | </dl> |
---|
409 | <p>The following n_r entries are set to zero.</p> |
---|
410 | <p>The result is found by using scipy.linalg.basic.lstsq to invert |
---|
411 | the matrix and find the coefficients x.</p> |
---|
412 | <table class="docutils field-list" frame="void" rules="none"> |
---|
413 | <col class="field-name" /> |
---|
414 | <col class="field-body" /> |
---|
415 | <tbody valign="top"> |
---|
416 | <tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple"> |
---|
417 | <li><strong>nfunc</strong> – number of base functions to use.</li> |
---|
418 | <li><strong>nr</strong> – number of r points to evaluate the 2nd derivative at for the reg. term.</li> |
---|
419 | </ul> |
---|
420 | </td> |
---|
421 | </tr> |
---|
422 | </tbody> |
---|
423 | </table> |
---|
424 | <p>If the result does not allow us to compute the covariance matrix, |
---|
425 | a matrix filled with zeros will be returned.</p> |
---|
426 | </dd></dl> |
---|
427 | |
---|
428 | <dl class="attribute"> |
---|
429 | <dt id="sans.pr.invertor.Invertor.oscillations"> |
---|
430 | <tt class="descname">oscillations</tt><a class="headerlink" href="#sans.pr.invertor.Invertor.oscillations" title="Permalink to this definition">¶</a></dt> |
---|
431 | <dd><p>Returns the value of the oscillation figure of merit for |
---|
432 | the given set of coefficients. For a sphere, the oscillation |
---|
433 | figure of merit is 1.1.</p> |
---|
434 | <blockquote> |
---|
435 | @param args: c-parameters |
---|
436 | @return: oscillation figure of merit</blockquote> |
---|
437 | </dd></dl> |
---|
438 | |
---|
439 | <dl class="attribute"> |
---|
440 | <dt id="sans.pr.invertor.Invertor.pr"> |
---|
441 | <tt class="descname">pr</tt><a class="headerlink" href="#sans.pr.invertor.Invertor.pr" title="Permalink to this definition">¶</a></dt> |
---|
442 | <dd>Function to call to evaluate P(r) |
---|
443 | @param args: c-parameters and r |
---|
444 | @return: P(r)</dd></dl> |
---|
445 | |
---|
446 | <dl class="method"> |
---|
447 | <dt id="sans.pr.invertor.Invertor.pr_err"> |
---|
448 | <tt class="descname">pr_err</tt><big>(</big><em>c</em>, <em>c_cov</em>, <em>r</em><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.pr_err" title="Permalink to this definition">¶</a></dt> |
---|
449 | <dd><p>Returns the value of P(r) for a given r, and base function |
---|
450 | coefficients, with error.</p> |
---|
451 | <table class="docutils field-list" frame="void" rules="none"> |
---|
452 | <col class="field-name" /> |
---|
453 | <col class="field-body" /> |
---|
454 | <tbody valign="top"> |
---|
455 | <tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> |
---|
456 | <li><strong>c</strong> – base function coefficients</li> |
---|
457 | <li><strong>c_cov</strong> – covariance matrice of the base function coefficients</li> |
---|
458 | <li><strong>r</strong> – r-value to evaluate P(r) at</li> |
---|
459 | </ul> |
---|
460 | </td> |
---|
461 | </tr> |
---|
462 | <tr class="field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">P(r)</p> |
---|
463 | </td> |
---|
464 | </tr> |
---|
465 | </tbody> |
---|
466 | </table> |
---|
467 | </dd></dl> |
---|
468 | |
---|
469 | <dl class="method"> |
---|
470 | <dt id="sans.pr.invertor.Invertor.pr_fit"> |
---|
471 | <tt class="descname">pr_fit</tt><big>(</big><em>nfunc=5</em><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.pr_fit" title="Permalink to this definition">¶</a></dt> |
---|
472 | <dd><p>This is a direct fit to a given P(r). It assumes that the y data |
---|
473 | is set to some P(r) distribution that we are trying to reproduce |
---|
474 | with a set of base functions.</p> |
---|
475 | <p>This method is provided as a test.</p> |
---|
476 | </dd></dl> |
---|
477 | |
---|
478 | <dl class="attribute"> |
---|
479 | <dt id="sans.pr.invertor.Invertor.pr_residuals"> |
---|
480 | <tt class="descname">pr_residuals</tt><a class="headerlink" href="#sans.pr.invertor.Invertor.pr_residuals" title="Permalink to this definition">¶</a></dt> |
---|
481 | <dd><p>Function to call to evaluate the residuals |
---|
482 | for P(r) minimization (for testing purposes)</p> |
---|
483 | <blockquote> |
---|
484 | @param args: input parameters |
---|
485 | @return: list of residuals</blockquote> |
---|
486 | </dd></dl> |
---|
487 | |
---|
488 | <dl class="attribute"> |
---|
489 | <dt id="sans.pr.invertor.Invertor.residuals"> |
---|
490 | <tt class="descname">residuals</tt><a class="headerlink" href="#sans.pr.invertor.Invertor.residuals" title="Permalink to this definition">¶</a></dt> |
---|
491 | <dd><p>Function to call to evaluate the residuals |
---|
492 | for P(r) inversion</p> |
---|
493 | <blockquote> |
---|
494 | @param args: input parameters |
---|
495 | @return: list of residuals</blockquote> |
---|
496 | </dd></dl> |
---|
497 | |
---|
498 | <dl class="attribute"> |
---|
499 | <dt id="sans.pr.invertor.Invertor.rg"> |
---|
500 | <tt class="descname">rg</tt><a class="headerlink" href="#sans.pr.invertor.Invertor.rg" title="Permalink to this definition">¶</a></dt> |
---|
501 | <dd>Returns the value of the radius of gyration Rg. |
---|
502 | @param args: c-parameters |
---|
503 | @return: Rg</dd></dl> |
---|
504 | |
---|
505 | <dl class="attribute"> |
---|
506 | <dt id="sans.pr.invertor.Invertor.set_alpha"> |
---|
507 | <tt class="descname">set_alpha</tt><a class="headerlink" href="#sans.pr.invertor.Invertor.set_alpha" title="Permalink to this definition">¶</a></dt> |
---|
508 | <dd>Sets the alpha parameter</dd></dl> |
---|
509 | |
---|
510 | <dl class="attribute"> |
---|
511 | <dt id="sans.pr.invertor.Invertor.set_dmax"> |
---|
512 | <tt class="descname">set_dmax</tt><a class="headerlink" href="#sans.pr.invertor.Invertor.set_dmax" title="Permalink to this definition">¶</a></dt> |
---|
513 | <dd>Sets the maximum distance</dd></dl> |
---|
514 | |
---|
515 | <dl class="attribute"> |
---|
516 | <dt id="sans.pr.invertor.Invertor.set_err"> |
---|
517 | <tt class="descname">set_err</tt><a class="headerlink" href="#sans.pr.invertor.Invertor.set_err" title="Permalink to this definition">¶</a></dt> |
---|
518 | <dd><p>Function to set the err data |
---|
519 | Takes an array of doubles as input.</p> |
---|
520 | <blockquote> |
---|
521 | @return: number of entries found</blockquote> |
---|
522 | </dd></dl> |
---|
523 | |
---|
524 | <dl class="attribute"> |
---|
525 | <dt id="sans.pr.invertor.Invertor.set_has_bck"> |
---|
526 | <tt class="descname">set_has_bck</tt><a class="headerlink" href="#sans.pr.invertor.Invertor.set_has_bck" title="Permalink to this definition">¶</a></dt> |
---|
527 | <dd>Sets background flag</dd></dl> |
---|
528 | |
---|
529 | <dl class="attribute"> |
---|
530 | <dt id="sans.pr.invertor.Invertor.set_qmax"> |
---|
531 | <tt class="descname">set_qmax</tt><a class="headerlink" href="#sans.pr.invertor.Invertor.set_qmax" title="Permalink to this definition">¶</a></dt> |
---|
532 | <dd>Sets the maximum q</dd></dl> |
---|
533 | |
---|
534 | <dl class="attribute"> |
---|
535 | <dt id="sans.pr.invertor.Invertor.set_qmin"> |
---|
536 | <tt class="descname">set_qmin</tt><a class="headerlink" href="#sans.pr.invertor.Invertor.set_qmin" title="Permalink to this definition">¶</a></dt> |
---|
537 | <dd>Sets the minimum q</dd></dl> |
---|
538 | |
---|
539 | <dl class="attribute"> |
---|
540 | <dt id="sans.pr.invertor.Invertor.set_slit_height"> |
---|
541 | <tt class="descname">set_slit_height</tt><a class="headerlink" href="#sans.pr.invertor.Invertor.set_slit_height" title="Permalink to this definition">¶</a></dt> |
---|
542 | <dd>Sets the slit height in units of q [A-1]</dd></dl> |
---|
543 | |
---|
544 | <dl class="attribute"> |
---|
545 | <dt id="sans.pr.invertor.Invertor.set_slit_width"> |
---|
546 | <tt class="descname">set_slit_width</tt><a class="headerlink" href="#sans.pr.invertor.Invertor.set_slit_width" title="Permalink to this definition">¶</a></dt> |
---|
547 | <dd>Sets the slit width in units of q [A-1]</dd></dl> |
---|
548 | |
---|
549 | <dl class="attribute"> |
---|
550 | <dt id="sans.pr.invertor.Invertor.set_x"> |
---|
551 | <tt class="descname">set_x</tt><a class="headerlink" href="#sans.pr.invertor.Invertor.set_x" title="Permalink to this definition">¶</a></dt> |
---|
552 | <dd><p>Function to set the x data |
---|
553 | Takes an array of doubles as input.</p> |
---|
554 | <blockquote> |
---|
555 | @return: number of entries found</blockquote> |
---|
556 | </dd></dl> |
---|
557 | |
---|
558 | <dl class="attribute"> |
---|
559 | <dt id="sans.pr.invertor.Invertor.set_y"> |
---|
560 | <tt class="descname">set_y</tt><a class="headerlink" href="#sans.pr.invertor.Invertor.set_y" title="Permalink to this definition">¶</a></dt> |
---|
561 | <dd><p>Function to set the y data |
---|
562 | Takes an array of doubles as input.</p> |
---|
563 | <blockquote> |
---|
564 | @return: number of entries found</blockquote> |
---|
565 | </dd></dl> |
---|
566 | |
---|
567 | <dl class="method"> |
---|
568 | <dt id="sans.pr.invertor.Invertor.to_file"> |
---|
569 | <tt class="descname">to_file</tt><big>(</big><em>path</em>, <em>npts=100</em><big>)</big><a class="headerlink" href="#sans.pr.invertor.Invertor.to_file" title="Permalink to this definition">¶</a></dt> |
---|
570 | <dd><p>Save the state to a file that will be readable |
---|
571 | by SliceView.</p> |
---|
572 | <table class="docutils field-list" frame="void" rules="none"> |
---|
573 | <col class="field-name" /> |
---|
574 | <col class="field-body" /> |
---|
575 | <tbody valign="top"> |
---|
576 | <tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple"> |
---|
577 | <li><strong>path</strong> – path of the file to write</li> |
---|
578 | <li><strong>npts</strong> – number of P(r) points to be written</li> |
---|
579 | </ul> |
---|
580 | </td> |
---|
581 | </tr> |
---|
582 | </tbody> |
---|
583 | </table> |
---|
584 | </dd></dl> |
---|
585 | |
---|
586 | </dd></dl> |
---|
587 | |
---|
588 | <dl class="function"> |
---|
589 | <dt id="sans.pr.invertor.help"> |
---|
590 | <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> |
---|
591 | <dd>Provide general online help text |
---|
592 | Future work: extend this function to allow topic selection</dd></dl> |
---|
593 | |
---|
594 | </div> |
---|
595 | </div> |
---|
596 | |
---|
597 | |
---|
598 | </div> |
---|
599 | </div> |
---|
600 | </div> |
---|
601 | <div class="sphinxsidebar"> |
---|
602 | <div class="sphinxsidebarwrapper"> |
---|
603 | <h3><a href="../index.html">Table Of Contents</a></h3> |
---|
604 | <ul> |
---|
605 | <li><a class="reference internal" href="#">invertor</a><ul> |
---|
606 | <li><a class="reference internal" href="#module-sans.pr.invertor"><tt class="docutils literal"><span class="pre">sans.pr.invertor</span></tt></a></li> |
---|
607 | </ul> |
---|
608 | </li> |
---|
609 | </ul> |
---|
610 | |
---|
611 | <h4>Previous topic</h4> |
---|
612 | <p class="topless"><a href="distance_explorer.html" |
---|
613 | title="previous chapter">distance_explorer</a></p> |
---|
614 | <h4>Next topic</h4> |
---|
615 | <p class="topless"><a href="num_term.html" |
---|
616 | title="next chapter">num_term</a></p> |
---|
617 | <h3>This Page</h3> |
---|
618 | <ul class="this-page-menu"> |
---|
619 | <li><a href="../_sources/api/invertor.txt" |
---|
620 | rel="nofollow">Show Source</a></li> |
---|
621 | </ul> |
---|
622 | <div id="searchbox" style="display: none"> |
---|
623 | <h3>Quick search</h3> |
---|
624 | <form class="search" action="../search.html" method="get"> |
---|
625 | <input type="text" name="q" size="18" /> |
---|
626 | <input type="submit" value="Go" /> |
---|
627 | <input type="hidden" name="check_keywords" value="yes" /> |
---|
628 | <input type="hidden" name="area" value="default" /> |
---|
629 | </form> |
---|
630 | <p class="searchtip" style="font-size: 90%"> |
---|
631 | Enter search terms or a module, class or function name. |
---|
632 | </p> |
---|
633 | </div> |
---|
634 | <script type="text/javascript">$('#searchbox').show(0);</script> |
---|
635 | </div> |
---|
636 | </div> |
---|
637 | <div class="clearer"></div> |
---|
638 | </div> |
---|
639 | <div class="related"> |
---|
640 | <h3>Navigation</h3> |
---|
641 | <ul> |
---|
642 | <li class="right" style="margin-right: 10px"> |
---|
643 | <a href="../genindex.html" title="General Index" |
---|
644 | >index</a></li> |
---|
645 | <li class="right" > |
---|
646 | <a href="../py-modindex.html" title="Python Module Index" |
---|
647 | >modules</a> |</li> |
---|
648 | <li class="right" > |
---|
649 | <a href="num_term.html" title="num_term" |
---|
650 | >next</a> |</li> |
---|
651 | <li class="right" > |
---|
652 | <a href="distance_explorer.html" title="distance_explorer" |
---|
653 | >previous</a> |</li> |
---|
654 | <li><a href="../index.html">pr_inversion v0.1.0 documentation</a> »</li> |
---|
655 | <li><a href="index.html" >Reference</a> »</li> |
---|
656 | </ul> |
---|
657 | </div> |
---|
658 | <div class="footer"> |
---|
659 | © Copyright 2010, sans group. |
---|
660 | Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0b1. |
---|
661 | </div> |
---|
662 | </body> |
---|
663 | </html> |
---|