SasView: Ticket Query
http://trac.sasview.org/query?status=!closed&reporter=toqduj&order=priority
SasView - Open Source SAS Data Analysis Softwareen-USTrac 1.0.1
http://trac.sasview.org/ticket/1171
http://trac.sasview.org/ticket/1171#1171: Expose volume calculation in SasModelsSat, 08 Sep 2018 13:21:25 GMTtoqduj<p>
McSAS relies on the ability to weigh the contributions based on their volume in its optimisation routine. This means that we need to be able to get a volume for a given contribution from <a class="missing wiki">SasModels?</a>.
</p>
<p>
At the moment, the kernel can be queried for the volume of the last-calculated iteration:
</p>
<pre class="wiki">kernel.result[kernel.q_input.nq]
</pre><p>
Paul Kienzle commented on this a while back:
"
For your case (without dispersion) the form_volume is already computed by the kernel and returned as the final element in the result. You should be able to grab it using kernel.result[kernel.q_input.nq] after calculating the kernel. This is a side-effect of the current implementation and not part of the formal interface; it will not work for pure python models, but should work for C models run as dll or as OpenCL.
</p>
<p>
[…]
</p>
<p>
If we were to make this a formal interface, we would need to generalize it to the case of dispersion-weighted volume average by additionally accumulating the sum of the weights in result[nq+1], then defining self.average_volume = result[nq]/result[nq+1]. Something similar could be done in the python kernel loop.
"
</p>
Resultshttp://trac.sasview.org/ticket/1171#changelog
http://trac.sasview.org/ticket/1172
http://trac.sasview.org/ticket/1172#1172: Allow "polydispersity" to be defined by series/sets of uncorrelated, discrete pointsSat, 08 Sep 2018 14:25:07 GMTtoqduj<p>
The output from a McSAS optimisation is a set of uncorrelated contributions, the sum of which comprises the scattered intensity.
</p>
<p>
As discussed during the <a class="missing wiki">SasView?</a> Code camp McSAS session, defining a parameter's polydispersity using either/or a classical definition and a freeform (e.g. McSAS) definition would require that the <a class="missing wiki">SasModels?</a> calculation can handle a range of freeform distributions.
</p>
<p>
While there is some sort of freeform distribution already implemented using a set of points and scaling factors (between which there is interpolation going on), The McSAS definition makes no assumption of the relationship between the points. For example, a set of ten McSAS cylinder contributions with a fixed length might (conceptually) look like this:
</p>
<ul><li>cylinder, diameter 3.4211
</li><li>cylinder, diameter 1.1235
</li><li>cylinder, diameter 2.1098
</li><li>cylinder, diameter 2.0983
</li><li>cylinder, diameter 4.0917
</li><li>cylinder, diameter 3.0918
</li><li>cylinder, diameter 1.091
</li><li>cylinder, diameter 2.901
</li><li>cylinder, diameter 2.998
</li><li>cylinder, diameter 3.116
</li></ul><p>
Note that a typical scattering pattern can easily be described using about 200 or 300 such contributions that make up a scattering pattern, when each contribution is scaled by its surface or volume, not the normal volume-squared scaling. This has the effect of suppressing the scattering of large contributions so that the smaller ones become visible, which is taken into account when visualising the result in a number- volume- or surface-weighted distribution.
</p>
<p>
Anyway, back to the topic. The idea during the <a class="missing wiki">SasView?</a> code camp was to enable a workflow that looked like this:
</p>
<ul><li>optimize a set of 1D or 2D model parameters using a classical optimisation
</li><li>pick one to three parameters to be optimised using a McSAS optimisation core, fixing all parameters except for the background- and scaling parameters (which are least-squares optimised for every McSAS iteration).
</li><li>get a coffee
</li><li>allow for re-optimization of the remaining model parameters using classical optimisation, fixing the McSAS-optimized parameter distributions
</li></ul><p>
Another aspect to note is that the uncertainties on the McSAS parameter distributions come from the analysis of variance from repeated, independent MC results in the optional histogramming (visualisation) phase. So, theoretically, you'd automatically repeat the above optimisation sequence a number of times to get a nice mean and standard error on the mean.
</p>
<p>
Back (again) to the topic at hand, for starters we would need a method that returns a calculated intensity as the sum (or average) of a set of individual contributions, each with its own parameters.
</p>
<p>
That's at least as far as I can imagine for now. This could be in <a class="missing wiki">SasModels?</a> or in <a class="missing wiki">SasView?</a>..
</p>
Resultshttp://trac.sasview.org/ticket/1172#changelog