# resolution - Resolution¶

 FWHM2sigma QL2T Compute angle from $$Q$$ and wavelength. QT2L Compute wavelength from $$Q$$ and angle. TL2Q Compute $$Q$$ from angle and wavelength. TOF2L Convert neutron time-of-flight to wavelength. binedges Construct bin edges E from bin centers L. bins Return bin centers from low to high preserving a fixed resolution. binwidths Determine the wavelength dispersion from bin centers L. dQ_broadening Broaden an existing dQ by the given divergence. dQdL2dT Convert a calculated Q resolution and wavelength dispersion to angular divergence. dQdT2dLoL Convert a calculated Q resolution and angular divergence to a wavelength dispersion. dTdL2dQ Convert wavelength dispersion and angular divergence to $$Q$$ resolution. divergence Calculate divergence due to slit and sample geometry. sigma2FWHM slit_widths Compute the slit widths for the standard scanning reflectometer fixed-opening-fixed geometry.

Resolution calculations

refl1d.resolution.FWHM2sigma(s)[source]
refl1d.resolution.QL2T(Q=None, L=None)[source]

Compute angle from $$Q$$ and wavelength.

$\theta = \sin^{-1}( |Q| \lambda / 4 \pi )$

Returns $$\theta$$°.

refl1d.resolution.QT2L(Q=None, T=None)[source]

Compute wavelength from $$Q$$ and angle.

$\lambda = 4 \pi \sin( \theta )/Q$

Returns $$\lambda$$Å.

refl1d.resolution.TL2Q(T=None, L=None)[source]

Compute $$Q$$ from angle and wavelength.

$Q = 4 \pi \sin(\theta) / \lambda$

Returns $$Q$$-1

refl1d.resolution.TOF2L(d_moderator, TOF)[source]

Convert neutron time-of-flight to wavelength.

$\lambda = (t/d) (h/n_m)$

where:

$$\lambda$$ is wavelength in Å
$$t$$ is time-of-flight in $$u$$s
$$h$$ is Planck’s constant in erg seconds
$$n_m$$ is the neutron mass in g
refl1d.resolution.binedges(L)[source]

Construct bin edges E from bin centers L.

Assuming fixed $$\omega = \Delta\lambda/\lambda$$ in the bins, the edges will be spaced logarithmically at:

$\begin{split}E_0 &= \min \lambda \\ E_{i+1} &= E_i + \omega E_i = E_i (1+\omega)\end{split}$

with centers $$L$$ half way between the edges:

$L_i = (E_i+E_{i+1})/2 = (E_i + E_i (1+\omega))/2 = E_i (2 + \omega)/2$

Solving for $$E_i$$, we can recover the edges from the centers:

$E_i = L_i \frac{2}{2+\omega}$

The final edge, $$E_{n+1}$$, does not have a corresponding center $$L_{n+1}$$ so we must determine it from the previous edge $$E_n$$:

$E_{n+1} = L_n \frac{2}{2+\omega}(1+\omega)$

The fixed $$\omega$$ can be retrieved from the ratio of any pair of bin centers using:

