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