Skip to content

Commit 065467b

Browse files
committed
docs: add description of data reduction procedure
1 parent bddec78 commit 065467b

File tree

3 files changed

+142
-2
lines changed

3 files changed

+142
-2
lines changed

docs/api-reference/index.md

-2
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,8 @@
4444
:template: module-template.rst
4545
:recursive:
4646
47-
beamline
4847
conversions
4948
data
50-
instrument_view
5149
load
5250
orso
5351
resolution

docs/user-guide/data-reduction.md

+141
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
# Reflectometry data reduction procedure
2+
3+
The goal of the reflectometry data reduction is to compute the sample reflectivity $R(Q)$ as a function of the momentum transfer $Q$.
4+
5+
## Preliminaries
6+
7+
The detector data consists of a list $EV$ of neutron detector events.
8+
For each neutron event in the event list we know what wavelength $\lambda$ it had and we know the pixel number $j$ of the detector pixel that it hit.
9+
The detector pixel positions are known and so is the position of the sample and the orientation of the sample.
10+
From that information we can compute the reflection angle (assumed equal to the incidence angle) $\theta$, and the momentum transfer $Q$ caused by the interaction with the sample.
11+
12+
The purpose of this text is not to describe how the event coordinates $Q$ and $\theta$ are derived from the raw event data and the geometry information, so for now just take those relations for given.
13+
14+
To avoid overcomplicating the description it is assumed that the sample- and reference measurements were made over the same length of time, and it is assumed the neutron intensity from the source did not vary between the two measurements.
15+
16+
## Model
17+
18+
The sample reflectivity is related to the intensity of neutron counts in the detector by the model
19+
20+
$$
21+
I_{sam}(\lambda, j) = F(\theta(\lambda, j, \mu_{sam}), w_{sam}) \cdot R(Q(\lambda, \theta(\lambda, j, \mu_{sam}))) \cdot I_{ideal}(\lambda, j)
22+
$$ (model)
23+
where $I_{sam}(\lambda, j)$ represents the number of neutrons detected in the $j$ pixel of the detector having a wavelength in the interval $[\lambda, \lambda + d\lambda]$. $I_{ideal}$ represents the number of neutrons that would have been detected if the sample was a perfect reflector and large enough so that the footprint of the focused beam on the sample was small compared to the sample. $F(\theta, w)$ is the fraction of the focused beam that hits the sample. It depends on the incidence angle $\theta$ and on the size of the sample represented by $w$. $\mu_{sam}$ is the sample rotation.
24+
25+
The ideal intensity is estimated from a reference measurement on a neutron supermirror.
26+
How it is computed will be described later, for now assume it exists.
27+
28+
## Estimating $R(Q)$
29+
Move $F$ to the left-hand-side of equation {eq}`model` and integrate over all $\lambda$ and $j$ contributing to one particular $Q$-bin $[q_{i}, q_{i+1}]$
30+
31+
$$
32+
\int_{Q(\lambda, \theta(\lambda, j, \mu_{sam})) \in [q_{i}, q_{i+1}]} \frac{I_{sam}(\lambda, j)}{F(\theta(\lambda, j, \mu_{sam}), w_{sam})} d\lambda \ dj = \\
33+
\int_{Q(\lambda, \theta(\lambda, j, \mu_{sam})) \in [q_{i}, q_{i+1}]} I_{ideal}(\lambda, j) R(Q(\lambda, \theta(\lambda, j, \mu_{sam}))) d\lambda \ dj.
34+
$$
35+
Notice that if the $Q$ binning is sufficiently fine then $R(Q)$ is approximately constant in the integration region.
36+
Assuming the binning is fine enough $R(Q)$ can be moved outside the integral and isolated so that
37+
38+
$$
39+
R(Q_{i+\frac{1}{2}}) \approx \frac{\int_{Q(\lambda, j, \mu_{sam}) \in [q_{i}, q_{i+1}]} \frac{I_{sam}(\lambda, j)}{F(\theta(\lambda, j, \mu_{sam}), w_{sam})} d\lambda \ dj }{\int_{Q(\lambda, \theta(\lambda, j, \mu_{sam})) \in [q_{i}, q_{i+1}]} I_{ideal}(\lambda, j) d\lambda \ dj} := \frac{I_{measured}(Q_{i+\frac{1}{2}})}{I_{ideal}(Q_{i+\frac{1}{2}})}
40+
$$
41+
for $Q_{i+\frac{1}{2}} \in [q_{i}, q_{i+1}]$.
42+
43+
44+
## The reference intensity $I_{ideal}$
45+
$I_{ideal}$ is estimated from a reference measurement on a neutron supermirror with known reflectivity curve.
46+
The reference measurement intensity is modeled the same way the sample measurement was
47+
48+
$$
49+
I_{ref}(\lambda, j) = F(\theta(\lambda, j, \mu_{ref}), w_{ref}) \cdot R_{supermirror}(Q(\lambda, \theta(\lambda, j, \mu_{ref}))) \cdot I_{ideal}(\lambda, j)
50+
$$
51+
but in this case $R_{supermirror}(Q)$ is known.
52+
53+
This leads to
54+
55+
$$
56+
I_{ideal}(Q_{i+\frac{1}{2}}) = \int_{Q(\lambda, \theta(\lambda, j, \mu_{sam})) \in [q_{i}, q_{i+1}]} \frac{I_{ref}(\lambda, j)}{F(\theta(\lambda, j, \mu_{ref}), w_{ref}) R_{supermirror}(Q(\lambda, \theta(\lambda, j, \mu_{ref})))}
57+
d\lambda \ dj.
58+
$$
59+
60+
## Estimating intensities from detector counts
61+
The neutron counts are Poisson distributed.
62+
This implies that the intensity integrals are equal to the expected number of neutron detector counts in the integration region.
63+
The expected number of counts can be estimated by the empirically observed count:
64+
65+
$$
66+
I_{measured}(Q_{i+\frac{1}{2}}) = \int_{Q(\lambda, \theta(\lambda, j, \mu_{sam})) \in [q_{i}, q_{i+1}]} \frac{I_{sam}(\lambda, j)}{F(\theta(\lambda, j, \mu_{sam}), w_{sam})} d\lambda \ dj = \\
67+
E\bigg[ \sum_{\substack{k \in EV_{sam} \\ Q(\lambda_{k}, \theta(\lambda_{k}, j_{k}, \mu_{sam})) \in [q_{i}, q_{i+1}]}} \frac{1}{F(\theta(\lambda_{k}, j_{k}, \mu_{sam}), w_{sam})} \bigg] \approx
68+
\sum_{\substack{k \in EV_{sam} \\ Q(\lambda_{k}, \theta(\lambda_{k}, j_{k}, \mu_{sam})) \in [q_{i}, q_{i+1}]}} \frac{1}{F(\theta(\lambda_{k}, j_{k}, \mu_{sam}), w_{sam})}
69+
$$
70+
where $EV_{sam}$ refers to the event list from the sample experiment.
71+
72+
We also know that the variance of the counts is the same as the expected count, so it can also be estimated as the empirically observed count:
73+
74+
$$
75+
V\bigg[ \sum_{\substack{k \in EV_{sam} \\ Q(\lambda_{k}, \theta(\lambda_{k}, j_{k}, \mu_{sam})) \in [q_{i}, q_{i+1}]}} \frac{1}{F(\theta(\lambda_{k}, j_{k}, \mu_{sam}), w_{sam})} \bigg] \approx
76+
\sum_{\substack{k \in EV_{sam} \\ Q(\lambda_{k}, \theta(\lambda_{k}, j_{k}, \mu_{sam})) \in [q_{i}, q_{i+1}]}} \frac{1}{F(\theta(\lambda_{k}, j_{k}, \mu_{sam}), w_{sam})}.
77+
$$
78+
79+
The same estimates are used to approximate the ideal intensity:
80+
81+
$$
82+
I_{ideal}(Q_{i+\frac{1}{2}}) \approx \sum_{\substack{k \in EV_{ref} \\ Q(\lambda_{k}, \theta(\lambda_{k}, j_{k}, \mu_{sam})) \in [q_{i}, q_{i+1}]}} \frac{1}{F(\theta(\lambda_{k}, j_{k}, \mu_{ref}), w_{ref}) R_{supermirror}(Q(\lambda_{k}, \theta(\lambda_{k}, j_{k}, \mu_{ref})))}
83+
$$
84+
85+
### More efficient evaluation of the reference intensity
86+
The above expression for the reference intensity is cumbersome to compute because it is a sum over the reference measurement event list, and the reference measurement is large compared to the sample measurement.
87+
88+
Therefore we back up a bit. Consider the expression for the reference intensity, replacing the integrand with a generic $I(\lambda, j)$ it looks something like:
89+
90+
$$
91+
I_{ideal}(Q_{i+\frac{1}{2}}) = \int_{Q(\lambda, \theta(\lambda, j, \mu_{sam})) \in [q_{i}, q_{i+1}]} I(\lambda, j) \ d\lambda \ dj.
92+
$$
93+
94+
In the previous section we approximated the integral by summing over all events in the reference measurement.
95+
96+
Alternatively, we could define a $\lambda$ grid with edges $\lambda_{k}$ for $k=1\ldots N$ and approximate the integration region as the union of a subset of the grid cells:
97+
98+
$$
99+
\int_{Q(\lambda, \theta(\lambda, j, \mu_{sam})) \in [q_{i}, q_{i+1}]} I(\lambda, j) \ d\lambda \ dj
100+
\approx \sum_{Q(\bar{\lambda}_{k+\frac{1}{2}},\ \theta(\bar{\lambda}_{k+\frac{1}{2}}, j, \mu_{sam})) \in [q_{i}, q_{i+1}]} I_{k+\frac{1}{2},j}
101+
$$
102+
where
103+
104+
$$
105+
I_{k+\frac{1}{2},j} = \int_{\lambda \in [\lambda_{k}, \lambda_{k+1}]} I(\lambda, j) \ d\lambda
106+
$$
107+
and $\bar{\lambda}_{k+\frac{1}{2}} = (\lambda_{k} + \lambda_{k+1}) / 2$.
108+
109+
Why would this be more efficient than the original approach? Note that $I_{k+\frac{1}{2}, j}$ does not depend on $\mu_{sam}$, and that it can be computed once and reused for all sample measurements.
110+
This allows us to save computing time for each new sample measurement, as long as $|EV_{ref}| >> NM$ where $M$ is the number of detector pixels and $N$ is the size of the $\lambda$ grid.
111+
112+
However, ideally computing the reference intensity should be quick compared to reducing the sample measurement. And since a reasonable value for $N$ is approximately $500$, and $M\approx 30000$, and a sample measurement is likely less than $10$ million events, the cost of computing the reference measurement is still considerable compared to reducing the sample measurement.
113+
114+
Therefore there's one more approximation that is used to further reduce the cost of computing the reference intensity.
115+
116+
The Amor detector has three logical dimensions, `blade`, `wire` and `stripe`. It happens to be the case that $\theta(\lambda, j)$ is almost the same for all $j$ belonging to the same `stripe` of the detector.
117+
We can express this as
118+
119+
$$
120+
\theta(\lambda, j, \mu_{sam}) \approx \bar{\theta}(\lambda, \mathrm{bladewire}(j), \mu_{sam})
121+
$$
122+
where $\bar{\theta}$ is an approximation for $\theta$ that only depends on the blade and the wire of the pixel where the neutron was detected.
123+
Then the above expression for the reference intensity can be rewritten as
124+
125+
$$
126+
\int_{Q(\lambda, \bar{\theta}(\lambda, z, \mu_{sam})) \in [q_{i}, q_{i+1}]} \int_{\mathrm{bladewire}(j) = z} I(\lambda, j) \ dj \ d\lambda \ dz
127+
\approx \sum_{Q(\bar{\lambda}_{k+\frac{1}{2}}, \bar{\theta}(\bar{\lambda}_{k+\frac{1}{2}}, z, \mu_{sam})) \in [q_{i}, q_{i+1}]} I_{k+\frac{1}{2},z}
128+
$$
129+
where
130+
131+
$$
132+
I_{k+\frac{1}{2},z} = \int_{\lambda \in [\lambda_{k}, \lambda_{k+1}]} \int_{\mathrm{bladewire}(j) = z} I(\lambda, j) \ dj \ d\lambda .
133+
$$
134+
Like before, the benefit of doing this is that
135+
136+
$$
137+
\int_{\lambda \in [\lambda_{k}, \lambda_{k+1}]} \int_{\mathrm{bladewire}(j) = z} I(\lambda, j) \ dj \ d\lambda
138+
$$
139+
can be pre-computed because it doesn't depend on $\mu_{sam}$.
140+
But unlike before $I_{k+\frac{1}{2},z}$ now has a much more manageable size, about 64x smaller than the first attempt.
141+
This makes it comfortably smaller than the sample measurement.

docs/user-guide/index.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
maxdepth: 1
66
---
77
amor/index
8+
data-reduction
89
```
910

0 commit comments

Comments
 (0)