[990d8df] | 1 | .. sm_help.rst |
---|
| 2 | |
---|
| 3 | .. This is a port of the original SasView html help file to ReSTructured text |
---|
| 4 | .. by S King, ISIS, during SasView CodeCamp-III in Feb 2015. |
---|
| 5 | |
---|
| 6 | |
---|
| 7 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
| 8 | |
---|
| 9 | Resolution Functions |
---|
| 10 | ==================== |
---|
| 11 | |
---|
| 12 | Sometimes the instrumental geometry used to acquire the experimental data has |
---|
| 13 | an impact on the clarity of features in the reduced scattering curve. For |
---|
| 14 | example, peaks or fringes might be slightly broadened. This is known as |
---|
| 15 | *Q resolution smearing*. To compensate for this effect one can either try and |
---|
| 16 | remove the resolution contribution - a process called *desmearing* - or add the |
---|
| 17 | resolution contribution into a model calculation/simulation (which by definition |
---|
| 18 | will be exact) to make it more representative of what has been measured |
---|
[1f058ea] | 19 | experimentally - a process called *smearing*. Sasmodels does the latter. |
---|
[990d8df] | 20 | |
---|
| 21 | Both smearing and desmearing rely on functions to describe the resolution |
---|
[1f058ea] | 22 | effect. Sasmodels provides three smearing algorithms: |
---|
[990d8df] | 23 | |
---|
| 24 | * *Slit Smearing* |
---|
| 25 | * *Pinhole Smearing* |
---|
| 26 | * *2D Smearing* |
---|
| 27 | |
---|
| 28 | The $Q$ resolution values should be determined by the data reduction software |
---|
| 29 | for the instrument and stored with the data file. If not, they will need to |
---|
| 30 | be set manually before fitting. |
---|
| 31 | |
---|
| 32 | |
---|
| 33 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
| 34 | |
---|
| 35 | Slit Smearing |
---|
| 36 | ------------- |
---|
| 37 | |
---|
| 38 | **This type of smearing is normally only encountered with data from X-ray Kratky** |
---|
| 39 | **cameras or X-ray/neutron Bonse-Hart USAXS/USANS instruments.** |
---|
| 40 | |
---|
| 41 | The slit-smeared scattering intensity is defined by |
---|
| 42 | |
---|
| 43 | .. math:: |
---|
| 44 | I_s = \frac{1}{\text{Norm}} |
---|
| 45 | \int_{-\infty}^{\infty} dv\, W_v(v) |
---|
| 46 | \int_{-\infty}^{\infty} du\, W_u(u)\, |
---|
| 47 | I\left(\sqrt{(q+v)^2 + |u|^2}\right) |
---|
| 48 | |
---|
| 49 | where *Norm* is given by |
---|
| 50 | |
---|
| 51 | .. math:: \int_{-\infty}^{\infty} dv\, W_v(v) \int_{-\infty}^{\infty} du\, W_u(u) |
---|
| 52 | |
---|
| 53 | **[Equation 1]** |
---|
| 54 | |
---|
| 55 | The functions $W_v(v)$ and $W_u(u)$ refer to the slit width weighting |
---|
| 56 | function and the slit height weighting determined at the given $q$ point, |
---|
| 57 | respectively. It is assumed that the weighting function is described by a |
---|
| 58 | rectangular function, such that |
---|
| 59 | |
---|
| 60 | .. math:: W_v(v) = \delta(|v| \leq \Delta q_v) |
---|
| 61 | |
---|
| 62 | **[Equation 2]** |
---|
| 63 | |
---|
| 64 | and |
---|
| 65 | |
---|
| 66 | .. math:: W_u(u) = \delta(|u| \leq \Delta q_u) |
---|
| 67 | |
---|
| 68 | **[Equation 3]** |
---|
| 69 | |
---|
| 70 | so that $\Delta q_\alpha = \int_0^\infty d\alpha\, W_\alpha(\alpha)$ |
---|
| 71 | for $\alpha$ as $v$ and $u$. |
---|
| 72 | |
---|
| 73 | Here $\Delta q_u$ and $\Delta q_v$ stand for the the slit height (FWHM/2) |
---|
| 74 | and the slit width (FWHM/2) in $q$ space. |
---|
| 75 | |
---|
| 76 | This simplifies the integral in Equation 1 to |
---|
| 77 | |
---|
| 78 | .. math:: |
---|
| 79 | |
---|
| 80 | I_s(q) = \frac{2}{\text{Norm}} |
---|
| 81 | \int_{-\Delta q_v}^{\Delta q_v} dv |
---|
| 82 | \int_{0}^{\Delta q_u} |
---|
| 83 | du\, I\left(\sqrt{(q+v)^2 + u^2}\right) |
---|
| 84 | |
---|
| 85 | **[Equation 4]** |
---|
| 86 | |
---|
| 87 | which may be solved numerically, depending on the nature of |
---|
| 88 | $\Delta q_u$ and $\Delta q_v$. |
---|
| 89 | |
---|
| 90 | Solution 1 |
---|
| 91 | ^^^^^^^^^^ |
---|
| 92 | |
---|
| 93 | **For** $\Delta q_v = 0$ **and** $\Delta q_u = \text{constant}$ |
---|
| 94 | |
---|
| 95 | .. math:: |
---|
| 96 | |
---|
| 97 | I_s(q) \approx \int_0^{\Delta q_u} du\, I\left(\sqrt{q^2+u^2}\right) |
---|
| 98 | = \int_0^{\Delta q_u} d\left(\sqrt{q'^2-q^2}\right)\, I(q') |
---|
| 99 | |
---|
| 100 | For discrete $q$ values, at the $q$ values of the data points and at the $q$ |
---|
[1f058ea] | 101 | values extended up to $q_N = q_i + \Delta q_u$ the smeared |
---|
[990d8df] | 102 | intensity can be approximately calculated as |
---|
| 103 | |
---|
| 104 | .. math:: |
---|
| 105 | |
---|
| 106 | I_s(q_i) |
---|
| 107 | \approx \sum_{j=i}^{N-1} \left[\sqrt{q_{j+1}^2 - q_i^2} - \sqrt{q_j^2 - q_i^2}\right]\, I(q_j) |
---|
| 108 | \sum_{j=1}^{N-1} W_{ij}\, I(q_j) |
---|
| 109 | |
---|
| 110 | **[Equation 5]** |
---|
| 111 | |
---|
| 112 | where $W_{ij} = 0$ for $I_s$ when $j < i$ or $j > N-1$. |
---|
| 113 | |
---|
| 114 | Solution 2 |
---|
| 115 | ^^^^^^^^^^ |
---|
| 116 | |
---|
| 117 | **For** $\Delta q_v = \text{constant}$ **and** $\Delta q_u = 0$ |
---|
| 118 | |
---|
| 119 | Similar to Case 1 |
---|
| 120 | |
---|
| 121 | .. math:: |
---|
| 122 | |
---|
| 123 | I_s(q_i) |
---|
| 124 | \approx \sum_{j=p}^{N-1} [q_{j+1} - q_i]\, I(q_j) |
---|
| 125 | \approx \sum_{j=p}^{N-1} W_{ij}\, I(q_j) |
---|
| 126 | |
---|
| 127 | for $q_p = q_i - \Delta q_v$ and $q_N = q_i + \Delta q_v$ |
---|
| 128 | |
---|
| 129 | **[Equation 6]** |
---|
| 130 | |
---|
| 131 | where $W_{ij} = 0$ for $I_s$ when $j < p$ or $j > N-1$. |
---|
| 132 | |
---|
| 133 | Solution 3 |
---|
| 134 | ^^^^^^^^^^ |
---|
| 135 | |
---|
| 136 | **For** $\Delta q_v = \text{constant}$ **and** $\Delta q_u = \text{constant}$ |
---|
| 137 | |
---|
| 138 | In this case, the best way is to perform the integration of Equation 1 |
---|
| 139 | numerically for both slit height and slit width. However, the numerical |
---|
| 140 | integration is imperfect unless a large number of iterations, say, at |
---|
| 141 | least 10000 by 10000 for each element of the matrix $W$, is performed. |
---|
| 142 | This is usually too slow for routine use. |
---|
| 143 | |
---|
| 144 | An alternative approach is used in sasmodels which assumes |
---|
| 145 | slit width << slit height. This method combines Solution 1 with the |
---|
| 146 | numerical integration for the slit width. Then |
---|
| 147 | |
---|
| 148 | .. math:: |
---|
| 149 | |
---|
| 150 | I_s(q_i) |
---|
| 151 | &\approx \sum_{j=p}^{N-1} \sum_{k=-L}^L |
---|
| 152 | \left[\sqrt{q_{j+1}^2 - (q_i + (k\Delta q_v/L))^2} |
---|
| 153 | - \sqrt{q_j^2 - (q_i + (k\Delta q_v/L))^2}\right] |
---|
| 154 | (\Delta q_v/L)\, I(q_j) \\ |
---|
| 155 | &\approx \sum_{j=p}^{N-1} W_{ij}\,I(q_j) |
---|
| 156 | |
---|
| 157 | **[Equation 7]** |
---|
| 158 | |
---|
| 159 | for $q_p = q_i - \Delta q_v$ and $q_N = q_i + \Delta q_v$ |
---|
| 160 | |
---|
| 161 | where $W_{ij} = 0$ for $I_s$ when $j < p$ or $j > N-1$. |
---|
| 162 | |
---|
| 163 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
| 164 | |
---|
| 165 | Pinhole Smearing |
---|
| 166 | ---------------- |
---|
| 167 | |
---|
| 168 | **This is the type of smearing normally encountered with data from synchrotron** |
---|
| 169 | **SAXS cameras and SANS instruments.** |
---|
| 170 | |
---|
[f8a2baa] | 171 | The pinhole smearing computation is performed in a similar fashion to the |
---|
| 172 | slit-smeared case above except that the weight function used is a Gaussian. Thus |
---|
[990d8df] | 173 | Equation 6 becomes |
---|
| 174 | |
---|
| 175 | .. math:: |
---|
| 176 | |
---|
| 177 | I_s(q_i) |
---|
| 178 | &\approx \sum_{j=0}^{N-1}[\operatorname{erf}(q_{j+1}) |
---|
| 179 | - \operatorname{erf}(q_j)]\, I(q_j) \\ |
---|
| 180 | &\approx \sum_{j=0}^{N-1} W_{ij}\, I(q_j) |
---|
| 181 | |
---|
| 182 | **[Equation 8]** |
---|
| 183 | |
---|
| 184 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
| 185 | |
---|
| 186 | 2D Smearing |
---|
| 187 | ----------- |
---|
| 188 | |
---|
| 189 | The 2D smearing computation is performed in a similar fashion to the 1D pinhole |
---|
| 190 | smearing above except that the weight function used is a 2D elliptical Gaussian. |
---|
| 191 | Thus |
---|
| 192 | |
---|
| 193 | .. math:: |
---|
| 194 | |
---|
| 195 | I_s(x_0,\, y_0) |
---|
| 196 | &= A\iint dx'dy'\, |
---|
| 197 | \exp \left[ -\left(\frac{(x'-x_0')^2}{2\sigma_{x_0'}^2} |
---|
| 198 | + \frac{(y'-y_0')^2}{2\sigma_{y_0'}}\right)\right] I(x',\, y') \\ |
---|
| 199 | &= A\sigma_{x_0'}\sigma_{y_0'}\iint dX dY\, |
---|
| 200 | \exp\left[-\frac{(X^2+Y^2)}{2}\right] I(\sigma_{x_0'}X x_0',\, \sigma_{y_0'} Y + y_0') \\ |
---|
| 201 | &= A\sigma_{x_0'}\sigma_{y_0'}\iint dR d\Theta\, |
---|
| 202 | R\exp\left(-\frac{R^2}{2}\right) I(\sigma_{x_0'}R\cos\Theta + x_0',\, \sigma_{y_0'}R\sin\Theta+y_0') |
---|
| 203 | |
---|
| 204 | **[Equation 9]** |
---|
| 205 | |
---|
| 206 | In Equation 9, $x_0 = q \cos(\theta)$, $y_0 = q \sin(\theta)$, and |
---|
| 207 | the primed axes are all in the coordinate rotated by an angle $\theta$ about |
---|
| 208 | the $z$\ -axis (see the figure below) so that |
---|
| 209 | $x'_0 = x_0 \cos(\theta) + y_0 \sin(\theta)$ and |
---|
| 210 | $y'_0 = -x_0 \sin(\theta) + y_0 \cos(\theta)$. |
---|
| 211 | Note that the rotation angle is zero for a $x$\ -\ $y$ symmetric |
---|
| 212 | elliptical Gaussian distribution. The $A$ is a normalization factor. |
---|
| 213 | |
---|
[30b60d2] | 214 | .. figure:: resolution_2d_rotation.png |
---|
[990d8df] | 215 | |
---|
| 216 | Coordinate axis rotation for 2D resolution calculation. |
---|
| 217 | |
---|
| 218 | Now we consider a numerical integration where each of the bins in $\theta$ |
---|
| 219 | and $R$ are *evenly* (this is to simplify the equation below) distributed |
---|
| 220 | by $\Delta \theta$ and $\Delta R$ respectively, and it is further assumed |
---|
| 221 | that $I(x',y')$ is constant within the bins. Then |
---|
| 222 | |
---|
| 223 | .. math:: |
---|
| 224 | |
---|
| 225 | I_s(x_0,\, y_0) |
---|
| 226 | &\approx A \sigma_{x'_0}\sigma_{y'_0}\sum_i^n |
---|
| 227 | \Delta\Theta\left[\exp\left(\frac{(R_i-\Delta R/2)^2}{2}\right) |
---|
| 228 | - \exp\left(\frac{(R_i + \Delta R/2)^2}{2}\right)\right] |
---|
| 229 | I(\sigma_{x'_0} R_i\cos\Theta_i+x'_0,\, \sigma_{y'_0}R_i\sin\Theta_i + y'_0) \\ |
---|
| 230 | &\approx \sum_i^n W_i\, I(\sigma_{x'_0} R_i \cos\Theta_i + x'_0,\, \sigma_{y'_0}R_i\sin\Theta_i + y'_0) |
---|
| 231 | |
---|
| 232 | **[Equation 10]** |
---|
| 233 | |
---|
| 234 | Since the weighting factor on each of the bins is known, it is convenient to |
---|
| 235 | transform $x'$\ -\ $y'$ back to $x$\ -\ $y$ coordinates (by rotating it |
---|
| 236 | by $-\theta$ around the $z$\ -axis). |
---|
| 237 | |
---|
| 238 | Then, for a polar symmetric smear |
---|
| 239 | |
---|
| 240 | .. math:: |
---|
| 241 | |
---|
| 242 | I_s(x_0,\, y_0) \approx \sum_i^n W_i\, |
---|
| 243 | I(x'\cos\theta - y'\sin\theta,\, x'sin\theta + y'\cos\theta) |
---|
| 244 | |
---|
| 245 | **[Equation 11]** |
---|
| 246 | |
---|
| 247 | where |
---|
| 248 | |
---|
| 249 | .. math:: |
---|
| 250 | |
---|
| 251 | x' &= \sigma_{x'_0} R_i \cos\Theta_i + x'_0 \\ |
---|
| 252 | y' &= \sigma_{y'_0} R_i \sin\Theta_i + y'_0 \\ |
---|
| 253 | x'_0 &= q = \sqrt{x_0^2 + y_0^2} \\ |
---|
| 254 | y'_0 &= 0 |
---|
| 255 | |
---|
| 256 | while for a $x$\ -\ $y$ symmetric smear |
---|
| 257 | |
---|
| 258 | .. math:: |
---|
| 259 | |
---|
| 260 | I_s(x_0,\, y_0) \approx \sum_i^n W_i\, I(x',\, y') |
---|
| 261 | |
---|
| 262 | **[Equation 12]** |
---|
| 263 | |
---|
| 264 | where |
---|
| 265 | |
---|
| 266 | .. math:: |
---|
| 267 | |
---|
| 268 | x' &= \sigma_{x'_0} R_i \cos\Theta_i + x'_0 \\ |
---|
| 269 | y' &= \sigma_{y'_0} R_i \sin\Theta_i + y'_0 \\ |
---|
| 270 | x'_0 &= x_0 = q_x \\ |
---|
| 271 | y'_0 &= y_0 = q_y |
---|
| 272 | |
---|
| 273 | |
---|
| 274 | The current version of sasmodels uses Equation 11 for 2D smearing, assuming |
---|
| 275 | that all the Gaussian weighting functions are aligned in the polar coordinate. |
---|
| 276 | |
---|
| 277 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
| 278 | |
---|
| 279 | Weighting & Normalization |
---|
| 280 | ------------------------- |
---|
| 281 | |
---|
| 282 | In all the cases above, the weighting matrix $W$ is calculated on the first |
---|
| 283 | call to a smearing function, and includes ~60 $q$ values (finely and evenly |
---|
| 284 | binned) below (>0) and above the $q$ range of data in order to smear all |
---|
| 285 | data points for a given model and slit/pinhole size. The *Norm* factor is |
---|
| 286 | found numerically with the weighting matrix and applied on the computation |
---|
| 287 | of $I_s$. |
---|
| 288 | |
---|
| 289 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
| 290 | |
---|
| 291 | *Document History* |
---|
| 292 | |
---|
| 293 | | 2015-05-01 Steve King |
---|
| 294 | | 2017-05-08 Paul Kienzle |
---|