1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
---|
2 | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
---|
3 | |
---|
4 | |
---|
5 | <html xmlns="http://www.w3.org/1999/xhtml"> |
---|
6 | <head> |
---|
7 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
---|
8 | |
---|
9 | <title>sas.fit package — SasView 3.0.0 documentation</title> |
---|
10 | |
---|
11 | <link rel="stylesheet" href="../../_static/default.css" type="text/css" /> |
---|
12 | <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" /> |
---|
13 | |
---|
14 | <script type="text/javascript"> |
---|
15 | var DOCUMENTATION_OPTIONS = { |
---|
16 | URL_ROOT: '../../', |
---|
17 | VERSION: '3.0.0', |
---|
18 | COLLAPSE_INDEX: false, |
---|
19 | FILE_SUFFIX: '.html', |
---|
20 | HAS_SOURCE: true |
---|
21 | }; |
---|
22 | </script> |
---|
23 | <script type="text/javascript" src="../../_static/jquery.js"></script> |
---|
24 | <script type="text/javascript" src="../../_static/underscore.js"></script> |
---|
25 | <script type="text/javascript" src="../../_static/doctools.js"></script> |
---|
26 | <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> |
---|
27 | <link rel="top" title="SasView 3.0.0 documentation" href="../../index.html" /> |
---|
28 | <link rel="up" title="sas package" href="sas.html" /> |
---|
29 | <link rel="next" title="sas.guiframe package" href="sas.guiframe.html" /> |
---|
30 | <link rel="prev" title="sas.dataloader.readers package" href="sas.dataloader.readers.html" /> |
---|
31 | </head> |
---|
32 | <body> |
---|
33 | <div class="related"> |
---|
34 | <h3>Navigation</h3> |
---|
35 | <ul> |
---|
36 | <li class="right" style="margin-right: 10px"> |
---|
37 | <a href="../../genindex.html" title="General Index" |
---|
38 | accesskey="I">index</a></li> |
---|
39 | <li class="right" > |
---|
40 | <a href="../../py-modindex.html" title="Python Module Index" |
---|
41 | >modules</a> |</li> |
---|
42 | <li class="right" > |
---|
43 | <a href="sas.guiframe.html" title="sas.guiframe package" |
---|
44 | accesskey="N">next</a> |</li> |
---|
45 | <li class="right" > |
---|
46 | <a href="sas.dataloader.readers.html" title="sas.dataloader.readers package" |
---|
47 | accesskey="P">previous</a> |</li> |
---|
48 | <li><a href="../../index.html">SasView 3.0.0 documentation</a> »</li> |
---|
49 | <li><a href="../dev.html" >Developer Documentation</a> »</li> |
---|
50 | <li><a href="modules.html" >lib.macosx-10.5-x86_64-2.7</a> »</li> |
---|
51 | <li><a href="sas.html" accesskey="U">sas package</a> »</li> |
---|
52 | </ul> |
---|
53 | </div> |
---|
54 | |
---|
55 | <div class="document"> |
---|
56 | <div class="documentwrapper"> |
---|
57 | <div class="bodywrapper"> |
---|
58 | <div class="body"> |
---|
59 | |
---|
60 | <div class="section" id="sas-fit-package"> |
---|
61 | <h1>sas.fit package</h1> |
---|
62 | <div class="section" id="submodules"> |
---|
63 | <h2>Submodules</h2> |
---|
64 | </div> |
---|
65 | <div class="section" id="module-sas.fit.AbstractFitEngine"> |
---|
66 | <span id="sas-fit-abstractfitengine-module"></span><h2>sas.fit.AbstractFitEngine module</h2> |
---|
67 | <dl class="class"> |
---|
68 | <dt id="sas.fit.AbstractFitEngine.FResult"> |
---|
69 | <em class="property">class </em><tt class="descclassname">sas.fit.AbstractFitEngine.</tt><tt class="descname">FResult</tt><big>(</big><em>model=None</em>, <em>param_list=None</em>, <em>data=None</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/AbstractFitEngine.html#FResult"><span class="viewcode-link">[source]</span></a></dt> |
---|
70 | <dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></p> |
---|
71 | <p>Storing fit result</p> |
---|
72 | <dl class="method"> |
---|
73 | <dt id="sas.fit.AbstractFitEngine.FResult.print_summary"> |
---|
74 | <tt class="descname">print_summary</tt><big>(</big><big>)</big><a class="reference internal" href="../../_modules/sas/fit/AbstractFitEngine.html#FResult.print_summary"><span class="viewcode-link">[source]</span></a></dt> |
---|
75 | <dd></dd></dl> |
---|
76 | |
---|
77 | <dl class="method"> |
---|
78 | <dt id="sas.fit.AbstractFitEngine.FResult.set_fitness"> |
---|
79 | <tt class="descname">set_fitness</tt><big>(</big><em>fitness</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/AbstractFitEngine.html#FResult.set_fitness"><span class="viewcode-link">[source]</span></a></dt> |
---|
80 | <dd></dd></dl> |
---|
81 | |
---|
82 | <dl class="method"> |
---|
83 | <dt id="sas.fit.AbstractFitEngine.FResult.set_model"> |
---|
84 | <tt class="descname">set_model</tt><big>(</big><em>model</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/AbstractFitEngine.html#FResult.set_model"><span class="viewcode-link">[source]</span></a></dt> |
---|
85 | <dd></dd></dl> |
---|
86 | |
---|
87 | </dd></dl> |
---|
88 | |
---|
89 | <dl class="exception"> |
---|
90 | <dt id="sas.fit.AbstractFitEngine.FitAbort"> |
---|
91 | <em class="property">exception </em><tt class="descclassname">sas.fit.AbstractFitEngine.</tt><tt class="descname">FitAbort</tt><a class="reference internal" href="../../_modules/sas/fit/AbstractFitEngine.html#FitAbort"><span class="viewcode-link">[source]</span></a></dt> |
---|
92 | <dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">exceptions.Exception</span></tt></p> |
---|
93 | <p>Exception raise to stop the fit</p> |
---|
94 | </dd></dl> |
---|
95 | |
---|
96 | <dl class="class"> |
---|
97 | <dt id="sas.fit.AbstractFitEngine.FitArrange"> |
---|
98 | <em class="property">class </em><tt class="descclassname">sas.fit.AbstractFitEngine.</tt><tt class="descname">FitArrange</tt><a class="reference internal" href="../../_modules/sas/fit/AbstractFitEngine.html#FitArrange"><span class="viewcode-link">[source]</span></a></dt> |
---|
99 | <dd><dl class="method"> |
---|
100 | <dt id="sas.fit.AbstractFitEngine.FitArrange.add_data"> |
---|
101 | <tt class="descname">add_data</tt><big>(</big><em>data</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/AbstractFitEngine.html#FitArrange.add_data"><span class="viewcode-link">[source]</span></a></dt> |
---|
102 | <dd><p>add_data fill a self.data_list with data to fit</p> |
---|
103 | <table class="docutils field-list" frame="void" rules="none"> |
---|
104 | <col class="field-name" /> |
---|
105 | <col class="field-body" /> |
---|
106 | <tbody valign="top"> |
---|
107 | <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>data</strong> – Data to add in the list</td> |
---|
108 | </tr> |
---|
109 | </tbody> |
---|
110 | </table> |
---|
111 | </dd></dl> |
---|
112 | |
---|
113 | <dl class="method"> |
---|
114 | <dt id="sas.fit.AbstractFitEngine.FitArrange.get_data"> |
---|
115 | <tt class="descname">get_data</tt><big>(</big><big>)</big><a class="reference internal" href="../../_modules/sas/fit/AbstractFitEngine.html#FitArrange.get_data"><span class="viewcode-link">[source]</span></a></dt> |
---|
116 | <dd><table class="docutils field-list" frame="void" rules="none"> |
---|
117 | <col class="field-name" /> |
---|
118 | <col class="field-body" /> |
---|
119 | <tbody valign="top"> |
---|
120 | <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">list of data data_list</td> |
---|
121 | </tr> |
---|
122 | </tbody> |
---|
123 | </table> |
---|
124 | </dd></dl> |
---|
125 | |
---|
126 | <dl class="method"> |
---|
127 | <dt id="sas.fit.AbstractFitEngine.FitArrange.get_model"> |
---|
128 | <tt class="descname">get_model</tt><big>(</big><big>)</big><a class="reference internal" href="../../_modules/sas/fit/AbstractFitEngine.html#FitArrange.get_model"><span class="viewcode-link">[source]</span></a></dt> |
---|
129 | <dd><table class="docutils field-list" frame="void" rules="none"> |
---|
130 | <col class="field-name" /> |
---|
131 | <col class="field-body" /> |
---|
132 | <tbody valign="top"> |
---|
133 | <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">saved model</td> |
---|
134 | </tr> |
---|
135 | </tbody> |
---|
136 | </table> |
---|
137 | </dd></dl> |
---|
138 | |
---|
139 | <dl class="method"> |
---|
140 | <dt id="sas.fit.AbstractFitEngine.FitArrange.get_to_fit"> |
---|
141 | <tt class="descname">get_to_fit</tt><big>(</big><big>)</big><a class="reference internal" href="../../_modules/sas/fit/AbstractFitEngine.html#FitArrange.get_to_fit"><span class="viewcode-link">[source]</span></a></dt> |
---|
142 | <dd><p>return self.selected value</p> |
---|
143 | </dd></dl> |
---|
144 | |
---|
145 | <dl class="method"> |
---|
146 | <dt id="sas.fit.AbstractFitEngine.FitArrange.remove_data"> |
---|
147 | <tt class="descname">remove_data</tt><big>(</big><em>data</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/AbstractFitEngine.html#FitArrange.remove_data"><span class="viewcode-link">[source]</span></a></dt> |
---|
148 | <dd><p>Remove one element from the list</p> |
---|
149 | <table class="docutils field-list" frame="void" rules="none"> |
---|
150 | <col class="field-name" /> |
---|
151 | <col class="field-body" /> |
---|
152 | <tbody valign="top"> |
---|
153 | <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>data</strong> – Data to remove from data_list</td> |
---|
154 | </tr> |
---|
155 | </tbody> |
---|
156 | </table> |
---|
157 | </dd></dl> |
---|
158 | |
---|
159 | <dl class="method"> |
---|
160 | <dt id="sas.fit.AbstractFitEngine.FitArrange.set_model"> |
---|
161 | <tt class="descname">set_model</tt><big>(</big><em>model</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/AbstractFitEngine.html#FitArrange.set_model"><span class="viewcode-link">[source]</span></a></dt> |
---|
162 | <dd><p>set_model save a copy of the model</p> |
---|
163 | <table class="docutils field-list" frame="void" rules="none"> |
---|
164 | <col class="field-name" /> |
---|
165 | <col class="field-body" /> |
---|
166 | <tbody valign="top"> |
---|
167 | <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>model</strong> – the model being set</td> |
---|
168 | </tr> |
---|
169 | </tbody> |
---|
170 | </table> |
---|
171 | </dd></dl> |
---|
172 | |
---|
173 | <dl class="method"> |
---|
174 | <dt id="sas.fit.AbstractFitEngine.FitArrange.set_to_fit"> |
---|
175 | <tt class="descname">set_to_fit</tt><big>(</big><em>value=0</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/AbstractFitEngine.html#FitArrange.set_to_fit"><span class="viewcode-link">[source]</span></a></dt> |
---|
176 | <dd><p>set self.selected to 0 or 1 for other values raise an exception</p> |
---|
177 | <table class="docutils field-list" frame="void" rules="none"> |
---|
178 | <col class="field-name" /> |
---|
179 | <col class="field-body" /> |
---|
180 | <tbody valign="top"> |
---|
181 | <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>value</strong> – integer between 0 or 1</td> |
---|
182 | </tr> |
---|
183 | </tbody> |
---|
184 | </table> |
---|
185 | </dd></dl> |
---|
186 | |
---|
187 | </dd></dl> |
---|
188 | |
---|
189 | <dl class="class"> |
---|
190 | <dt id="sas.fit.AbstractFitEngine.FitData1D"> |
---|
191 | <em class="property">class </em><tt class="descclassname">sas.fit.AbstractFitEngine.</tt><tt class="descname">FitData1D</tt><big>(</big><em>x</em>, <em>y</em>, <em>dx=None</em>, <em>dy=None</em>, <em>smearer=None</em>, <em>data=None</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/AbstractFitEngine.html#FitData1D"><span class="viewcode-link">[source]</span></a></dt> |
---|
192 | <dd><p>Bases: <a class="reference internal" href="sas.dataloader.html#sas.dataloader.data_info.Data1D" title="sas.dataloader.data_info.Data1D"><tt class="xref py py-class docutils literal"><span class="pre">sas.dataloader.data_info.Data1D</span></tt></a></p> |
---|
193 | <p>Wrapper class for SAS data |
---|
194 | FitData1D inherits from DataLoader.data_info.Data1D. Implements |
---|
195 | a way to get residuals from data.</p> |
---|
196 | <dl class="method"> |
---|
197 | <dt id="sas.fit.AbstractFitEngine.FitData1D.get_fit_range"> |
---|
198 | <tt class="descname">get_fit_range</tt><big>(</big><big>)</big><a class="reference internal" href="../../_modules/sas/fit/AbstractFitEngine.html#FitData1D.get_fit_range"><span class="viewcode-link">[source]</span></a></dt> |
---|
199 | <dd><p>Return the range of data.x to fit</p> |
---|
200 | </dd></dl> |
---|
201 | |
---|
202 | <dl class="method"> |
---|
203 | <dt id="sas.fit.AbstractFitEngine.FitData1D.residuals"> |
---|
204 | <tt class="descname">residuals</tt><big>(</big><em>fn</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/AbstractFitEngine.html#FitData1D.residuals"><span class="viewcode-link">[source]</span></a></dt> |
---|
205 | <dd><p>Compute residuals.</p> |
---|
206 | <p>If self.smearer has been set, use if to smear |
---|
207 | the data before computing chi squared.</p> |
---|
208 | <table class="docutils field-list" frame="void" rules="none"> |
---|
209 | <col class="field-name" /> |
---|
210 | <col class="field-body" /> |
---|
211 | <tbody valign="top"> |
---|
212 | <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>fn</strong> – function that return model value</td> |
---|
213 | </tr> |
---|
214 | <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">residuals</td> |
---|
215 | </tr> |
---|
216 | </tbody> |
---|
217 | </table> |
---|
218 | </dd></dl> |
---|
219 | |
---|
220 | <dl class="method"> |
---|
221 | <dt id="sas.fit.AbstractFitEngine.FitData1D.residuals_deriv"> |
---|
222 | <tt class="descname">residuals_deriv</tt><big>(</big><em>model</em>, <em>pars=[]</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/AbstractFitEngine.html#FitData1D.residuals_deriv"><span class="viewcode-link">[source]</span></a></dt> |
---|
223 | <dd><table class="docutils field-list" frame="void" rules="none"> |
---|
224 | <col class="field-name" /> |
---|
225 | <col class="field-body" /> |
---|
226 | <tbody valign="top"> |
---|
227 | <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">residuals derivatives .</td> |
---|
228 | </tr> |
---|
229 | <tr class="field-even field"><th class="field-name">Note:</th><td class="field-body">in this case just return empty array</td> |
---|
230 | </tr> |
---|
231 | </tbody> |
---|
232 | </table> |
---|
233 | </dd></dl> |
---|
234 | |
---|
235 | <dl class="method"> |
---|
236 | <dt id="sas.fit.AbstractFitEngine.FitData1D.set_fit_range"> |
---|
237 | <tt class="descname">set_fit_range</tt><big>(</big><em>qmin=None</em>, <em>qmax=None</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/AbstractFitEngine.html#FitData1D.set_fit_range"><span class="viewcode-link">[source]</span></a></dt> |
---|
238 | <dd><p>to set the fit range</p> |
---|
239 | </dd></dl> |
---|
240 | |
---|
241 | <dl class="method"> |
---|
242 | <dt id="sas.fit.AbstractFitEngine.FitData1D.size"> |
---|
243 | <tt class="descname">size</tt><big>(</big><big>)</big><a class="reference internal" href="../../_modules/sas/fit/AbstractFitEngine.html#FitData1D.size"><span class="viewcode-link">[source]</span></a></dt> |
---|
244 | <dd><p>Number of measurement points in data set after masking, etc.</p> |
---|
245 | </dd></dl> |
---|
246 | |
---|
247 | </dd></dl> |
---|
248 | |
---|
249 | <dl class="class"> |
---|
250 | <dt id="sas.fit.AbstractFitEngine.FitData2D"> |
---|
251 | <em class="property">class </em><tt class="descclassname">sas.fit.AbstractFitEngine.</tt><tt class="descname">FitData2D</tt><big>(</big><em>sas_data2d</em>, <em>data=None</em>, <em>err_data=None</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/AbstractFitEngine.html#FitData2D"><span class="viewcode-link">[source]</span></a></dt> |
---|
252 | <dd><p>Bases: <a class="reference internal" href="sas.dataloader.html#sas.dataloader.data_info.Data2D" title="sas.dataloader.data_info.Data2D"><tt class="xref py py-class docutils literal"><span class="pre">sas.dataloader.data_info.Data2D</span></tt></a></p> |
---|
253 | <p>Wrapper class for SAS data</p> |
---|
254 | <dl class="method"> |
---|
255 | <dt id="sas.fit.AbstractFitEngine.FitData2D.get_fit_range"> |
---|
256 | <tt class="descname">get_fit_range</tt><big>(</big><big>)</big><a class="reference internal" href="../../_modules/sas/fit/AbstractFitEngine.html#FitData2D.get_fit_range"><span class="viewcode-link">[source]</span></a></dt> |
---|
257 | <dd><p>return the range of data.x to fit</p> |
---|
258 | </dd></dl> |
---|
259 | |
---|
260 | <dl class="method"> |
---|
261 | <dt id="sas.fit.AbstractFitEngine.FitData2D.residuals"> |
---|
262 | <tt class="descname">residuals</tt><big>(</big><em>fn</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/AbstractFitEngine.html#FitData2D.residuals"><span class="viewcode-link">[source]</span></a></dt> |
---|
263 | <dd><p>return the residuals</p> |
---|
264 | </dd></dl> |
---|
265 | |
---|
266 | <dl class="method"> |
---|
267 | <dt id="sas.fit.AbstractFitEngine.FitData2D.residuals_deriv"> |
---|
268 | <tt class="descname">residuals_deriv</tt><big>(</big><em>model</em>, <em>pars=[]</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/AbstractFitEngine.html#FitData2D.residuals_deriv"><span class="viewcode-link">[source]</span></a></dt> |
---|
269 | <dd><table class="docutils field-list" frame="void" rules="none"> |
---|
270 | <col class="field-name" /> |
---|
271 | <col class="field-body" /> |
---|
272 | <tbody valign="top"> |
---|
273 | <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">residuals derivatives .</td> |
---|
274 | </tr> |
---|
275 | <tr class="field-even field"><th class="field-name">Note:</th><td class="field-body">in this case just return empty array</td> |
---|
276 | </tr> |
---|
277 | </tbody> |
---|
278 | </table> |
---|
279 | </dd></dl> |
---|
280 | |
---|
281 | <dl class="method"> |
---|
282 | <dt id="sas.fit.AbstractFitEngine.FitData2D.set_data"> |
---|
283 | <tt class="descname">set_data</tt><big>(</big><em>sas_data2d</em>, <em>qmin=None</em>, <em>qmax=None</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/AbstractFitEngine.html#FitData2D.set_data"><span class="viewcode-link">[source]</span></a></dt> |
---|
284 | <dd><p>Determine the correct qx_data and qy_data within range to fit</p> |
---|
285 | </dd></dl> |
---|
286 | |
---|
287 | <dl class="method"> |
---|
288 | <dt id="sas.fit.AbstractFitEngine.FitData2D.set_fit_range"> |
---|
289 | <tt class="descname">set_fit_range</tt><big>(</big><em>qmin=None</em>, <em>qmax=None</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/AbstractFitEngine.html#FitData2D.set_fit_range"><span class="viewcode-link">[source]</span></a></dt> |
---|
290 | <dd><p>To set the fit range</p> |
---|
291 | </dd></dl> |
---|
292 | |
---|
293 | <dl class="method"> |
---|
294 | <dt id="sas.fit.AbstractFitEngine.FitData2D.set_smearer"> |
---|
295 | <tt class="descname">set_smearer</tt><big>(</big><em>smearer</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/AbstractFitEngine.html#FitData2D.set_smearer"><span class="viewcode-link">[source]</span></a></dt> |
---|
296 | <dd><p>Set smearer</p> |
---|
297 | </dd></dl> |
---|
298 | |
---|
299 | <dl class="method"> |
---|
300 | <dt id="sas.fit.AbstractFitEngine.FitData2D.size"> |
---|
301 | <tt class="descname">size</tt><big>(</big><big>)</big><a class="reference internal" href="../../_modules/sas/fit/AbstractFitEngine.html#FitData2D.size"><span class="viewcode-link">[source]</span></a></dt> |
---|
302 | <dd><p>Number of measurement points in data set after masking, etc.</p> |
---|
303 | </dd></dl> |
---|
304 | |
---|
305 | </dd></dl> |
---|
306 | |
---|
307 | <dl class="class"> |
---|
308 | <dt id="sas.fit.AbstractFitEngine.FitEngine"> |
---|
309 | <em class="property">class </em><tt class="descclassname">sas.fit.AbstractFitEngine.</tt><tt class="descname">FitEngine</tt><a class="reference internal" href="../../_modules/sas/fit/AbstractFitEngine.html#FitEngine"><span class="viewcode-link">[source]</span></a></dt> |
---|
310 | <dd><dl class="method"> |
---|
311 | <dt id="sas.fit.AbstractFitEngine.FitEngine.get_model"> |
---|
312 | <tt class="descname">get_model</tt><big>(</big><em>id</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/AbstractFitEngine.html#FitEngine.get_model"><span class="viewcode-link">[source]</span></a></dt> |
---|
313 | <dd><table class="docutils field-list" frame="void" rules="none"> |
---|
314 | <col class="field-name" /> |
---|
315 | <col class="field-body" /> |
---|
316 | <tbody valign="top"> |
---|
317 | <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>id</strong> – id is key in the dictionary containing the model to return</td> |
---|
318 | </tr> |
---|
319 | <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">a model at this id or None if no FitArrange element was |
---|
320 | created with this id</td> |
---|
321 | </tr> |
---|
322 | </tbody> |
---|
323 | </table> |
---|
324 | </dd></dl> |
---|
325 | |
---|
326 | <dl class="method"> |
---|
327 | <dt id="sas.fit.AbstractFitEngine.FitEngine.get_problem_to_fit"> |
---|
328 | <tt class="descname">get_problem_to_fit</tt><big>(</big><em>id</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/AbstractFitEngine.html#FitEngine.get_problem_to_fit"><span class="viewcode-link">[source]</span></a></dt> |
---|
329 | <dd><p>return the self.selected value of the fit problem of id</p> |
---|
330 | <table class="docutils field-list" frame="void" rules="none"> |
---|
331 | <col class="field-name" /> |
---|
332 | <col class="field-body" /> |
---|
333 | <tbody valign="top"> |
---|
334 | <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>id</strong> – the id of the problem</td> |
---|
335 | </tr> |
---|
336 | </tbody> |
---|
337 | </table> |
---|
338 | </dd></dl> |
---|
339 | |
---|
340 | <dl class="method"> |
---|
341 | <dt id="sas.fit.AbstractFitEngine.FitEngine.remove_fit_problem"> |
---|
342 | <tt class="descname">remove_fit_problem</tt><big>(</big><em>id</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/AbstractFitEngine.html#FitEngine.remove_fit_problem"><span class="viewcode-link">[source]</span></a></dt> |
---|
343 | <dd><p>remove fitarrange in id</p> |
---|
344 | </dd></dl> |
---|
345 | |
---|
346 | <dl class="method"> |
---|
347 | <dt id="sas.fit.AbstractFitEngine.FitEngine.select_problem_for_fit"> |
---|
348 | <tt class="descname">select_problem_for_fit</tt><big>(</big><em>id</em>, <em>value</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/AbstractFitEngine.html#FitEngine.select_problem_for_fit"><span class="viewcode-link">[source]</span></a></dt> |
---|
349 | <dd><p>select a couple of model and data at the id position in dictionary |
---|
350 | and set in self.selected value to value</p> |
---|
351 | <table class="docutils field-list" frame="void" rules="none"> |
---|
352 | <col class="field-name" /> |
---|
353 | <col class="field-body" /> |
---|
354 | <tbody valign="top"> |
---|
355 | <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>value</strong> – the value to allow fitting. |
---|
356 | can only have the value one or zero</td> |
---|
357 | </tr> |
---|
358 | </tbody> |
---|
359 | </table> |
---|
360 | </dd></dl> |
---|
361 | |
---|
362 | <dl class="method"> |
---|
363 | <dt id="sas.fit.AbstractFitEngine.FitEngine.set_data"> |
---|
364 | <tt class="descname">set_data</tt><big>(</big><em>data</em>, <em>id</em>, <em>smearer=None</em>, <em>qmin=None</em>, <em>qmax=None</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/AbstractFitEngine.html#FitEngine.set_data"><span class="viewcode-link">[source]</span></a></dt> |
---|
365 | <dd><p>Receives plottable, creates a list of data to fit,set data |
---|
366 | in a FitArrange object and adds that object in a dictionary |
---|
367 | with key id.</p> |
---|
368 | <table class="docutils field-list" frame="void" rules="none"> |
---|
369 | <col class="field-name" /> |
---|
370 | <col class="field-body" /> |
---|
371 | <tbody valign="top"> |
---|
372 | <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple"> |
---|
373 | <li><strong>data</strong> – data added</li> |
---|
374 | <li><strong>id</strong> – unique key corresponding to a fitArrange object with data</li> |
---|
375 | </ul> |
---|
376 | </td> |
---|
377 | </tr> |
---|
378 | </tbody> |
---|
379 | </table> |
---|
380 | </dd></dl> |
---|
381 | |
---|
382 | <dl class="method"> |
---|
383 | <dt id="sas.fit.AbstractFitEngine.FitEngine.set_model"> |
---|
384 | <tt class="descname">set_model</tt><big>(</big><em>model</em>, <em>id</em>, <em>pars=[]</em>, <em>constraints=[]</em>, <em>data=None</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/AbstractFitEngine.html#FitEngine.set_model"><span class="viewcode-link">[source]</span></a></dt> |
---|
385 | <dd><p>set a model on a given in the fit engine.</p> |
---|
386 | <table class="docutils field-list" frame="void" rules="none"> |
---|
387 | <col class="field-name" /> |
---|
388 | <col class="field-body" /> |
---|
389 | <tbody valign="top"> |
---|
390 | <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> |
---|
391 | <li><strong>model</strong> – sas.models type</li> |
---|
392 | <li><strong>id</strong> – is the key of the fitArrange dictionary where model is saved as a value</li> |
---|
393 | <li><strong>pars</strong> – the list of parameters to fit</li> |
---|
394 | <li><strong>constraints</strong> – list of |
---|
395 | tuple (name of parameter, value of parameters) |
---|
396 | the value of parameter must be a string to constraint 2 different |
---|
397 | parameters. |
---|
398 | Example: |
---|
399 | we want to fit 2 model M1 and M2 both have parameters A and B. |
---|
400 | constraints can be <tt class="docutils literal"><span class="pre">constraints</span> <span class="pre">=</span> <span class="pre">[(M1.A,</span> <span class="pre">M2.B+2),</span> <span class="pre">(M1.B=</span> <span class="pre">M2.A</span> <span class="pre">*5),...,]</span></tt></li> |
---|
401 | </ul> |
---|
402 | </td> |
---|
403 | </tr> |
---|
404 | <tr class="field-even field"><th class="field-name">Note:</th><td class="field-body"><p class="first last">pars must contains only name of existing model’s parameters</p> |
---|
405 | </td> |
---|
406 | </tr> |
---|
407 | </tbody> |
---|
408 | </table> |
---|
409 | </dd></dl> |
---|
410 | |
---|
411 | </dd></dl> |
---|
412 | |
---|
413 | <dl class="class"> |
---|
414 | <dt id="sas.fit.AbstractFitEngine.FitHandler"> |
---|
415 | <em class="property">class </em><tt class="descclassname">sas.fit.AbstractFitEngine.</tt><tt class="descname">FitHandler</tt><a class="reference internal" href="../../_modules/sas/fit/AbstractFitEngine.html#FitHandler"><span class="viewcode-link">[source]</span></a></dt> |
---|
416 | <dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></p> |
---|
417 | <p>Abstract interface for fit thread handler.</p> |
---|
418 | <p>The methods in this class are called by the optimizer as the fit |
---|
419 | progresses.</p> |
---|
420 | <p>Note that it is up to the optimizer to call the fit handler correctly, |
---|
421 | reporting all status changes and maintaining the ‘done’ flag.</p> |
---|
422 | <dl class="method"> |
---|
423 | <dt id="sas.fit.AbstractFitEngine.FitHandler.abort"> |
---|
424 | <tt class="descname">abort</tt><big>(</big><big>)</big><a class="reference internal" href="../../_modules/sas/fit/AbstractFitEngine.html#FitHandler.abort"><span class="viewcode-link">[source]</span></a></dt> |
---|
425 | <dd><p>Fit was aborted.</p> |
---|
426 | </dd></dl> |
---|
427 | |
---|
428 | <dl class="attribute"> |
---|
429 | <dt id="sas.fit.AbstractFitEngine.FitHandler.done"> |
---|
430 | <tt class="descname">done</tt><em class="property"> = False</em></dt> |
---|
431 | <dd><p>True when the fit job is complete</p> |
---|
432 | </dd></dl> |
---|
433 | |
---|
434 | <dl class="method"> |
---|
435 | <dt id="sas.fit.AbstractFitEngine.FitHandler.error"> |
---|
436 | <tt class="descname">error</tt><big>(</big><em>msg</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/AbstractFitEngine.html#FitHandler.error"><span class="viewcode-link">[source]</span></a></dt> |
---|
437 | <dd><p>Model had an error; print traceback</p> |
---|
438 | </dd></dl> |
---|
439 | |
---|
440 | <dl class="method"> |
---|
441 | <dt id="sas.fit.AbstractFitEngine.FitHandler.finalize"> |
---|
442 | <tt class="descname">finalize</tt><big>(</big><big>)</big><a class="reference internal" href="../../_modules/sas/fit/AbstractFitEngine.html#FitHandler.finalize"><span class="viewcode-link">[source]</span></a></dt> |
---|
443 | <dd><p>Fit is complete; best results are reported</p> |
---|
444 | </dd></dl> |
---|
445 | |
---|
446 | <dl class="method"> |
---|
447 | <dt id="sas.fit.AbstractFitEngine.FitHandler.improvement"> |
---|
448 | <tt class="descname">improvement</tt><big>(</big><big>)</big><a class="reference internal" href="../../_modules/sas/fit/AbstractFitEngine.html#FitHandler.improvement"><span class="viewcode-link">[source]</span></a></dt> |
---|
449 | <dd><p>Called when a result is observed which is better than previous |
---|
450 | results from the fit.</p> |
---|
451 | <p>result is a FitResult object, with parameters, #calls and fitness.</p> |
---|
452 | </dd></dl> |
---|
453 | |
---|
454 | <dl class="method"> |
---|
455 | <dt id="sas.fit.AbstractFitEngine.FitHandler.progress"> |
---|
456 | <tt class="descname">progress</tt><big>(</big><em>current</em>, <em>expected</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/AbstractFitEngine.html#FitHandler.progress"><span class="viewcode-link">[source]</span></a></dt> |
---|
457 | <dd><p>Called each cycle of the fit, reporting the current and the |
---|
458 | expected amount of work. The meaning of these values is |
---|
459 | optimizer dependent, but they can be converted into a percent |
---|
460 | complete using (100*current)//expected.</p> |
---|
461 | <p>Progress is updated each iteration of the fit, whatever that |
---|
462 | means for the particular optimization algorithm. It is called |
---|
463 | after any calls to improvement for the iteration so that the |
---|
464 | update handler can control I/O bandwidth by suppressing |
---|
465 | intermediate improvements until the fit is complete.</p> |
---|
466 | </dd></dl> |
---|
467 | |
---|
468 | <dl class="attribute"> |
---|
469 | <dt id="sas.fit.AbstractFitEngine.FitHandler.result"> |
---|
470 | <tt class="descname">result</tt><em class="property"> = None</em></dt> |
---|
471 | <dd><p>The current best result of the fit</p> |
---|
472 | </dd></dl> |
---|
473 | |
---|
474 | <dl class="method"> |
---|
475 | <dt id="sas.fit.AbstractFitEngine.FitHandler.set_result"> |
---|
476 | <tt class="descname">set_result</tt><big>(</big><em>result=None</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/AbstractFitEngine.html#FitHandler.set_result"><span class="viewcode-link">[source]</span></a></dt> |
---|
477 | <dd></dd></dl> |
---|
478 | |
---|
479 | <dl class="method"> |
---|
480 | <dt id="sas.fit.AbstractFitEngine.FitHandler.update_fit"> |
---|
481 | <tt class="descname">update_fit</tt><big>(</big><em>last=False</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/AbstractFitEngine.html#FitHandler.update_fit"><span class="viewcode-link">[source]</span></a></dt> |
---|
482 | <dd></dd></dl> |
---|
483 | |
---|
484 | </dd></dl> |
---|
485 | |
---|
486 | <dl class="class"> |
---|
487 | <dt id="sas.fit.AbstractFitEngine.Model"> |
---|
488 | <em class="property">class </em><tt class="descclassname">sas.fit.AbstractFitEngine.</tt><tt class="descname">Model</tt><big>(</big><em>sas_model</em>, <em>sas_data=None</em>, <em>**kw</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/AbstractFitEngine.html#Model"><span class="viewcode-link">[source]</span></a></dt> |
---|
489 | <dd><p>Fit wrapper for SAS models.</p> |
---|
490 | <dl class="method"> |
---|
491 | <dt id="sas.fit.AbstractFitEngine.Model.eval"> |
---|
492 | <tt class="descname">eval</tt><big>(</big><em>x</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/AbstractFitEngine.html#Model.eval"><span class="viewcode-link">[source]</span></a></dt> |
---|
493 | <dd><p>Override eval method of park model.</p> |
---|
494 | <table class="docutils field-list" frame="void" rules="none"> |
---|
495 | <col class="field-name" /> |
---|
496 | <col class="field-body" /> |
---|
497 | <tbody valign="top"> |
---|
498 | <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>x</strong> – the x value used to compute a function</td> |
---|
499 | </tr> |
---|
500 | </tbody> |
---|
501 | </table> |
---|
502 | </dd></dl> |
---|
503 | |
---|
504 | <dl class="method"> |
---|
505 | <dt id="sas.fit.AbstractFitEngine.Model.eval_derivs"> |
---|
506 | <tt class="descname">eval_derivs</tt><big>(</big><em>x</em>, <em>pars=[]</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/AbstractFitEngine.html#Model.eval_derivs"><span class="viewcode-link">[source]</span></a></dt> |
---|
507 | <dd><p>Evaluate the model and derivatives wrt pars at x.</p> |
---|
508 | <p>pars is a list of the names of the parameters for which derivatives |
---|
509 | are desired.</p> |
---|
510 | <p>This method needs to be specialized in the model to evaluate the |
---|
511 | model function. Alternatively, the model can implement is own |
---|
512 | version of residuals which calculates the residuals directly |
---|
513 | instead of calling eval.</p> |
---|
514 | </dd></dl> |
---|
515 | |
---|
516 | <dl class="method"> |
---|
517 | <dt id="sas.fit.AbstractFitEngine.Model.get_params"> |
---|
518 | <tt class="descname">get_params</tt><big>(</big><em>fitparams</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/AbstractFitEngine.html#Model.get_params"><span class="viewcode-link">[source]</span></a></dt> |
---|
519 | <dd><p>return a list of value of paramter to fit</p> |
---|
520 | <table class="docutils field-list" frame="void" rules="none"> |
---|
521 | <col class="field-name" /> |
---|
522 | <col class="field-body" /> |
---|
523 | <tbody valign="top"> |
---|
524 | <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>fitparams</strong> – list of paramaters name to fit</td> |
---|
525 | </tr> |
---|
526 | </tbody> |
---|
527 | </table> |
---|
528 | </dd></dl> |
---|
529 | |
---|
530 | <dl class="method"> |
---|
531 | <dt id="sas.fit.AbstractFitEngine.Model.set"> |
---|
532 | <tt class="descname">set</tt><big>(</big><em>**kw</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/AbstractFitEngine.html#Model.set"><span class="viewcode-link">[source]</span></a></dt> |
---|
533 | <dd></dd></dl> |
---|
534 | |
---|
535 | <dl class="method"> |
---|
536 | <dt id="sas.fit.AbstractFitEngine.Model.set_params"> |
---|
537 | <tt class="descname">set_params</tt><big>(</big><em>paramlist</em>, <em>params</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/AbstractFitEngine.html#Model.set_params"><span class="viewcode-link">[source]</span></a></dt> |
---|
538 | <dd><p>Set value for parameters to fit</p> |
---|
539 | <table class="docutils field-list" frame="void" rules="none"> |
---|
540 | <col class="field-name" /> |
---|
541 | <col class="field-body" /> |
---|
542 | <tbody valign="top"> |
---|
543 | <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>params</strong> – list of value for parameters to fit</td> |
---|
544 | </tr> |
---|
545 | </tbody> |
---|
546 | </table> |
---|
547 | </dd></dl> |
---|
548 | |
---|
549 | </dd></dl> |
---|
550 | |
---|
551 | </div> |
---|
552 | <div class="section" id="module-sas.fit.BumpsFitting"> |
---|
553 | <span id="sas-fit-bumpsfitting-module"></span><h2>sas.fit.BumpsFitting module</h2> |
---|
554 | <p>BumpsFitting module runs the bumps optimizer.</p> |
---|
555 | <dl class="class"> |
---|
556 | <dt id="sas.fit.BumpsFitting.BumpsFit"> |
---|
557 | <em class="property">class </em><tt class="descclassname">sas.fit.BumpsFitting.</tt><tt class="descname">BumpsFit</tt><a class="reference internal" href="../../_modules/sas/fit/BumpsFitting.html#BumpsFit"><span class="viewcode-link">[source]</span></a></dt> |
---|
558 | <dd><p>Bases: <a class="reference internal" href="#sas.fit.AbstractFitEngine.FitEngine" title="sas.fit.AbstractFitEngine.FitEngine"><tt class="xref py py-class docutils literal"><span class="pre">sas.fit.AbstractFitEngine.FitEngine</span></tt></a></p> |
---|
559 | <p>Fit a model using bumps.</p> |
---|
560 | <dl class="method"> |
---|
561 | <dt id="sas.fit.BumpsFitting.BumpsFit.fit"> |
---|
562 | <tt class="descname">fit</tt><big>(</big><em>msg_q=None</em>, <em>q=None</em>, <em>handler=None</em>, <em>curr_thread=None</em>, <em>ftol=1.49012e-08</em>, <em>reset_flag=False</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/BumpsFitting.html#BumpsFit.fit"><span class="viewcode-link">[source]</span></a></dt> |
---|
563 | <dd></dd></dl> |
---|
564 | |
---|
565 | </dd></dl> |
---|
566 | |
---|
567 | <dl class="class"> |
---|
568 | <dt id="sas.fit.BumpsFitting.BumpsMonitor"> |
---|
569 | <em class="property">class </em><tt class="descclassname">sas.fit.BumpsFitting.</tt><tt class="descname">BumpsMonitor</tt><big>(</big><em>handler</em>, <em>max_step</em>, <em>pars</em>, <em>dof</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/BumpsFitting.html#BumpsMonitor"><span class="viewcode-link">[source]</span></a></dt> |
---|
570 | <dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></p> |
---|
571 | <dl class="method"> |
---|
572 | <dt id="sas.fit.BumpsFitting.BumpsMonitor.config_history"> |
---|
573 | <tt class="descname">config_history</tt><big>(</big><em>history</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/BumpsFitting.html#BumpsMonitor.config_history"><span class="viewcode-link">[source]</span></a></dt> |
---|
574 | <dd></dd></dl> |
---|
575 | |
---|
576 | </dd></dl> |
---|
577 | |
---|
578 | <dl class="class"> |
---|
579 | <dt id="sas.fit.BumpsFitting.ConvergenceMonitor"> |
---|
580 | <em class="property">class </em><tt class="descclassname">sas.fit.BumpsFitting.</tt><tt class="descname">ConvergenceMonitor</tt><a class="reference internal" href="../../_modules/sas/fit/BumpsFitting.html#ConvergenceMonitor"><span class="viewcode-link">[source]</span></a></dt> |
---|
581 | <dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></p> |
---|
582 | <p>ConvergenceMonitor contains population summary statistics to show progress |
---|
583 | of the fit. This is a list [ (best, 0%, 25%, 50%, 75%, 100%) ] or |
---|
584 | just a list [ (best, ) ] if population size is 1.</p> |
---|
585 | <dl class="method"> |
---|
586 | <dt id="sas.fit.BumpsFitting.ConvergenceMonitor.config_history"> |
---|
587 | <tt class="descname">config_history</tt><big>(</big><em>history</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/BumpsFitting.html#ConvergenceMonitor.config_history"><span class="viewcode-link">[source]</span></a></dt> |
---|
588 | <dd></dd></dl> |
---|
589 | |
---|
590 | </dd></dl> |
---|
591 | |
---|
592 | <dl class="class"> |
---|
593 | <dt id="sas.fit.BumpsFitting.ParameterExpressions"> |
---|
594 | <em class="property">class </em><tt class="descclassname">sas.fit.BumpsFitting.</tt><tt class="descname">ParameterExpressions</tt><big>(</big><em>models</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/BumpsFitting.html#ParameterExpressions"><span class="viewcode-link">[source]</span></a></dt> |
---|
595 | <dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></p> |
---|
596 | </dd></dl> |
---|
597 | |
---|
598 | <dl class="class"> |
---|
599 | <dt id="sas.fit.BumpsFitting.Progress"> |
---|
600 | <em class="property">class </em><tt class="descclassname">sas.fit.BumpsFitting.</tt><tt class="descname">Progress</tt><big>(</big><em>history</em>, <em>max_step</em>, <em>pars</em>, <em>dof</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/BumpsFitting.html#Progress"><span class="viewcode-link">[source]</span></a></dt> |
---|
601 | <dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></p> |
---|
602 | </dd></dl> |
---|
603 | |
---|
604 | <dl class="class"> |
---|
605 | <dt id="sas.fit.BumpsFitting.SasFitness"> |
---|
606 | <em class="property">class </em><tt class="descclassname">sas.fit.BumpsFitting.</tt><tt class="descname">SasFitness</tt><big>(</big><em>model</em>, <em>data</em>, <em>fitted=[]</em>, <em>constraints={}</em>, <em>initial_values=None</em>, <em>**kw</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/BumpsFitting.html#SasFitness"><span class="viewcode-link">[source]</span></a></dt> |
---|
607 | <dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></p> |
---|
608 | <p>Wrap SAS model as a bumps fitness object</p> |
---|
609 | <dl class="method"> |
---|
610 | <dt id="sas.fit.BumpsFitting.SasFitness.nllf"> |
---|
611 | <tt class="descname">nllf</tt><big>(</big><big>)</big><a class="reference internal" href="../../_modules/sas/fit/BumpsFitting.html#SasFitness.nllf"><span class="viewcode-link">[source]</span></a></dt> |
---|
612 | <dd></dd></dl> |
---|
613 | |
---|
614 | <dl class="method"> |
---|
615 | <dt id="sas.fit.BumpsFitting.SasFitness.numpoints"> |
---|
616 | <tt class="descname">numpoints</tt><big>(</big><big>)</big><a class="reference internal" href="../../_modules/sas/fit/BumpsFitting.html#SasFitness.numpoints"><span class="viewcode-link">[source]</span></a></dt> |
---|
617 | <dd></dd></dl> |
---|
618 | |
---|
619 | <dl class="method"> |
---|
620 | <dt id="sas.fit.BumpsFitting.SasFitness.parameters"> |
---|
621 | <tt class="descname">parameters</tt><big>(</big><big>)</big><a class="reference internal" href="../../_modules/sas/fit/BumpsFitting.html#SasFitness.parameters"><span class="viewcode-link">[source]</span></a></dt> |
---|
622 | <dd></dd></dl> |
---|
623 | |
---|
624 | <dl class="method"> |
---|
625 | <dt id="sas.fit.BumpsFitting.SasFitness.residuals"> |
---|
626 | <tt class="descname">residuals</tt><big>(</big><big>)</big><a class="reference internal" href="../../_modules/sas/fit/BumpsFitting.html#SasFitness.residuals"><span class="viewcode-link">[source]</span></a></dt> |
---|
627 | <dd></dd></dl> |
---|
628 | |
---|
629 | <dl class="method"> |
---|
630 | <dt id="sas.fit.BumpsFitting.SasFitness.set_fitted"> |
---|
631 | <tt class="descname">set_fitted</tt><big>(</big><em>param_list</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/BumpsFitting.html#SasFitness.set_fitted"><span class="viewcode-link">[source]</span></a></dt> |
---|
632 | <dd><p>Flag a set of parameters as fitted parameters.</p> |
---|
633 | </dd></dl> |
---|
634 | |
---|
635 | <dl class="method"> |
---|
636 | <dt id="sas.fit.BumpsFitting.SasFitness.theory"> |
---|
637 | <tt class="descname">theory</tt><big>(</big><big>)</big><a class="reference internal" href="../../_modules/sas/fit/BumpsFitting.html#SasFitness.theory"><span class="viewcode-link">[source]</span></a></dt> |
---|
638 | <dd></dd></dl> |
---|
639 | |
---|
640 | <dl class="method"> |
---|
641 | <dt id="sas.fit.BumpsFitting.SasFitness.update"> |
---|
642 | <tt class="descname">update</tt><big>(</big><big>)</big><a class="reference internal" href="../../_modules/sas/fit/BumpsFitting.html#SasFitness.update"><span class="viewcode-link">[source]</span></a></dt> |
---|
643 | <dd></dd></dl> |
---|
644 | |
---|
645 | </dd></dl> |
---|
646 | |
---|
647 | <dl class="function"> |
---|
648 | <dt id="sas.fit.BumpsFitting.run_bumps"> |
---|
649 | <tt class="descclassname">sas.fit.BumpsFitting.</tt><tt class="descname">run_bumps</tt><big>(</big><em>problem</em>, <em>handler</em>, <em>curr_thread</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/BumpsFitting.html#run_bumps"><span class="viewcode-link">[source]</span></a></dt> |
---|
650 | <dd></dd></dl> |
---|
651 | |
---|
652 | </div> |
---|
653 | <div class="section" id="module-sas.fit.Fitting"> |
---|
654 | <span id="sas-fit-fitting-module"></span><h2>sas.fit.Fitting module</h2> |
---|
655 | <p>Class Fit contains ScipyFit and ParkFit methods declaration |
---|
656 | allows to create instance of type ScipyFit or ParkFit to perform either |
---|
657 | a park fit or a scipy fit.</p> |
---|
658 | <dl class="class"> |
---|
659 | <dt id="sas.fit.Fitting.Fit"> |
---|
660 | <em class="property">class </em><tt class="descclassname">sas.fit.Fitting.</tt><tt class="descname">Fit</tt><big>(</big><em>engine='scipy'</em>, <em>*args</em>, <em>**kw</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/Fitting.html#Fit"><span class="viewcode-link">[source]</span></a></dt> |
---|
661 | <dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></p> |
---|
662 | <p>Wrap class that allows to select the fitting type.this class |
---|
663 | can be used as follow :</p> |
---|
664 | <div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">sas.fit.Fitting</span> <span class="kn">import</span> <span class="n">Fit</span> |
---|
665 | <span class="n">fitter</span><span class="o">=</span> <span class="n">Fit</span><span class="p">()</span> |
---|
666 | <span class="n">fitter</span><span class="o">.</span><span class="n">fit_engine</span><span class="p">(</span><span class="s">'scipy'</span><span class="p">)</span> <span class="ow">or</span> <span class="n">fitter</span><span class="o">.</span><span class="n">fit_engine</span><span class="p">(</span><span class="s">'park'</span><span class="p">)</span> |
---|
667 | <span class="n">engine</span> <span class="o">=</span> <span class="n">fitter</span><span class="o">.</span><span class="n">returnEngine</span><span class="p">()</span> |
---|
668 | <span class="n">engine</span><span class="o">.</span><span class="n">set_data</span><span class="p">(</span><span class="n">data</span><span class="p">,</span><span class="nb">id</span><span class="p">)</span> |
---|
669 | <span class="n">engine</span><span class="o">.</span><span class="n">set_param</span><span class="p">(</span> <span class="n">model</span><span class="p">,</span><span class="n">model</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">pars</span><span class="p">)</span> |
---|
670 | <span class="n">engine</span><span class="o">.</span><span class="n">set_model</span><span class="p">(</span><span class="n">model</span><span class="p">,</span><span class="nb">id</span><span class="p">)</span> |
---|
671 | |
---|
672 | <span class="n">chisqr1</span><span class="p">,</span> <span class="n">out1</span><span class="p">,</span> <span class="n">cov1</span><span class="o">=</span><span class="n">engine</span><span class="o">.</span><span class="n">fit</span><span class="p">(</span><span class="n">pars</span><span class="p">,</span><span class="n">qmin</span><span class="p">,</span><span class="n">qmax</span><span class="p">)</span> |
---|
673 | </pre></div> |
---|
674 | </div> |
---|
675 | <dl class="method"> |
---|
676 | <dt id="sas.fit.Fitting.Fit.fit"> |
---|
677 | <tt class="descname">fit</tt><big>(</big><em>msg_q=None</em>, <em>q=None</em>, <em>handler=None</em>, <em>curr_thread=None</em>, <em>ftol=1.49012e-08</em>, <em>reset_flag=False</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/Fitting.html#Fit.fit"><span class="viewcode-link">[source]</span></a></dt> |
---|
678 | <dd><p>Perform the fit</p> |
---|
679 | </dd></dl> |
---|
680 | |
---|
681 | <dl class="method"> |
---|
682 | <dt id="sas.fit.Fitting.Fit.get_model"> |
---|
683 | <tt class="descname">get_model</tt><big>(</big><em>id</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/Fitting.html#Fit.get_model"><span class="viewcode-link">[source]</span></a></dt> |
---|
684 | <dd><p>return list of data</p> |
---|
685 | </dd></dl> |
---|
686 | |
---|
687 | <dl class="method"> |
---|
688 | <dt id="sas.fit.Fitting.Fit.get_problem_to_fit"> |
---|
689 | <tt class="descname">get_problem_to_fit</tt><big>(</big><em>id</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/Fitting.html#Fit.get_problem_to_fit"><span class="viewcode-link">[source]</span></a></dt> |
---|
690 | <dd><p>return the self.selected value of the fit problem of id</p> |
---|
691 | <table class="docutils field-list" frame="void" rules="none"> |
---|
692 | <col class="field-name" /> |
---|
693 | <col class="field-body" /> |
---|
694 | <tbody valign="top"> |
---|
695 | <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>id</strong> – the id of the problem</td> |
---|
696 | </tr> |
---|
697 | </tbody> |
---|
698 | </table> |
---|
699 | </dd></dl> |
---|
700 | |
---|
701 | <dl class="method"> |
---|
702 | <dt id="sas.fit.Fitting.Fit.remove_fit_problem"> |
---|
703 | <tt class="descname">remove_fit_problem</tt><big>(</big><em>id</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/Fitting.html#Fit.remove_fit_problem"><span class="viewcode-link">[source]</span></a></dt> |
---|
704 | <dd><p>remove fitarrange in id</p> |
---|
705 | </dd></dl> |
---|
706 | |
---|
707 | <dl class="method"> |
---|
708 | <dt id="sas.fit.Fitting.Fit.select_problem_for_fit"> |
---|
709 | <tt class="descname">select_problem_for_fit</tt><big>(</big><em>id</em>, <em>value</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/Fitting.html#Fit.select_problem_for_fit"><span class="viewcode-link">[source]</span></a></dt> |
---|
710 | <dd><p>select a couple of model and data at the id position in dictionary |
---|
711 | and set in self.selected value to value</p> |
---|
712 | <table class="docutils field-list" frame="void" rules="none"> |
---|
713 | <col class="field-name" /> |
---|
714 | <col class="field-body" /> |
---|
715 | <tbody valign="top"> |
---|
716 | <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>value</strong> – the value to allow fitting. |
---|
717 | can only have the value one or zero</td> |
---|
718 | </tr> |
---|
719 | </tbody> |
---|
720 | </table> |
---|
721 | </dd></dl> |
---|
722 | |
---|
723 | <dl class="method"> |
---|
724 | <dt id="sas.fit.Fitting.Fit.set_data"> |
---|
725 | <tt class="descname">set_data</tt><big>(</big><em>data</em>, <em>id</em>, <em>smearer=None</em>, <em>qmin=None</em>, <em>qmax=None</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/Fitting.html#Fit.set_data"><span class="viewcode-link">[source]</span></a></dt> |
---|
726 | <dd><p>Store data to fit at the psotion id of the fit engine</p> |
---|
727 | <table class="docutils field-list" frame="void" rules="none"> |
---|
728 | <col class="field-name" /> |
---|
729 | <col class="field-body" /> |
---|
730 | <tbody valign="top"> |
---|
731 | <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple"> |
---|
732 | <li><strong>data</strong> – data to fit</li> |
---|
733 | <li><strong>smearer</strong> – smearerobject to smear data</li> |
---|
734 | <li><strong>qmin</strong> – the minimum q range to fit</li> |
---|
735 | <li><strong>qmax</strong> – the minimum q range to fit</li> |
---|
736 | </ul> |
---|
737 | </td> |
---|
738 | </tr> |
---|
739 | </tbody> |
---|
740 | </table> |
---|
741 | </dd></dl> |
---|
742 | |
---|
743 | <dl class="method"> |
---|
744 | <dt id="sas.fit.Fitting.Fit.set_engine"> |
---|
745 | <tt class="descname">set_engine</tt><big>(</big><em>word</em>, <em>*args</em>, <em>**kw</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/Fitting.html#Fit.set_engine"><span class="viewcode-link">[source]</span></a></dt> |
---|
746 | <dd><p>Select the type of Fit</p> |
---|
747 | <table class="docutils field-list" frame="void" rules="none"> |
---|
748 | <col class="field-name" /> |
---|
749 | <col class="field-body" /> |
---|
750 | <tbody valign="top"> |
---|
751 | <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>word</strong> – the keyword to select the fit type</td> |
---|
752 | </tr> |
---|
753 | <tr class="field-even field"><th class="field-name">Raise:</th><td class="field-body">if the user does not enter ‘scipy’ or ‘park’, |
---|
754 | a valueError is raised</td> |
---|
755 | </tr> |
---|
756 | </tbody> |
---|
757 | </table> |
---|
758 | </dd></dl> |
---|
759 | |
---|
760 | <dl class="method"> |
---|
761 | <dt id="sas.fit.Fitting.Fit.set_model"> |
---|
762 | <tt class="descname">set_model</tt><big>(</big><em>model</em>, <em>id</em>, <em>pars=[]</em>, <em>constraints=[]</em>, <em>data=None</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/Fitting.html#Fit.set_model"><span class="viewcode-link">[source]</span></a></dt> |
---|
763 | <dd><p>store a model model to fit at the position id of the fit engine</p> |
---|
764 | </dd></dl> |
---|
765 | |
---|
766 | </dd></dl> |
---|
767 | |
---|
768 | </div> |
---|
769 | <div class="section" id="module-sas.fit.Loader"> |
---|
770 | <span id="sas-fit-loader-module"></span><h2>sas.fit.Loader module</h2> |
---|
771 | <dl class="class"> |
---|
772 | <dt id="sas.fit.Loader.Load"> |
---|
773 | <em class="property">class </em><tt class="descclassname">sas.fit.Loader.</tt><tt class="descname">Load</tt><big>(</big><em>x=None</em>, <em>y=None</em>, <em>dx=None</em>, <em>dy=None</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/Loader.html#Load"><span class="viewcode-link">[source]</span></a></dt> |
---|
774 | <dd><p>This class is loading values from given file or value giving by the user</p> |
---|
775 | <dl class="method"> |
---|
776 | <dt id="sas.fit.Loader.Load.get_filename"> |
---|
777 | <tt class="descname">get_filename</tt><big>(</big><big>)</big><a class="reference internal" href="../../_modules/sas/fit/Loader.html#Load.get_filename"><span class="viewcode-link">[source]</span></a></dt> |
---|
778 | <dd><p>return the file’s path</p> |
---|
779 | </dd></dl> |
---|
780 | |
---|
781 | <dl class="method"> |
---|
782 | <dt id="sas.fit.Loader.Load.get_values"> |
---|
783 | <tt class="descname">get_values</tt><big>(</big><big>)</big><a class="reference internal" href="../../_modules/sas/fit/Loader.html#Load.get_values"><span class="viewcode-link">[source]</span></a></dt> |
---|
784 | <dd><p>Return x, y, dx, dy</p> |
---|
785 | </dd></dl> |
---|
786 | |
---|
787 | <dl class="method"> |
---|
788 | <dt id="sas.fit.Loader.Load.load_data"> |
---|
789 | <tt class="descname">load_data</tt><big>(</big><em>data</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/Loader.html#Load.load_data"><span class="viewcode-link">[source]</span></a></dt> |
---|
790 | <dd><p>Return plottable</p> |
---|
791 | </dd></dl> |
---|
792 | |
---|
793 | <dl class="method"> |
---|
794 | <dt id="sas.fit.Loader.Load.set_filename"> |
---|
795 | <tt class="descname">set_filename</tt><big>(</big><em>path=None</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/Loader.html#Load.set_filename"><span class="viewcode-link">[source]</span></a></dt> |
---|
796 | <dd><p>Store path into a variable.If the user doesn’t give |
---|
797 | a path as a parameter a pop-up |
---|
798 | window appears to select the file.</p> |
---|
799 | <table class="docutils field-list" frame="void" rules="none"> |
---|
800 | <col class="field-name" /> |
---|
801 | <col class="field-body" /> |
---|
802 | <tbody valign="top"> |
---|
803 | <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>path</strong> – the path given by the user</td> |
---|
804 | </tr> |
---|
805 | </tbody> |
---|
806 | </table> |
---|
807 | </dd></dl> |
---|
808 | |
---|
809 | <dl class="method"> |
---|
810 | <dt id="sas.fit.Loader.Load.set_values"> |
---|
811 | <tt class="descname">set_values</tt><big>(</big><big>)</big><a class="reference internal" href="../../_modules/sas/fit/Loader.html#Load.set_values"><span class="viewcode-link">[source]</span></a></dt> |
---|
812 | <dd><p>Store the values loaded from file in local variables</p> |
---|
813 | </dd></dl> |
---|
814 | |
---|
815 | </dd></dl> |
---|
816 | |
---|
817 | </div> |
---|
818 | <div class="section" id="module-sas.fit.ParkFitting"> |
---|
819 | <span id="sas-fit-parkfitting-module"></span><h2>sas.fit.ParkFitting module</h2> |
---|
820 | <p>ParkFitting module contains SasParameter,Model,Data |
---|
821 | FitArrange, ParkFit,Parameter classes.All listed classes work together |
---|
822 | to perform a simple fit with park optimizer.</p> |
---|
823 | <dl class="class"> |
---|
824 | <dt id="sas.fit.ParkFitting.MyAssembly"> |
---|
825 | <em class="property">class </em><tt class="descclassname">sas.fit.ParkFitting.</tt><tt class="descname">MyAssembly</tt><big>(</big><em>models</em>, <em>curr_thread=None</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/ParkFitting.html#MyAssembly"><span class="viewcode-link">[source]</span></a></dt> |
---|
826 | <dd><p>Bases: <a class="reference internal" href="park.html#park.assembly.Assembly" title="park.assembly.Assembly"><tt class="xref py py-class docutils literal"><span class="pre">park.assembly.Assembly</span></tt></a></p> |
---|
827 | <dl class="method"> |
---|
828 | <dt id="sas.fit.ParkFitting.MyAssembly.eval"> |
---|
829 | <tt class="descname">eval</tt><big>(</big><big>)</big><a class="reference internal" href="../../_modules/sas/fit/ParkFitting.html#MyAssembly.eval"><span class="viewcode-link">[source]</span></a></dt> |
---|
830 | <dd><p>Recalculate the theory functions, and from them, the |
---|
831 | residuals and chisq.</p> |
---|
832 | <table class="docutils field-list" frame="void" rules="none"> |
---|
833 | <col class="field-name" /> |
---|
834 | <col class="field-body" /> |
---|
835 | <tbody valign="top"> |
---|
836 | <tr class="field-odd field"><th class="field-name">Note:</th><td class="field-body">Call this after the parameters have been updated.</td> |
---|
837 | </tr> |
---|
838 | </tbody> |
---|
839 | </table> |
---|
840 | </dd></dl> |
---|
841 | |
---|
842 | <dl class="method"> |
---|
843 | <dt id="sas.fit.ParkFitting.MyAssembly.extend_results_with_calculated_parameters"> |
---|
844 | <tt class="descname">extend_results_with_calculated_parameters</tt><big>(</big><em>result</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/ParkFitting.html#MyAssembly.extend_results_with_calculated_parameters"><span class="viewcode-link">[source]</span></a></dt> |
---|
845 | <dd><p>Extend result from the fit with the calculated parameters.</p> |
---|
846 | </dd></dl> |
---|
847 | |
---|
848 | <dl class="method"> |
---|
849 | <dt id="sas.fit.ParkFitting.MyAssembly.fit_parameters"> |
---|
850 | <tt class="descname">fit_parameters</tt><big>(</big><big>)</big><a class="reference internal" href="../../_modules/sas/fit/ParkFitting.html#MyAssembly.fit_parameters"><span class="viewcode-link">[source]</span></a></dt> |
---|
851 | <dd><p>Return an alphabetical list of the fitting parameters.</p> |
---|
852 | <p>This function is called once at the beginning of a fit, |
---|
853 | and serves as a convenient place to precalculate what |
---|
854 | can be precalculated such as the set of fitting parameters |
---|
855 | and the parameter expressions evaluator.</p> |
---|
856 | </dd></dl> |
---|
857 | |
---|
858 | </dd></dl> |
---|
859 | |
---|
860 | <dl class="class"> |
---|
861 | <dt id="sas.fit.ParkFitting.ParkFit"> |
---|
862 | <em class="property">class </em><tt class="descclassname">sas.fit.ParkFitting.</tt><tt class="descname">ParkFit</tt><a class="reference internal" href="../../_modules/sas/fit/ParkFitting.html#ParkFit"><span class="viewcode-link">[source]</span></a></dt> |
---|
863 | <dd><p>Bases: <a class="reference internal" href="#sas.fit.AbstractFitEngine.FitEngine" title="sas.fit.AbstractFitEngine.FitEngine"><tt class="xref py py-class docutils literal"><span class="pre">sas.fit.AbstractFitEngine.FitEngine</span></tt></a></p> |
---|
864 | <p>ParkFit performs the Fit.This class can be used as follow: |
---|
865 | #Do the fit Park |
---|
866 | create an engine: engine = ParkFit() |
---|
867 | Use data must be of type plottable |
---|
868 | Use a sas model</p> |
---|
869 | <p>Add data with a dictionnary of FitArrangeList where Uid is a key and data |
---|
870 | is saved in FitArrange object. |
---|
871 | engine.set_data(data,Uid)</p> |
---|
872 | <p>Set model parameter “M1”= model.name add {model.parameter.name:value}.</p> |
---|
873 | <p>..note:</p> |
---|
874 | <div class="highlight-python"><div class="highlight"><pre>Set_param() if used must always preceded set_model() for the fit to be performed. ``engine.set_param( model,"M1", {'A':2,'B':4})`` |
---|
875 | </pre></div> |
---|
876 | </div> |
---|
877 | <p>Add model with a dictionnary of FitArrangeList{} where Uid is a key |
---|
878 | and model |
---|
879 | is save in FitArrange object. |
---|
880 | engine.set_model(model,Uid)</p> |
---|
881 | <p>engine.fit return chisqr,[model.parameter 1,2,..],[[err1....][..err2...]] |
---|
882 | chisqr1, out1, cov1=engine.fit({model.parameter.name:value},qmin,qmax)</p> |
---|
883 | <p>..note:</p> |
---|
884 | <div class="highlight-python"><div class="highlight"><pre>{model.parameter.name:value} is ignored in fit function since |
---|
885 | the user should make sure to call set_param himself. |
---|
886 | </pre></div> |
---|
887 | </div> |
---|
888 | <dl class="method"> |
---|
889 | <dt id="sas.fit.ParkFitting.ParkFit.create_assembly"> |
---|
890 | <tt class="descname">create_assembly</tt><big>(</big><em>curr_thread</em>, <em>reset_flag=False</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/ParkFitting.html#ParkFit.create_assembly"><span class="viewcode-link">[source]</span></a></dt> |
---|
891 | <dd><p>Extract sasmodel and sasdata from |
---|
892 | self.FitArrangelist ={Uid:FitArrange} |
---|
893 | Create parkmodel and park data ,form a list couple of parkmodel |
---|
894 | and parkdata |
---|
895 | create an assembly self.problem= park.Assembly([(parkmodel,parkdata)])</p> |
---|
896 | </dd></dl> |
---|
897 | |
---|
898 | <dl class="method"> |
---|
899 | <dt id="sas.fit.ParkFitting.ParkFit.fit"> |
---|
900 | <tt class="descname">fit</tt><big>(</big><em>msg_q=None</em>, <em>q=None</em>, <em>handler=None</em>, <em>curr_thread=None</em>, <em>ftol=1.49012e-08</em>, <em>reset_flag=False</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/ParkFitting.html#ParkFit.fit"><span class="viewcode-link">[source]</span></a></dt> |
---|
901 | <dd><p>Performs fit with park.fit module.It can perform fit with one model |
---|
902 | and a set of data, more than two fit of one model and sets of data or |
---|
903 | fit with more than two model associated with their set of data and |
---|
904 | constraints</p> |
---|
905 | <table class="docutils field-list" frame="void" rules="none"> |
---|
906 | <col class="field-name" /> |
---|
907 | <col class="field-body" /> |
---|
908 | <tbody valign="top"> |
---|
909 | <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> |
---|
910 | <li><strong>pars</strong> – Dictionary of parameter names for the model and their |
---|
911 | values.</li> |
---|
912 | <li><strong>qmin</strong> – The minimum value of data’s range to be fit</li> |
---|
913 | <li><strong>qmax</strong> – The maximum value of data’s range to be fit</li> |
---|
914 | </ul> |
---|
915 | </td> |
---|
916 | </tr> |
---|
917 | <tr class="field-even field"><th class="field-name">Note:</th><td class="field-body"><p class="first">all parameter are ignored most of the time.Are just there |
---|
918 | to keep ScipyFit and ParkFit interface the same.</p> |
---|
919 | </td> |
---|
920 | </tr> |
---|
921 | <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">result.fitness Value of the goodness of fit metric</p> |
---|
922 | </td> |
---|
923 | </tr> |
---|
924 | <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">result.pvec list of parameter with the best value |
---|
925 | found during fitting</p> |
---|
926 | </td> |
---|
927 | </tr> |
---|
928 | <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">result.cov Covariance matrix</p> |
---|
929 | </td> |
---|
930 | </tr> |
---|
931 | </tbody> |
---|
932 | </table> |
---|
933 | </dd></dl> |
---|
934 | |
---|
935 | </dd></dl> |
---|
936 | |
---|
937 | <dl class="class"> |
---|
938 | <dt id="sas.fit.ParkFitting.ParkModel"> |
---|
939 | <em class="property">class </em><tt class="descclassname">sas.fit.ParkFitting.</tt><tt class="descname">ParkModel</tt><big>(</big><em>sas_model</em>, <em>sas_data=None</em>, <em>**kw</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/ParkFitting.html#ParkModel"><span class="viewcode-link">[source]</span></a></dt> |
---|
940 | <dd><p>Bases: <a class="reference internal" href="park.html#park.model.Model" title="park.model.Model"><tt class="xref py py-class docutils literal"><span class="pre">park.model.Model</span></tt></a></p> |
---|
941 | <p>PARK wrapper for SAS models.</p> |
---|
942 | <dl class="method"> |
---|
943 | <dt id="sas.fit.ParkFitting.ParkModel.eval"> |
---|
944 | <tt class="descname">eval</tt><big>(</big><em>x</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/ParkFitting.html#ParkModel.eval"><span class="viewcode-link">[source]</span></a></dt> |
---|
945 | <dd><p>Override eval method of park model.</p> |
---|
946 | <table class="docutils field-list" frame="void" rules="none"> |
---|
947 | <col class="field-name" /> |
---|
948 | <col class="field-body" /> |
---|
949 | <tbody valign="top"> |
---|
950 | <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>x</strong> – the x value used to compute a function</td> |
---|
951 | </tr> |
---|
952 | </tbody> |
---|
953 | </table> |
---|
954 | </dd></dl> |
---|
955 | |
---|
956 | <dl class="method"> |
---|
957 | <dt id="sas.fit.ParkFitting.ParkModel.eval_derivs"> |
---|
958 | <tt class="descname">eval_derivs</tt><big>(</big><em>x</em>, <em>pars=[]</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/ParkFitting.html#ParkModel.eval_derivs"><span class="viewcode-link">[source]</span></a></dt> |
---|
959 | <dd><p>Evaluate the model and derivatives wrt pars at x.</p> |
---|
960 | <p>pars is a list of the names of the parameters for which derivatives |
---|
961 | are desired.</p> |
---|
962 | <p>This method needs to be specialized in the model to evaluate the |
---|
963 | model function. Alternatively, the model can implement is own |
---|
964 | version of residuals which calculates the residuals directly |
---|
965 | instead of calling eval.</p> |
---|
966 | </dd></dl> |
---|
967 | |
---|
968 | <dl class="method"> |
---|
969 | <dt id="sas.fit.ParkFitting.ParkModel.get_params"> |
---|
970 | <tt class="descname">get_params</tt><big>(</big><em>fitparams</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/ParkFitting.html#ParkModel.get_params"><span class="viewcode-link">[source]</span></a></dt> |
---|
971 | <dd><p>return a list of value of paramter to fit</p> |
---|
972 | <table class="docutils field-list" frame="void" rules="none"> |
---|
973 | <col class="field-name" /> |
---|
974 | <col class="field-body" /> |
---|
975 | <tbody valign="top"> |
---|
976 | <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>fitparams</strong> – list of paramaters name to fit</td> |
---|
977 | </tr> |
---|
978 | </tbody> |
---|
979 | </table> |
---|
980 | </dd></dl> |
---|
981 | |
---|
982 | <dl class="attribute"> |
---|
983 | <dt id="sas.fit.ParkFitting.ParkModel.parameters"> |
---|
984 | <tt class="descname">parameters</tt><em class="property"> = []</em></dt> |
---|
985 | <dd></dd></dl> |
---|
986 | |
---|
987 | <dl class="attribute"> |
---|
988 | <dt id="sas.fit.ParkFitting.ParkModel.parameterset"> |
---|
989 | <tt class="descname">parameterset</tt><em class="property"> = []</em></dt> |
---|
990 | <dd></dd></dl> |
---|
991 | |
---|
992 | <dl class="method"> |
---|
993 | <dt id="sas.fit.ParkFitting.ParkModel.set_params"> |
---|
994 | <tt class="descname">set_params</tt><big>(</big><em>paramlist</em>, <em>params</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/ParkFitting.html#ParkModel.set_params"><span class="viewcode-link">[source]</span></a></dt> |
---|
995 | <dd><p>Set value for parameters to fit</p> |
---|
996 | <table class="docutils field-list" frame="void" rules="none"> |
---|
997 | <col class="field-name" /> |
---|
998 | <col class="field-body" /> |
---|
999 | <tbody valign="top"> |
---|
1000 | <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>params</strong> – list of value for parameters to fit</td> |
---|
1001 | </tr> |
---|
1002 | </tbody> |
---|
1003 | </table> |
---|
1004 | </dd></dl> |
---|
1005 | |
---|
1006 | </dd></dl> |
---|
1007 | |
---|
1008 | <dl class="class"> |
---|
1009 | <dt id="sas.fit.ParkFitting.SasFitMC"> |
---|
1010 | <em class="property">class </em><tt class="descclassname">sas.fit.ParkFitting.</tt><tt class="descname">SasFitMC</tt><big>(</big><em>localfit</em>, <em>start_points=10</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/ParkFitting.html#SasFitMC"><span class="viewcode-link">[source]</span></a></dt> |
---|
1011 | <dd><p>Bases: <a class="reference internal" href="#sas.fit.ParkFitting.SasFitter" title="sas.fit.ParkFitting.SasFitter"><tt class="xref py py-class docutils literal"><span class="pre">sas.fit.ParkFitting.SasFitter</span></tt></a></p> |
---|
1012 | <p>Monte Carlo optimizer.</p> |
---|
1013 | <p>This implements <cite>park.fit.Fitter</cite>.</p> |
---|
1014 | <dl class="attribute"> |
---|
1015 | <dt id="sas.fit.ParkFitting.SasFitMC.localfit"> |
---|
1016 | <tt class="descname">localfit</tt><em class="property"> = <sas.fit.ParkFitting.SasFitSimplex object at 0x10ab534d0></em></dt> |
---|
1017 | <dd></dd></dl> |
---|
1018 | |
---|
1019 | <dl class="attribute"> |
---|
1020 | <dt id="sas.fit.ParkFitting.SasFitMC.start_points"> |
---|
1021 | <tt class="descname">start_points</tt><em class="property"> = 10</em></dt> |
---|
1022 | <dd></dd></dl> |
---|
1023 | |
---|
1024 | </dd></dl> |
---|
1025 | |
---|
1026 | <dl class="class"> |
---|
1027 | <dt id="sas.fit.ParkFitting.SasFitParameter"> |
---|
1028 | <em class="property">class </em><tt class="descclassname">sas.fit.ParkFitting.</tt><tt class="descname">SasFitParameter</tt><big>(</big><em>name</em>, <em>range</em>, <em>value</em>, <em>model</em>, <em>data</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/ParkFitting.html#SasFitParameter"><span class="viewcode-link">[source]</span></a></dt> |
---|
1029 | <dd><p>Bases: <a class="reference internal" href="park.html#park.fitresult.FitParameter" title="park.fitresult.FitParameter"><tt class="xref py py-class docutils literal"><span class="pre">park.fitresult.FitParameter</span></tt></a></p> |
---|
1030 | <p>Fit result for an individual parameter.</p> |
---|
1031 | <dl class="method"> |
---|
1032 | <dt id="sas.fit.ParkFitting.SasFitParameter.summarize"> |
---|
1033 | <tt class="descname">summarize</tt><big>(</big><big>)</big><a class="reference internal" href="../../_modules/sas/fit/ParkFitting.html#SasFitParameter.summarize"><span class="viewcode-link">[source]</span></a></dt> |
---|
1034 | <dd><p>Return parameter range string.</p> |
---|
1035 | <p>E.g., ” Gold .....|.... 5.2043 in [2,7]”</p> |
---|
1036 | </dd></dl> |
---|
1037 | |
---|
1038 | </dd></dl> |
---|
1039 | |
---|
1040 | <dl class="class"> |
---|
1041 | <dt id="sas.fit.ParkFitting.SasFitResult"> |
---|
1042 | <em class="property">class </em><tt class="descclassname">sas.fit.ParkFitting.</tt><tt class="descname">SasFitResult</tt><big>(</big><em>*args</em>, <em>**kwrds</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/ParkFitting.html#SasFitResult"><span class="viewcode-link">[source]</span></a></dt> |
---|
1043 | <dd><p>Bases: <a class="reference internal" href="park.html#park.fitresult.FitResult" title="park.fitresult.FitResult"><tt class="xref py py-class docutils literal"><span class="pre">park.fitresult.FitResult</span></tt></a></p> |
---|
1044 | </dd></dl> |
---|
1045 | |
---|
1046 | <dl class="class"> |
---|
1047 | <dt id="sas.fit.ParkFitting.SasFitSimplex"> |
---|
1048 | <em class="property">class </em><tt class="descclassname">sas.fit.ParkFitting.</tt><tt class="descname">SasFitSimplex</tt><big>(</big><em>ftol=5e-05</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/ParkFitting.html#SasFitSimplex"><span class="viewcode-link">[source]</span></a></dt> |
---|
1049 | <dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">park.fitmc.FitSimplex</span></tt></p> |
---|
1050 | <p>Local minimizer using Nelder-Mead simplex algorithm.</p> |
---|
1051 | <p>Simplex is robust and derivative free, though not very efficient.</p> |
---|
1052 | <p>This class wraps the bounds contrained Nelder-Mead simplex |
---|
1053 | implementation for <cite>park.simplex.simplex</cite>.</p> |
---|
1054 | <dl class="method"> |
---|
1055 | <dt id="sas.fit.ParkFitting.SasFitSimplex.fit"> |
---|
1056 | <tt class="descname">fit</tt><big>(</big><em>fitness</em>, <em>x0</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/ParkFitting.html#SasFitSimplex.fit"><span class="viewcode-link">[source]</span></a></dt> |
---|
1057 | <dd><p>Run the fit</p> |
---|
1058 | </dd></dl> |
---|
1059 | |
---|
1060 | <dl class="attribute"> |
---|
1061 | <dt id="sas.fit.ParkFitting.SasFitSimplex.ftol"> |
---|
1062 | <tt class="descname">ftol</tt><em class="property"> = 5e-05</em></dt> |
---|
1063 | <dd><p>Stop when vertex values are within ftol of each other</p> |
---|
1064 | </dd></dl> |
---|
1065 | |
---|
1066 | <dl class="attribute"> |
---|
1067 | <dt id="sas.fit.ParkFitting.SasFitSimplex.maxiter"> |
---|
1068 | <tt class="descname">maxiter</tt><em class="property"> = None</em></dt> |
---|
1069 | <dd><p>Maximum number of iterations before fit terminates</p> |
---|
1070 | </dd></dl> |
---|
1071 | |
---|
1072 | <dl class="attribute"> |
---|
1073 | <dt id="sas.fit.ParkFitting.SasFitSimplex.radius"> |
---|
1074 | <tt class="descname">radius</tt><em class="property"> = 0.05</em></dt> |
---|
1075 | <dd><p>Size of the initial simplex; this is a portion between 0 and 1</p> |
---|
1076 | </dd></dl> |
---|
1077 | |
---|
1078 | <dl class="attribute"> |
---|
1079 | <dt id="sas.fit.ParkFitting.SasFitSimplex.xtol"> |
---|
1080 | <tt class="descname">xtol</tt><em class="property"> = 1</em></dt> |
---|
1081 | <dd><p>Stop when simplex vertices are within xtol of each other</p> |
---|
1082 | </dd></dl> |
---|
1083 | |
---|
1084 | </dd></dl> |
---|
1085 | |
---|
1086 | <dl class="class"> |
---|
1087 | <dt id="sas.fit.ParkFitting.SasFitter"> |
---|
1088 | <em class="property">class </em><tt class="descclassname">sas.fit.ParkFitting.</tt><tt class="descname">SasFitter</tt><big>(</big><em>**kw</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/ParkFitting.html#SasFitter"><span class="viewcode-link">[source]</span></a></dt> |
---|
1089 | <dd><p>Bases: <a class="reference internal" href="park.html#park.fit.Fitter" title="park.fit.Fitter"><tt class="xref py py-class docutils literal"><span class="pre">park.fit.Fitter</span></tt></a></p> |
---|
1090 | <dl class="method"> |
---|
1091 | <dt id="sas.fit.ParkFitting.SasFitter.fit"> |
---|
1092 | <tt class="descname">fit</tt><big>(</big><em>fitness</em>, <em>handler</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/ParkFitting.html#SasFitter.fit"><span class="viewcode-link">[source]</span></a></dt> |
---|
1093 | <dd><p>Global optimizer.</p> |
---|
1094 | <p>This function should return immediately</p> |
---|
1095 | </dd></dl> |
---|
1096 | |
---|
1097 | </dd></dl> |
---|
1098 | |
---|
1099 | <dl class="class"> |
---|
1100 | <dt id="sas.fit.ParkFitting.SasParameter"> |
---|
1101 | <em class="property">class </em><tt class="descclassname">sas.fit.ParkFitting.</tt><tt class="descname">SasParameter</tt><big>(</big><em>name</em>, <em>model</em>, <em>data</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/ParkFitting.html#SasParameter"><span class="viewcode-link">[source]</span></a></dt> |
---|
1102 | <dd><p>Bases: <a class="reference internal" href="park.html#park.parameter.Parameter" title="park.parameter.Parameter"><tt class="xref py py-class docutils literal"><span class="pre">park.parameter.Parameter</span></tt></a></p> |
---|
1103 | <p>SAS model parameters for use in the PARK fitting service. |
---|
1104 | The parameter attribute value is redirected to the underlying |
---|
1105 | parameter value in the SAS model.</p> |
---|
1106 | <dl class="method"> |
---|
1107 | <dt id="sas.fit.ParkFitting.SasParameter.get_name"> |
---|
1108 | <tt class="descname">get_name</tt><big>(</big><big>)</big><a class="reference internal" href="../../_modules/sas/fit/ParkFitting.html#SasParameter.get_name"><span class="viewcode-link">[source]</span></a></dt> |
---|
1109 | <dd></dd></dl> |
---|
1110 | |
---|
1111 | <dl class="attribute"> |
---|
1112 | <dt id="sas.fit.ParkFitting.SasParameter.range"> |
---|
1113 | <tt class="descname">range</tt></dt> |
---|
1114 | <dd><p>Override _getrange of park parameter |
---|
1115 | return the range of parameter</p> |
---|
1116 | </dd></dl> |
---|
1117 | |
---|
1118 | <dl class="attribute"> |
---|
1119 | <dt id="sas.fit.ParkFitting.SasParameter.value"> |
---|
1120 | <tt class="descname">value</tt></dt> |
---|
1121 | <dd><p>override the _getvalue of park parameter</p> |
---|
1122 | <p>:return value the parameter associates with self.name</p> |
---|
1123 | </dd></dl> |
---|
1124 | |
---|
1125 | </dd></dl> |
---|
1126 | |
---|
1127 | <dl class="class"> |
---|
1128 | <dt id="sas.fit.ParkFitting.SasPart"> |
---|
1129 | <em class="property">class </em><tt class="descclassname">sas.fit.ParkFitting.</tt><tt class="descname">SasPart</tt><big>(</big><em>fitness</em>, <em>weight=1.0</em>, <em>isfitted=True</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/ParkFitting.html#SasPart"><span class="viewcode-link">[source]</span></a></dt> |
---|
1130 | <dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">park.assembly.Part</span></tt></p> |
---|
1131 | <p>Part of a fitting assembly. Part holds the model itself and |
---|
1132 | associated data. The part can be initialized with a fitness |
---|
1133 | object or with a pair (model,data) for the default fitness function.</p> |
---|
1134 | <dl class="docutils"> |
---|
1135 | <dt>fitness (Fitness)</dt> |
---|
1136 | <dd>object implementing the <cite>park.assembly.Fitness</cite> interface. In |
---|
1137 | particular, fitness should provide a parameterset attribute |
---|
1138 | containing a ParameterSet and a residuals method returning a vector |
---|
1139 | of residuals.</dd> |
---|
1140 | <dt>weight (dimensionless)</dt> |
---|
1141 | <dd>weight for the model. See comments in assembly.py for details.</dd> |
---|
1142 | <dt>isfitted (boolean)</dt> |
---|
1143 | <dd>True if the model residuals should be included in the fit. |
---|
1144 | The model parameters may still be used in parameter |
---|
1145 | expressions, but there will be no comparison to the data.</dd> |
---|
1146 | <dt>residuals (vector)</dt> |
---|
1147 | <dd>Residuals for the model if they have been calculated, or None</dd> |
---|
1148 | <dt>degrees_of_freedom</dt> |
---|
1149 | <dd>Number of residuals minus number of fitted parameters. |
---|
1150 | Degrees of freedom for individual models does not make |
---|
1151 | sense in the presence of expressions combining models, |
---|
1152 | particularly in the case where a model has many parameters |
---|
1153 | but no data or many computed parameters. The degrees of |
---|
1154 | freedom for the model is set to be at least one.</dd> |
---|
1155 | <dt>chisq</dt> |
---|
1156 | <dd><p class="first">sum(residuals**2); use chisq/degrees_of_freedom to |
---|
1157 | get the reduced chisq value.</p> |
---|
1158 | <p>Get/set the weight on the given model.</p> |
---|
1159 | <p class="last">assembly.weight(3) returns the weight on model 3 (0-origin) |
---|
1160 | assembly.weight(3,0.5) sets the weight on model 3 (0-origin)</p> |
---|
1161 | </dd> |
---|
1162 | </dl> |
---|
1163 | </dd></dl> |
---|
1164 | |
---|
1165 | </div> |
---|
1166 | <div class="section" id="module-sas.fit.ScipyFitting"> |
---|
1167 | <span id="sas-fit-scipyfitting-module"></span><h2>sas.fit.ScipyFitting module</h2> |
---|
1168 | <p>ScipyFitting module contains FitArrange , ScipyFit, |
---|
1169 | Parameter classes.All listed classes work together to perform a |
---|
1170 | simple fit with scipy optimizer.</p> |
---|
1171 | <dl class="class"> |
---|
1172 | <dt id="sas.fit.ScipyFitting.SasAssembly"> |
---|
1173 | <em class="property">class </em><tt class="descclassname">sas.fit.ScipyFitting.</tt><tt class="descname">SasAssembly</tt><big>(</big><em>paramlist</em>, <em>model=None</em>, <em>data=None</em>, <em>fitresult=None</em>, <em>handler=None</em>, <em>curr_thread=None</em>, <em>msg_q=None</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/ScipyFitting.html#SasAssembly"><span class="viewcode-link">[source]</span></a></dt> |
---|
1174 | <dd><p>Sas Assembly class a class wrapper to be call in optimizer.leastsq method</p> |
---|
1175 | <dl class="method"> |
---|
1176 | <dt id="sas.fit.ScipyFitting.SasAssembly.check_param_range"> |
---|
1177 | <tt class="descname">check_param_range</tt><big>(</big><big>)</big><a class="reference internal" href="../../_modules/sas/fit/ScipyFitting.html#SasAssembly.check_param_range"><span class="viewcode-link">[source]</span></a></dt> |
---|
1178 | <dd><p>Check the lower and upper bound of the parameter value |
---|
1179 | and set res to the inf if the value is outside of the |
---|
1180 | range |
---|
1181 | :limitation: the initial values must be within range.</p> |
---|
1182 | </dd></dl> |
---|
1183 | |
---|
1184 | <dl class="method"> |
---|
1185 | <dt id="sas.fit.ScipyFitting.SasAssembly.chisq"> |
---|
1186 | <tt class="descname">chisq</tt><big>(</big><big>)</big><a class="reference internal" href="../../_modules/sas/fit/ScipyFitting.html#SasAssembly.chisq"><span class="viewcode-link">[source]</span></a></dt> |
---|
1187 | <dd><p>Calculates chi^2</p> |
---|
1188 | <table class="docutils field-list" frame="void" rules="none"> |
---|
1189 | <col class="field-name" /> |
---|
1190 | <col class="field-body" /> |
---|
1191 | <tbody valign="top"> |
---|
1192 | <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>params</strong> – list of parameter values</td> |
---|
1193 | </tr> |
---|
1194 | <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">chi^2</td> |
---|
1195 | </tr> |
---|
1196 | </tbody> |
---|
1197 | </table> |
---|
1198 | </dd></dl> |
---|
1199 | |
---|
1200 | </dd></dl> |
---|
1201 | |
---|
1202 | <dl class="class"> |
---|
1203 | <dt id="sas.fit.ScipyFitting.ScipyFit"> |
---|
1204 | <em class="property">class </em><tt class="descclassname">sas.fit.ScipyFitting.</tt><tt class="descname">ScipyFit</tt><a class="reference internal" href="../../_modules/sas/fit/ScipyFitting.html#ScipyFit"><span class="viewcode-link">[source]</span></a></dt> |
---|
1205 | <dd><p>Bases: <a class="reference internal" href="#sas.fit.AbstractFitEngine.FitEngine" title="sas.fit.AbstractFitEngine.FitEngine"><tt class="xref py py-class docutils literal"><span class="pre">sas.fit.AbstractFitEngine.FitEngine</span></tt></a></p> |
---|
1206 | <p>ScipyFit performs the Fit.This class can be used as follow: |
---|
1207 | #Do the fit SCIPY |
---|
1208 | create an engine: engine = ScipyFit() |
---|
1209 | Use data must be of type plottable |
---|
1210 | Use a sas model</p> |
---|
1211 | <p>Add data with a dictionnary of FitArrangeDict where Uid is a key and data |
---|
1212 | is saved in FitArrange object. |
---|
1213 | engine.set_data(data,Uid)</p> |
---|
1214 | <p>Set model parameter “M1”= model.name add {model.parameter.name:value}.</p> |
---|
1215 | <table class="docutils field-list" frame="void" rules="none"> |
---|
1216 | <col class="field-name" /> |
---|
1217 | <col class="field-body" /> |
---|
1218 | <tbody valign="top"> |
---|
1219 | <tr class="field-odd field"><th class="field-name">Note:</th><td class="field-body">Set_param() if used must always preceded set_model() |
---|
1220 | for the fit to be performed.In case of Scipyfit set_param is called in |
---|
1221 | fit () automatically.</td> |
---|
1222 | </tr> |
---|
1223 | </tbody> |
---|
1224 | </table> |
---|
1225 | <p>engine.set_param( model,”M1”, {‘A’:2,’B’:4})</p> |
---|
1226 | <p>Add model with a dictionnary of FitArrangeDict{} where Uid is a key and model |
---|
1227 | is save in FitArrange object. |
---|
1228 | engine.set_model(model,Uid)</p> |
---|
1229 | <p>engine.fit return chisqr,[model.parameter 1,2,..],[[err1....][..err2...]] |
---|
1230 | chisqr1, out1, cov1=engine.fit({model.parameter.name:value},qmin,qmax)</p> |
---|
1231 | <dl class="method"> |
---|
1232 | <dt id="sas.fit.ScipyFitting.ScipyFit.fit"> |
---|
1233 | <tt class="descname">fit</tt><big>(</big><em>msg_q=None</em>, <em>q=None</em>, <em>handler=None</em>, <em>curr_thread=None</em>, <em>ftol=1.49012e-08</em>, <em>reset_flag=False</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/ScipyFitting.html#ScipyFit.fit"><span class="viewcode-link">[source]</span></a></dt> |
---|
1234 | <dd></dd></dl> |
---|
1235 | |
---|
1236 | </dd></dl> |
---|
1237 | |
---|
1238 | </div> |
---|
1239 | <div class="section" id="module-sas.fit.expression"> |
---|
1240 | <span id="sas-fit-expression-module"></span><h2>sas.fit.expression module</h2> |
---|
1241 | <p>Parameter expression evaluator.</p> |
---|
1242 | <p>For systems in which constraints are expressed as string expressions rather |
---|
1243 | than python code, <a class="reference internal" href="#sas.fit.expression.compile_constraints" title="sas.fit.expression.compile_constraints"><tt class="xref py py-func docutils literal"><span class="pre">compile_constraints()</span></tt></a> can construct an expression |
---|
1244 | evaluator that substitutes the computed values of the expressions into the |
---|
1245 | parameters.</p> |
---|
1246 | <p>The compiler requires a symbol table, an expression set and a context. |
---|
1247 | The symbol table maps strings containing fully qualified names such as |
---|
1248 | ‘M1.c[3].full_width’ to parameter objects with a ‘value’ property that |
---|
1249 | can be queried and set. The expression set maps symbol names from the |
---|
1250 | symbol table to string expressions. The context provides additional symbols |
---|
1251 | for the expressions in addition to the usual mathematical functions and |
---|
1252 | constants.</p> |
---|
1253 | <p>The expressions are compiled and interpreted by python, with only minimal |
---|
1254 | effort to make sure that they don’t contain bad code. The resulting |
---|
1255 | constraints function returns 0 so it can be used directly in a fit problem |
---|
1256 | definition.</p> |
---|
1257 | <p>Extracting the symbol table from the model depends on the structure of the |
---|
1258 | model. If fitness.parameters() is set correctly, then this should simply |
---|
1259 | be a matter of walking the parameter data, remembering the path to each |
---|
1260 | parameter in the symbol table. For compactness, dictionary elements should |
---|
1261 | be referenced by .name rather than [“name”]. Model name can be used as the |
---|
1262 | top level.</p> |
---|
1263 | <p>Getting the parameter expressions applied correctly is challenging. |
---|
1264 | The following monkey patch works by overriding model_update in FitProblem |
---|
1265 | so that after setp(p) is called and, the constraints expression can be |
---|
1266 | applied before telling the underlying fitness function that the model |
---|
1267 | is out of date:</p> |
---|
1268 | <div class="highlight-python"><div class="highlight"><pre><span class="c"># Override model update so that parameter constraints are applied</span> |
---|
1269 | <span class="n">problem</span><span class="o">.</span><span class="n">_model_update</span> <span class="o">=</span> <span class="n">problem</span><span class="o">.</span><span class="n">model_update</span> |
---|
1270 | <span class="k">def</span> <span class="nf">model_update</span><span class="p">():</span> |
---|
1271 | <span class="n">constraints</span><span class="p">()</span> |
---|
1272 | <span class="n">problem</span><span class="o">.</span><span class="n">_model_update</span><span class="p">()</span> |
---|
1273 | <span class="n">problem</span><span class="o">.</span><span class="n">model_update</span> <span class="o">=</span> <span class="n">model_update</span> |
---|
1274 | </pre></div> |
---|
1275 | </div> |
---|
1276 | <p>Ideally, this interface will change</p> |
---|
1277 | <dl class="function"> |
---|
1278 | <dt id="sas.fit.expression.compile_constraints"> |
---|
1279 | <tt class="descclassname">sas.fit.expression.</tt><tt class="descname">compile_constraints</tt><big>(</big><em>symtab</em>, <em>exprs</em>, <em>context={}</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/expression.html#compile_constraints"><span class="viewcode-link">[source]</span></a></dt> |
---|
1280 | <dd><p>Build and return a function to evaluate all parameter expressions in |
---|
1281 | the proper order.</p> |
---|
1282 | <p>Input:</p> |
---|
1283 | <blockquote> |
---|
1284 | <div><p><em>symtab</em> is the symbol table for the model: { ‘name’: parameter }</p> |
---|
1285 | <p><em>exprs</em> is the set of computed symbols: { ‘name’: ‘expression’ }</p> |
---|
1286 | <p><em>context</em> is any additional context needed to evaluate the expression</p> |
---|
1287 | </div></blockquote> |
---|
1288 | <p>Return:</p> |
---|
1289 | <blockquote> |
---|
1290 | <div>updater function which sets parameter.value for each expression</div></blockquote> |
---|
1291 | <p>Raises:</p> |
---|
1292 | <blockquote> |
---|
1293 | <div><p>AssertionError - model, parameter or function is missing</p> |
---|
1294 | <p>SyntaxError - improper expression syntax</p> |
---|
1295 | <p>ValueError - expressions have circular dependencies</p> |
---|
1296 | </div></blockquote> |
---|
1297 | <p>This function is not terribly sophisticated, and it would be easy to |
---|
1298 | trick. However it handles the common cases cleanly and generates |
---|
1299 | reasonable messages for the common errors.</p> |
---|
1300 | <p>This code has not been fully audited for security. While we have |
---|
1301 | removed the builtins and the ability to import modules, there may |
---|
1302 | be other vectors for users to perform more than simple function |
---|
1303 | evaluations. Unauthenticated users should not be running this code.</p> |
---|
1304 | <p>Parameter names are assumed to contain only _.a-zA-Z0-9#[]</p> |
---|
1305 | <p>Both names are provided for inverse functions, e.g., acos and arccos.</p> |
---|
1306 | <p>Should try running the function to identify syntax errors before |
---|
1307 | running it in a fit.</p> |
---|
1308 | <p>Use help(fn) to see the code generated for the returned function fn. |
---|
1309 | dis.dis(fn) will show the corresponding python vm instructions.</p> |
---|
1310 | </dd></dl> |
---|
1311 | |
---|
1312 | <dl class="function"> |
---|
1313 | <dt id="sas.fit.expression.no_constraints"> |
---|
1314 | <tt class="descclassname">sas.fit.expression.</tt><tt class="descname">no_constraints</tt><big>(</big><big>)</big><a class="reference internal" href="../../_modules/sas/fit/expression.html#no_constraints"><span class="viewcode-link">[source]</span></a></dt> |
---|
1315 | <dd><p>This parameter set has no constraints between the parameters.</p> |
---|
1316 | </dd></dl> |
---|
1317 | |
---|
1318 | <dl class="function"> |
---|
1319 | <dt id="sas.fit.expression.order_dependencies"> |
---|
1320 | <tt class="descclassname">sas.fit.expression.</tt><tt class="descname">order_dependencies</tt><big>(</big><em>pairs</em><big>)</big><a class="reference internal" href="../../_modules/sas/fit/expression.html#order_dependencies"><span class="viewcode-link">[source]</span></a></dt> |
---|
1321 | <dd><p>Order elements from pairs so that b comes before a in the |
---|
1322 | ordered list for all pairs (a,b).</p> |
---|
1323 | </dd></dl> |
---|
1324 | |
---|
1325 | <dl class="function"> |
---|
1326 | <dt id="sas.fit.expression.test_deps"> |
---|
1327 | <tt class="descclassname">sas.fit.expression.</tt><tt class="descname">test_deps</tt><big>(</big><big>)</big><a class="reference internal" href="../../_modules/sas/fit/expression.html#test_deps"><span class="viewcode-link">[source]</span></a></dt> |
---|
1328 | <dd></dd></dl> |
---|
1329 | |
---|
1330 | <dl class="function"> |
---|
1331 | <dt id="sas.fit.expression.test_expr"> |
---|
1332 | <tt class="descclassname">sas.fit.expression.</tt><tt class="descname">test_expr</tt><big>(</big><big>)</big><a class="reference internal" href="../../_modules/sas/fit/expression.html#test_expr"><span class="viewcode-link">[source]</span></a></dt> |
---|
1333 | <dd></dd></dl> |
---|
1334 | |
---|
1335 | </div> |
---|
1336 | <div class="section" id="module-sas.fit"> |
---|
1337 | <span id="module-contents"></span><h2>Module contents</h2> |
---|
1338 | </div> |
---|
1339 | </div> |
---|
1340 | |
---|
1341 | |
---|
1342 | </div> |
---|
1343 | </div> |
---|
1344 | </div> |
---|
1345 | <div class="sphinxsidebar"> |
---|
1346 | <div class="sphinxsidebarwrapper"> |
---|
1347 | <h3><a href="../../index.html">Table Of Contents</a></h3> |
---|
1348 | <ul> |
---|
1349 | <li><a class="reference internal" href="#">sas.fit package</a><ul> |
---|
1350 | <li><a class="reference internal" href="#submodules">Submodules</a></li> |
---|
1351 | <li><a class="reference internal" href="#module-sas.fit.AbstractFitEngine">sas.fit.AbstractFitEngine module</a></li> |
---|
1352 | <li><a class="reference internal" href="#module-sas.fit.BumpsFitting">sas.fit.BumpsFitting module</a></li> |
---|
1353 | <li><a class="reference internal" href="#module-sas.fit.Fitting">sas.fit.Fitting module</a></li> |
---|
1354 | <li><a class="reference internal" href="#module-sas.fit.Loader">sas.fit.Loader module</a></li> |
---|
1355 | <li><a class="reference internal" href="#module-sas.fit.ParkFitting">sas.fit.ParkFitting module</a></li> |
---|
1356 | <li><a class="reference internal" href="#module-sas.fit.ScipyFitting">sas.fit.ScipyFitting module</a></li> |
---|
1357 | <li><a class="reference internal" href="#module-sas.fit.expression">sas.fit.expression module</a></li> |
---|
1358 | <li><a class="reference internal" href="#module-sas.fit">Module contents</a></li> |
---|
1359 | </ul> |
---|
1360 | </li> |
---|
1361 | </ul> |
---|
1362 | |
---|
1363 | <h4>Previous topic</h4> |
---|
1364 | <p class="topless"><a href="sas.dataloader.readers.html" |
---|
1365 | title="previous chapter">sas.dataloader.readers package</a></p> |
---|
1366 | <h4>Next topic</h4> |
---|
1367 | <p class="topless"><a href="sas.guiframe.html" |
---|
1368 | title="next chapter">sas.guiframe package</a></p> |
---|
1369 | <h3>This Page</h3> |
---|
1370 | <ul class="this-page-menu"> |
---|
1371 | <li><a href="../../_sources/dev/api/sas.fit.txt" |
---|
1372 | rel="nofollow">Show Source</a></li> |
---|
1373 | </ul> |
---|
1374 | <div id="searchbox" style="display: none"> |
---|
1375 | <h3>Quick search</h3> |
---|
1376 | <form class="search" action="../../search.html" method="get"> |
---|
1377 | <input type="text" name="q" /> |
---|
1378 | <input type="submit" value="Go" /> |
---|
1379 | <input type="hidden" name="check_keywords" value="yes" /> |
---|
1380 | <input type="hidden" name="area" value="default" /> |
---|
1381 | </form> |
---|
1382 | <p class="searchtip" style="font-size: 90%"> |
---|
1383 | Enter search terms or a module, class or function name. |
---|
1384 | </p> |
---|
1385 | </div> |
---|
1386 | <script type="text/javascript">$('#searchbox').show(0);</script> |
---|
1387 | </div> |
---|
1388 | </div> |
---|
1389 | <div class="clearer"></div> |
---|
1390 | </div> |
---|
1391 | <div class="related"> |
---|
1392 | <h3>Navigation</h3> |
---|
1393 | <ul> |
---|
1394 | <li class="right" style="margin-right: 10px"> |
---|
1395 | <a href="../../genindex.html" title="General Index" |
---|
1396 | >index</a></li> |
---|
1397 | <li class="right" > |
---|
1398 | <a href="../../py-modindex.html" title="Python Module Index" |
---|
1399 | >modules</a> |</li> |
---|
1400 | <li class="right" > |
---|
1401 | <a href="sas.guiframe.html" title="sas.guiframe package" |
---|
1402 | >next</a> |</li> |
---|
1403 | <li class="right" > |
---|
1404 | <a href="sas.dataloader.readers.html" title="sas.dataloader.readers package" |
---|
1405 | >previous</a> |</li> |
---|
1406 | <li><a href="../../index.html">SasView 3.0.0 documentation</a> »</li> |
---|
1407 | <li><a href="../dev.html" >Developer Documentation</a> »</li> |
---|
1408 | <li><a href="modules.html" >lib.macosx-10.5-x86_64-2.7</a> »</li> |
---|
1409 | <li><a href="sas.html" >sas package</a> »</li> |
---|
1410 | </ul> |
---|
1411 | </div> |
---|
1412 | <div class="footer"> |
---|
1413 | © Copyright 2013, The SasView Project. |
---|
1414 | Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.3. |
---|
1415 | </div> |
---|
1416 | </body> |
---|
1417 | </html> |
---|