Index: sansmodels/src/media/smear_computation.html
===================================================================
--- sansmodels/src/media/smear_computation.html	(revision 6e8b436b9448bd5d8b9b0fc4d82be7766f274b7e)
+++ sansmodels/src/media/smear_computation.html	(revision 6e8b436b9448bd5d8b9b0fc4d82be7766f274b7e)
@@ -0,0 +1,395 @@
+<html>
+
+<head>
+<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
+<meta name=Generator content="Microsoft Word 12 (filtered)">
+<style>
+<!--
+ /* Font Definitions */
+ @font-face
+	{font-family:Wingdings;
+	panose-1:5 0 0 0 0 0 0 0 0 0;}
+@font-face
+	{font-family:"Cambria Math";
+	panose-1:2 4 5 3 5 4 6 3 2 4;}
+@font-face
+	{font-family:Calibri;
+	panose-1:2 15 5 2 2 2 4 3 2 4;}
+@font-face
+	{font-family:Tahoma;
+	panose-1:2 11 6 4 3 5 4 4 2 4;}
+ /* Style Definitions */
+ p.MsoNormal, li.MsoNormal, div.MsoNormal
+	{margin-top:0in;
+	margin-right:0in;
+	margin-bottom:10.0pt;
+	margin-left:0in;
+	line-height:115%;
+	font-size:11.0pt;
+	font-family:"Calibri","sans-serif";}
+p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
+	{mso-style-link:"Balloon Text Char";
+	margin:0in;
+	margin-bottom:.0001pt;
+	font-size:8.0pt;
+	font-family:"Tahoma","sans-serif";}
+p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
+	{margin-top:0in;
+	margin-right:0in;
+	margin-bottom:10.0pt;
+	margin-left:.5in;
+	line-height:115%;
+	font-size:11.0pt;
+	font-family:"Calibri","sans-serif";}
+p.MsoListParagraphCxSpFirst, li.MsoListParagraphCxSpFirst, div.MsoListParagraphCxSpFirst
+	{margin-top:0in;
+	margin-right:0in;
+	margin-bottom:0in;
+	margin-left:.5in;
+	margin-bottom:.0001pt;
+	line-height:115%;
+	font-size:11.0pt;
+	font-family:"Calibri","sans-serif";}
+p.MsoListParagraphCxSpMiddle, li.MsoListParagraphCxSpMiddle, div.MsoListParagraphCxSpMiddle
+	{margin-top:0in;
+	margin-right:0in;
+	margin-bottom:0in;
+	margin-left:.5in;
+	margin-bottom:.0001pt;
+	line-height:115%;
+	font-size:11.0pt;
+	font-family:"Calibri","sans-serif";}
+p.MsoListParagraphCxSpLast, li.MsoListParagraphCxSpLast, div.MsoListParagraphCxSpLast
+	{margin-top:0in;
+	margin-right:0in;
+	margin-bottom:10.0pt;
+	margin-left:.5in;
+	line-height:115%;
+	font-size:11.0pt;
+	font-family:"Calibri","sans-serif";}
+span.BalloonTextChar
+	{mso-style-name:"Balloon Text Char";
+	mso-style-link:"Balloon Text";
+	font-family:"Tahoma","sans-serif";}
+.MsoPapDefault
+	{margin-bottom:10.0pt;
+	line-height:115%;}
+@page WordSection1
+	{size:8.5in 11.0in;
+	margin:1.0in 1.0in 1.0in 1.0in;}
+div.WordSection1
+	{page:WordSection1;}
+ /* List Definitions */
+ ol
+	{margin-bottom:0in;}
+ul
+	{margin-bottom:0in;}
+-->
+</style>
+
+</head>
+
+<body lang=EN-US>
+
+<div class=WordSection1>
+
+<p class=MsoNormal><span style='font-size:16.0pt;line-height:115%;font-family:
+"Times New Roman","serif"'>Smear Computation </span></p>
+<p class=MsoNormal>&nbsp;</p>
+
+<ul style='margin-top:0in' type=disc>
+ <li class=MsoNormal style='line-height:115%'><a href="#Slit Smear"><b>Slit Smear</b></a>
+     </li>
+ <li class=MsoNormal style='line-height:115%'><a href="#Pinhole Smear"><b>Pinhole Smear</b></a>
+	</li>
+ <li class=MsoNormal style='line-height:115%'><a href="#2D Smear"><b>2D Smear</b></a> 
+	</li>
+</ul>
+<p class=MsoNormal>&nbsp;</p>
+<p class=MsoNormal>&nbsp;</p>
+<p class=MsoListParagraph><span style='font-size:14.0pt;line-height:115%;
+font-family:"Times New Roman","serif"'><a name="Slit Smear">Slit Smear</a></span></p>
+
+<p class=MsoNormal><span style='font-family:"Times New Roman","serif"'>The sit
+smeared scattering intensity for SANS is defined by</span></p>
+
+<p class=MsoNormal><img width=349 height=49
+src="sm_image002.gif" align=left hspace=12></p>
+
+<p class=MsoNormal><span style='font-family:"Times New Roman","serif"'>           
+                                 1)</span><br clear=all>
+<span style='font-family:"Times New Roman","serif"'>where Norm = <span
+style='position:relative;top:15.0pt'><img width=137 height=49
+src="sm_image003.gif"></span>.</span></p>
+
+<p class=MsoNormal><span style='font-family:"Times New Roman","serif"'>The
+functions <span style='position:relative;top:6.0pt'><img width=43 height=25
+src="sm_image004.gif"></span>and <span style='position:
+relative;top:6.0pt'><img width=43 height=25
+src="sm_image005.gif"></span>refer to the slit width weighting
+function and the slit height weighting determined at the q point, respectively.
+ Here, we assumes that the weighting function is described by a rectangular
+function, i.e.,</span></p>
+
+<p class=MsoNormal><span style='position:relative;top:7.0pt'><img width=134
+height=26 src="sm_image006.gif">                                                                                                       
+  </span><span style='font-family:"Times New Roman","serif";position:relative;
+top:7.0pt'>2)</span></p>
+
+<p class=MsoNormal><span style='font-family:"Times New Roman","serif"'>and </span></p>
+
+<p class=MsoNormal><span style='position:relative;top:7.0pt'><img width=136
+height=26 src="sm_image007.gif"></span>,                                                                              
+                         <span style='font-family:"Times New Roman","serif"'>3)</span></p>
+
+<p class=MsoNormal><span style='font-family:"Times New Roman","serif"'>so that </span><span
+style='position:relative;top:6.0pt'><img width=58 height=23
+src="sm_image008.gif"></span> <span style='position:relative;
+top:16.0pt'><img width=76 height=51 src="sm_image009.gif"></span> <span
+style='font-family:"Times New Roman","serif"'>for</span>  <span
+style='position:relative;top:3.0pt'><img width=40 height=15
+src="sm_image010.gif"></span> <span style='font-family:
+"Times New Roman","serif"'>and <i>u</i>. The </span><span style='position:relative;
+top:6.0pt'><img width=28 height=24 src="sm_image011.gif"></span> <span
+style='font-family:"Times New Roman","serif"'>and </span><span
+style='position:relative;top:6.0pt'><img width=28 height=24
+src="sm_image012.gif"> </span><span style='font-family:
+"Times New Roman","serif"'>stand for the slit height (FWHM/2) and the slit
+width (FWHM/2) in the q space. Now the integral of Eq. (1) is simplified to</span></p>
+
+<p class=MsoNormal><img width=283 height=52
+src="sm_image013.gif" align=left hspace=12><span
+style='font-family:"Times New Roman","serif"'>                                                  
+         4)</span></p>
+
+<p class=MsoNormal><span style='font-family:"Times New Roman","serif";
+position:relative;top:20.0pt'>&nbsp;</span></p>
+
+<p class=MsoListParagraphCxSpFirst style='margin-left:0in'><b><span
+style='font-family:"Times New Roman","serif"'>Numerical Implementation of Eq.
+(4) </span></b></p>
+
+<p class=MsoListParagraphCxSpMiddle style='margin-left:.25in;text-indent:-.25in'><span
+style='font-family:"Times New Roman","serif"'>1)<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+</span></span><span style='font-family:"Times New Roman","serif"'>For </span><span
+style='position:relative;top:6.0pt'><img width=28 height=24
+src="sm_image014.gif"></span>= 0  <span style='font-family:
+"Times New Roman","serif"'>and </span><span style='position:relative;
+top:6.0pt'><img width=28 height=24 src="sm_image015.gif"></span> =
+<span style='font-family:"Times New Roman","serif"'>constant:</span></p>
+
+<p class=MsoListParagraphCxSpMiddle style='margin-left:.25in'>
+<img 
+src="sm_image016.gif"></p>
+
+<p class=MsoListParagraphCxSpMiddle style='margin-left:.25in'><span
+style='font-family:"Times New Roman","serif"'>For discrete q values, at the q
+values from the data points and at the q values extended up to  q<sub>N</sub>=
+q<sub>i</sub> + </span><span style='position:relative;top:6.0pt'><img width=28
+height=24 src="sm_image011.gif"></span><span
+style='font-family:"Times New Roman","serif"'>, the smeared intensity can be
+calculated approximately,</span></p>
+
+<p class=MsoListParagraphCxSpMiddle style='margin-left:.25in'><img 
+src="sm_image017.gif">.                                                           <span
+style='font-family:"Times New Roman","serif"'>5)</span></p>
+
+<p class=MsoListParagraphCxSpMiddle style='margin-left:.25in'><span
+style='position:relative;top:7.0pt'><img width=23 height=25
+src="sm_image018.gif"></span> <span style='font-family:
+"Times New Roman","serif"'>= 0 for <i>I<sub>s</sub></i> in</span> <i><span
+style='font-family:"Times New Roman","serif"'>j &lt; i</span></i><span
+style='font-family:"Times New Roman","serif"'> or<i> j&gt;N-1</i>.</span></p>
+
+<p class=MsoListParagraphCxSpMiddle style='margin-left:.25in'><span
+style='font-family:"Times New Roman","serif"'>&nbsp;</span></p>
+
+<p class=MsoListParagraphCxSpMiddle style='margin-left:.25in;text-indent:-.25in'><span
+style='font-family:"Times New Roman","serif"'>2)<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+</span></span><span style='font-family:"Times New Roman","serif"'>For  </span><span
+style='position:relative;top:6.0pt'><img width=28 height=24
+src="sm_image014.gif"></span>= <span style='font-family:
+"Times New Roman","serif"'>constant </span> <span style='font-family:"Times New Roman","serif"'>and
+</span><span style='position:relative;top:6.0pt'><img width=28 height=24
+src="sm_image015.gif"></span> = <span style='font-family:
+"Times New Roman","serif"'>0:</span></p>
+
+<p class=MsoListParagraphCxSpMiddle style='margin-left:.25in'><span
+style='font-family:"Times New Roman","serif"'>Similarly to 1), we get</span></p>
+
+<p class=MsoListParagraphCxSpMiddle style='margin-left:.25in'>
+<img 
+src="sm_image019.gif">                                                                                        
+<span
+style='font-family:"Times New Roman","serif"'>6)</span></p>
+
+<p class=MsoListParagraphCxSpMiddle style='margin-left:.25in'><span
+style='font-family:"Times New Roman","serif"'>for  q<sub>p</sub> = q<sub>i</sub>
+- </span><span style='position:relative;top:6.0pt'><img width=28 height=24
+src="sm_image012.gif"></span><span style='font-family:
+"Times New Roman","serif"'> and</span> <span style='font-family:"Times New Roman","serif"'>q<sub>N</sub>
+= q<sub>i</sub> + </span><span style='position:relative;top:6.0pt'><img
+width=28 height=24 src="sm_image012.gif"></span>.  <span
+style='position:relative;top:7.0pt'><img width=23 height=25
+src="sm_image018.gif"></span> <span style='font-family:
+"Times New Roman","serif"'>= 0 for <i>I<sub>s</sub></i> in</span> <i><span
+style='font-family:"Times New Roman","serif"'>j &lt; p</span></i><span
+style='font-family:"Times New Roman","serif"'> or<i> j&gt;N-1</i>.</span></p>
+
+<p class=MsoListParagraphCxSpMiddle style='margin-left:.25in'>&nbsp;</p>
+
+<p class=MsoListParagraphCxSpMiddle style='margin-left:.25in;text-indent:-.25in'><span
+style='font-family:"Times New Roman","serif"'>3)<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+</span></span><span style='font-family:"Times New Roman","serif"'>For  </span><span
+style='position:relative;top:6.0pt'><img width=28 height=24
+src="sm_image014.gif"></span>= <span style='font-family:
+"Times New Roman","serif"'>constant </span> <span style='font-family:"Times New Roman","serif"'>and
+</span><span style='position:relative;top:6.0pt'><img width=28 height=24
+src="sm_image015.gif"></span> = <span style='font-family:
+"Times New Roman","serif"'>constant:</span></p>
+
+<p class=MsoListParagraphCxSpMiddle style='margin-left:.25in'><span
+style='font-family:"Times New Roman","serif"'>This case, the best way is to
+perform the integration, Eq. (1), numerically for both slit height and width.
+However, the numerical integration is not correct enough unless given a large
+number of iteration, say at least 10000 by 10000 for each element of the matrix
+W, which will take minutes and minutes to finish the calculation for a set of
+typical SANS data. An alternative way which is correct for slit width &lt;&lt;
+slit hight, is used in the SANSView:  This method is a mixed method that
+combines the method 1) with the numerical integration for the slit width.</span></p>
+
+<p class=MsoListParagraphCxSpMiddle style='margin-left:.25in'>
+</p>
+
+<p class=MsoListParagraphCxSpMiddle style='margin-left:.25in'>
+<img 
+src="sm_image020.gif">    <span style='font-family:
+"Times New Roman","serif"'>(7)</span></p>
+
+<p class=MsoListParagraphCxSpMiddle style='margin-left:.25in'><span
+style='font-family:"Times New Roman","serif"'>for  q<sub>p</sub> = q<sub>i</sub>
+- </span><span style='position:relative;top:6.0pt'><img width=28 height=24
+src="sm_image012.gif"></span><span style='font-family:
+"Times New Roman","serif"'> and</span> <span style='font-family:"Times New Roman","serif"'>q<sub>N</sub>
+= q<sub>i</sub> + </span><span style='position:relative;top:6.0pt'><img
+width=28 height=24 src="sm_image012.gif"></span>.  <span
+style='position:relative;top:7.0pt'><img width=23 height=25
+src="sm_image018.gif"></span> <span style='font-family:
+"Times New Roman","serif"'>= 0 for <i>I<sub>s</sub></i> in</span> <i><span
+style='font-family:"Times New Roman","serif"'>j &lt; p</span></i><span
+style='font-family:"Times New Roman","serif"'> or<i> j&gt;N-1</i>. </span></p>
+
+<p class=MsoListParagraphCxSpMiddle style='margin-left:.25in'><span
+style='font-family:"Times New Roman","serif"'>&nbsp;</span></p>
+
+<p class=MsoListParagraphCxSpMiddle style='margin-left:.25in'><span
+style='font-family:"Times New Roman","serif"'>&nbsp;</span></p>
+
+<p class=MsoListParagraphCxSpLast><span style='font-size:14.0pt;line-height:
+115%;font-family:"Times New Roman","serif"'><a name="Pinhole Smear">Pinhole Smear</a></span></p>
+
+<p class=MsoNormal><span style='font-family:"Times New Roman","serif"'>The
+pinhole smearing computation is done similar to the Case 2) above except that
+the weight function used was the Gaussian function, so that the Eq. 6) for this
+case becomes</span></p>
+
+<p class=MsoNormal><img 
+src="sm_image021.gif"><span
+style='font-family:"Times New Roman","serif"'>                                                         (8)</span></p>
+
+<p class=MsoNormal><span style='font-family:"Times New Roman","serif"'>For all
+the cases above, the weighting matrix <i>W</i> is calculated when the smearing
+is called at the first time, and it includes the ~ 60 q values (finely binned
+evenly) below (&gt;0) and above the q range of data in order to cover all data
+points of the smearing computation for a given model and for a given slit size.
+ The <i>Norm</i> factor is found numerically with the weighting matrix, and
+considered on <i>I<sub>s</sub></i> computation.</span></p>
+
+<p class=MsoListParagraphCxSpFirst style='margin-left:.25in'><span
+style='font-family:"Times New Roman","serif"'>&nbsp;</span></p>
+
+<p class=MsoListParagraphCxSpLast><span style='font-size:14.0pt;line-height:
+115%;font-family:"Times New Roman","serif"'><a name="2D Smear">2D Smear</a></span></p>
+
+<p class=MsoNormal><span style='font-family:"Times New Roman","serif"'>The
+2D smearing computation is done similar to the 1D pinhole smearing above
+except that the weight function used was the 2D elliptical Gaussian function</span></p>
+
+<p class=MsoNormal><img 
+src="sm_image022.gif"><span
+style='font-family:"Times New Roman","serif"'>                    (9)</span></p>
+
+<p class=MsoNormal><span style='font-family:"Times New Roman","serif"'>In Eq
+(9), x<sub>0</sub> = qcos</span><span style='font-family:Symbol'>q</span><span
+style='font-family:"Times New Roman","serif"'> and y<sub>0</sub>=qsin</span><span
+style='font-family:Symbol'>q</span><span style='font-family:"Times New Roman","serif"'>
+, and the primed axes are in the coordinate rotated by an angle </span><span
+style='font-family:Symbol'>q</span><span style='font-family:"Times New Roman","serif"'>
+around z-axis (below) so that x<sub>0</sub> =  x<sub>0</sub>cos</span><span
+style='font-family:Symbol'>q + </span><span style='font-family:"Times New Roman","serif"'>y<sub>0</sub>
+sin</span><span style='font-family:Symbol'>q  </span><span style='font-family:
+"Times New Roman","serif"'>and y<sub>0</sub> =  -x<sub>0</sub>sin</span><span
+style='font-family:Symbol'>q + </span><span style='font-family:"Times New Roman","serif"'>y<sub>0</sub>
+cos</span><span style='font-family:Symbol'>q .</span><span style='font-family:
+"Times New Roman","serif"'> Note that the rotation angle is zero for x-y
+symmetric elliptical Gaussian distribution</span><span style='font-family:Symbol'>.
+</span><span style='font-family:"Times New Roman","serif"'>The  A is a
+normalization factor.</span></p>
+
+<p class=MsoNormal align=center style='text-align:center'><span
+style='font-family:"Times New Roman","serif"'><img width=439 height=376
+id="Object 1" src="sm_image023.gif"></span></p>
+
+<p class=MsoNormal><span style='font-family:"Times New Roman","serif"'>&nbsp;</span></p>
+
+<p class=MsoNormal><span style='font-family:"Times New Roman","serif"'>Now we
+consider a numerical integration where each bins in </span><span
+style='font-family:Symbol'>Q</span><span style='font-family:"Times New Roman","serif"'>
+and R are <b>evenly </b>(this is to simplify the equation below) distributed by
+</span><span style='font-family:Symbol'>DQ </span><span style='font-family:
+"Times New Roman","serif"'>and </span><span style='font-family:Symbol'>D</span><span
+style='font-family:"Times New Roman","serif"'>R, respectively, and it is
+assumed that I(x, y) is constant within the bins which in turn becomes</span></p>
+
+<p class=MsoNormal><img 
+src="sm_image024.gif"></p>
+
+<p class=MsoNormal>                                                                                                                                                                                <span
+style='font-family:"Times New Roman","serif"'>(10)</span></p>
+
+<p class=MsoNormal><span style='font-family:"Times New Roman","serif"'>Since we
+have found the weighting factor on each bin points, it is convenient to
+transform x-y back to x-y coordinate (rotating it by -</span><span
+style='font-family:Symbol'>q</span><span style='font-family:"Times New Roman","serif"'>
+around z axis).  Then, for the polar symmetric smear,</span></p>
+
+<p class=MsoNormal><img 
+src="sm_image025.gif"><span
+style='position:relative;top:35.0pt'>                                                         </span>(11)</p>
+
+<p class=MsoNormal><span style='font-family:"Times New Roman","serif"'>where,</span></p>
+
+<p class=MsoNormal><img 
+src="sm_image026.gif"></p>
+
+<p class=MsoNormal><span style='font-family:"Times New Roman","serif"'>while
+for the x-y symmetric smear,</span></p>
+
+<p class=MsoNormal><img 
+src="sm_image027.gif"><span
+style='font-family:"Times New Roman","serif"'>                                                                                          (12)</span></p>
+
+<p class=MsoNormal><span style='font-family:"Times New Roman","serif"'>where,</span></p>
+
+<p class=MsoNormal><img 
+src="sm_image028.gif"></p>
+
+<p class=MsoNormal><span style='font-family:"Times New Roman","serif"'>Here, the
+current version of the SANSVIEW uses the Eq. (11) for 2D smearing assuming that
+all the Gaussian weighting functions are aligned in the polar coordinate. </span></p>
+
+</div>
+
+</body>
+
+</html>