$\frac{L_{i+1}}{L_i} = \frac{ (E_{i+2}+E_{i+1})/2 }{ (E_{i+1}+E_i)/2 } = \frac{ (E_{i+1}(1+\omega)+E_{i+1} } { (E_i(1+\omega)+E_i } = \frac{E_{i+1}}{E_i} = \frac{E_i(1+\omega)}{E_i} = 1 + \omega$
refl1d.resolution.bins(low, high, dLoL)[source]

Return bin centers from low to high preserving a fixed resolution.

low, high are the minimum and maximum wavelength. dLoL is the desired resolution FWHM $$\Delta\lambda/\lambda$$ for the bins.

refl1d.resolution.binwidths(L)[source]

Determine the wavelength dispersion from bin centers L.

The wavelength dispersion $$\Delta\lambda$$ is just the difference between consecutive bin edges, so:

$\Delta L_i = E_{i+1}-E_{i} = (1+\omega) E_i - E_i = \omega E_i = \frac{2 \omega}{2+\omega} L_i$

where $$E$$ and $$\omega$$ are as defined in binedges().

refl1d.resolution.dQ_broadening(dQ, L, T, dT, width)[source]

Broaden an existing dQ by the given divergence.

dQ-1, with 1-$$\sigma$$ $$Q$$ resolution LT, dT °, with FWHM angular divergence width °, with FWHM increased angular divergence

The calculation is derived by substituting $$\Delta\theta' = \Delta\theta + \omega$$ for sample broadening $$\omega$$ into the resolution estimate $$(\Delta Q/Q)^2 = (\Delta\lambda/\lambda)^2 + (\Delta\theta/\tan\theta)^2$$.

refl1d.resolution.dQdL2dT(Q, dQ, L, dL)[source]

Convert a calculated Q resolution and wavelength dispersion to angular divergence.

Q, dQ-1 $$Q$$ and 1-$$\sigma$$ $$Q$$ resolution L, dL ° angle and FWHM angular divergence

Returns FWHM Deltatheta\$

refl1d.resolution.dQdT2dLoL(Q, dQ, T, dT)[source]

Convert a calculated Q resolution and angular divergence to a wavelength dispersion.

Q, dQ-1 $$Q$$ and 1-$$\sigma$$ $$Q$$ resolution T, dT ° angle and FWHM angular divergence

Returns FWHM $$\Delta\lambda/\lambda$$

refl1d.resolution.dTdL2dQ(T=None, dT=None, L=None, dL=None)[source]

Convert wavelength dispersion and angular divergence to $$Q$$ resolution.

T, dT (degrees) angle and FWHM angular divergence L, dL (Angstroms) wavelength and FWHM wavelength dispersion

Returns 1-$$\sigma$$ $$\Delta Q$$

Given $$Q = 4 \pi sin(\theta)/\lambda$$, this follows directly from gaussian error propagation using

..math:

\Delta Q^2
&= \left(\frac{\partial Q}{\partial \lambda}\right)^2\Delta\lambda^2
+ \left(\frac{\partial Q}{\partial \theta}\right)^2\Delta\theta^2

&= Q^2 \left(\frac{\Delta \lambda}{\lambda}\right)^2
+ Q^2 \left(\frac{\Delta \theta}{\tan \theta}\right)^2

&= Q^2 \left(\frac{\Delta \lambda}{\lambda}\right)^2
+ \left(\frac{4\pi\cos\theta\,\Delta\theta}{\lambda}\right)^2


with the final form chosen to avoid cancellation at $$Q=0$$.

refl1d.resolution.divergence(T=None, slits=None, distance=None, sample_width=10000000000.0, sample_broadening=0)[source]

Calculate divergence due to slit and sample geometry.

Parameters: T : float OR [float] | degrees incident angles slits : float OR (float, float) | mm s1, s2 slit openings for slit 1 and slit 2 distance : (float, float) | mm d1, d2 distance from sample to slit 1 and slit 2 sample_width : float | mm w, width of the sample sample_broadening : float | degrees FWHM additional divergence caused by sample dT : float OR [float] | degrees FWHM calculated angular divergence

Algorithm:

The divergence is based on the slit openings and the distance between the slits. For very small samples, where the slit opening is larger than the width of the sample across the beam, the sample itself acts like the second slit.

First find $$p$$, the projection of the beam on the sample:

$p &= w \sin\left(\frac{\pi}{180}\theta\right)$

Depending on whether $$p$$ is larger than $$s_2$$, determine the slit divergence $$\Delta\theta_d$$ in radians:

$\begin{split}\Delta\theta_d &= \left\{ \begin{array}{ll} \frac{1}{2}\frac{s_1+s_2}{d_1-d_2} & \mbox{if } p \geq s_2 \\ \frac{1}{2}\frac{s_1+p}{d_1} & \mbox{if } p < s_2 \end{array} \right.\end{split}$

In addition to the slit divergence, we need to add in any sample broadening $$\Delta\theta_s$$ returning the total divergence in degrees:

$\Delta\theta &= \frac{180}{\pi} \Delta\theta_d + \Delta\theta_s$

Reversing this equation, the sample broadening contribution can be measured from the full width at half maximum of the rocking curve, $$B$$, measured in degrees at a particular angle and slit opening:

$\Delta\theta_s = B - \frac{180}{\pi}\Delta\theta_d$
refl1d.resolution.sigma2FWHM(s)[source]
refl1d.resolution.slit_widths(T=None, slits_at_Tlo=None, Tlo=90, Thi=90, slits_below=None, slits_above=None)[source]

Compute the slit widths for the standard scanning reflectometer fixed-opening-fixed geometry.

Parameters: T : [float] | degrees Specular measurement angles. Tlo, Thi : float | degrees Start and end of the opening region. The default if Tlo is not specified is to use fixed slits at slits_below for all angles. slits_below, slits_above : float OR [float, float] | mm Slits outside opening region. The default is to use the values of the slits at the ends of the opening region. slits_at_Tlo : float OR [float, float] | mm Slits at the start of the opening region. s1, s2 : [float] | mm Slit widths for each theta.

Slits are assumed to be fixed below angle Tlo and above angle Thi, and opening at a constant dT/T between them.

Slit openings are defined by a tuple (s1, s2) or constant s=s1=s2. With no Tlo, the slits are fixed with widths defined by slits_below, which defaults to slits_at_Tlo. With no Thi, slits are continuously opening above Tlo.

Note

This function works equally well if angles are measured in radians and/or slits are measured in inches.