From d7910087ece26ae9f8fbd47837909e2823779ece Mon Sep 17 00:00:00 2001 From: jokasimr Date: Wed, 27 Nov 2024 10:02:43 +0100 Subject: [PATCH 01/27] Create estia-data-reduction.md --- docs/user-guide/estia-data-reduction.md | 200 ++++++++++++++++++++++++ 1 file changed, 200 insertions(+) create mode 100644 docs/user-guide/estia-data-reduction.md diff --git a/docs/user-guide/estia-data-reduction.md b/docs/user-guide/estia-data-reduction.md new file mode 100644 index 00000000..923e419b --- /dev/null +++ b/docs/user-guide/estia-data-reduction.md @@ -0,0 +1,200 @@ +## Model + +Intensities in the detector are related to the reflectivities of the sample by the model +```math +\begin{bmatrix} +I^{+} \\ +I^{-} +\end{bmatrix} +\big(\lambda, j\big) += +\begin{bmatrix} +D^+ & 0 \\ +0 & D^- +\end{bmatrix} +\begin{bmatrix} +1 - a^{\uparrow} & 1 - a^{\downarrow} \\ +a^{\uparrow} & a^{\downarrow} \\ +\end{bmatrix} +\begin{bmatrix} +R^{\uparrow\uparrow} & R^{\downarrow\uparrow} \\ +R^{\uparrow\downarrow} & R^{\downarrow\downarrow} +\end{bmatrix} +\begin{bmatrix} +(1 - f) & f \\ f & (1 - f) +\end{bmatrix} +\begin{bmatrix} +1 - p^{\uparrow} \\ +1 - p^{\downarrow} +\end{bmatrix} +``` +where + +* $I^+$ is the intensity of the neutron beam transmitted by the analyzer +and $I^-$ is the intensity of the neutron beam reflected by the analyzer, +* $R^\cdot$ are the reflectivities of the sample, + - $R^{\uparrow\uparrow}$ is the fraction of incoming neutrons with spin up that are reflected with spin up, + - $R^{\uparrow\downarrow}$ is the fraction of incoming neutrons with spin up that are reflected with spin down, + - etc.. +* $a^\uparrow$ is the analyzer reflectivity for spin up neutrons and $a^\downarrow$ is the analyzer reflectivity for spin down neutrons, +* $p^\uparrow$ is the polarizer reflectivity for spin up neutrons and $p^\downarrow$ is the polarizer reflectivity for spin down neutrons, +* $f$ is the probability of spin flip by the flipper, +* $D^\pm$ represents the inhomogeneity from the beam- and detector efficiency. They are different for the transmitted and the reflected beam + because the transmitted and reflected beam hit different pixels. + +**For simplicity the second flipper was omitted in the above description.** + +If the sample is measured at two different flipper settings $f=0$ and $f=1$, then we have +```math +\begin{bmatrix} +I^{0+} \\ +I^{0-} +\end{bmatrix} +\big(\lambda, j\big) += +\begin{bmatrix} +D^+ & 0 \\ +0 & D^- +\end{bmatrix} +\begin{bmatrix} +1 - a^{\uparrow} & 1 - a^{\downarrow} \\ +a^{\uparrow} & a^{\downarrow} \\ +\end{bmatrix} +\begin{bmatrix} +R^{\uparrow\uparrow} & R^{\downarrow\uparrow} \\ +R^{\uparrow\downarrow} & R^{\downarrow\downarrow} +\end{bmatrix} +\begin{bmatrix} +1 - p^{\uparrow} \\ +1 - p^{\downarrow} +\end{bmatrix} +``` +```math +\begin{bmatrix} +I^{1+} \\ +I^{1-} +\end{bmatrix} +\big(\lambda, j\big) += +\begin{bmatrix} +D^+ & 0 \\ +0 & D^- +\end{bmatrix} +\begin{bmatrix} +1 - a^{\uparrow} & 1 - a^{\downarrow} \\ +a^{\uparrow} & a^{\downarrow} \\ +\end{bmatrix} +\begin{bmatrix} +R^{\uparrow\uparrow} & R^{\downarrow\uparrow} \\ +R^{\uparrow\downarrow} & R^{\downarrow\downarrow} +\end{bmatrix} +\begin{bmatrix} +1 - p^{\downarrow} \\ +1 - p^{\uparrow} +\end{bmatrix}. +``` + +To simplify the above expressions, collect the terms in the diagonal matrix $\mathbf{D}$ and the (typically full) matrix $\mathbf{a}$ +```math +\begin{bmatrix} +I^{0+} \\ +I^{0-} \\ +I^{1+} \\ +I^{1-} +\end{bmatrix} +\big(\lambda, j\big) += +\mathbf{D}(\lambda, j) +\mathbf{a}(\lambda) +\begin{bmatrix} +R^{\uparrow\uparrow} \\ +R^{\uparrow\downarrow} \\ +R^{\downarrow\uparrow} \\ +R^{\downarrow\downarrow} +\end{bmatrix} +(Q(\lambda, j)). +``` + +To compute the reflectivities, integrate over a region of (almost) constant $Q$ +```math +\int_{Q\in[q_{n}, q_{n+1}]} +\begin{bmatrix} +I^{0+} \\ +I^{0-} \\ +I^{1+} \\ +I^{1-} +\end{bmatrix} +\big(\lambda, j\big) +d\lambda dj +\approx +\int_{Q\in[q_{n}, q_{n+1}]} +\mathbf{D}(\lambda, j) +\mathbf{a}(\lambda) +d\lambda dj +\begin{bmatrix} +R^{\uparrow\uparrow} \\ +R^{\uparrow\downarrow} \\ +R^{\downarrow\uparrow} \\ +R^{\downarrow\downarrow} +\end{bmatrix} +(q_{n+\frac{1}{2}}). +``` +Integrating $\mathbf{D}$ can be done using the reference measurement, $\mathbf{a}$ is known. + + +### How to compute the integral over $D(\lambda, j)$? + +For a reference measurement using flipper setting $f=0$ we have +```math +\begin{bmatrix} +I_{ref}^{+} \\ +I_{ref}^{-} +\end{bmatrix} +\big(\lambda, j\big) += +\begin{bmatrix} +D^+ & 0 \\ +0 & D^- +\end{bmatrix} +\begin{bmatrix} +1 - a^{\uparrow} & 1 - a^{\downarrow} \\ +a^{\uparrow} & a^{\downarrow} \\ +\end{bmatrix} +\begin{bmatrix} +R_{ref}^{\uparrow\uparrow} & R_{ref}^{\downarrow\uparrow} \\ +R_{ref}^{\uparrow\downarrow} & R_{ref}^{\downarrow\downarrow} +\end{bmatrix} +\begin{bmatrix} +1 - p^{\uparrow} \\ +1 - p^{\downarrow} +\end{bmatrix} +``` +or, simplified by collecting the known terms in the matrix $\mathbf{ar}$ +```math +\begin{bmatrix} +I_{ref}^{+} \\ +I_{ref}^{-} +\end{bmatrix} +\big(\lambda, j\big) += +\mathbf{ar}(\lambda, j) +\begin{bmatrix} +D^+ \\ +D^- +\end{bmatrix} +``` +where $\mathbf{ar}$ is a diagonal matrix. + +For some $b,\Omega$ +```math +\int_{\Omega} D^+(\lambda, j) b(\lambda, j) d\lambda j += +\int_{\Omega} +\frac{I_{ref}^+(\lambda, j)} +{ar^+(\lambda, j)} +b(\lambda, j) +d\lambda j +\approx \frac{1}{N}\sum_{i\in E_{ref}^+, (\lambda_{i}, j_{i}) \in \Omega} \frac{b(\lambda_{i}, j_{i})}{ar^{+}(\lambda_{i}, j_{i})} +``` +where the last integral can be approximated using the reference measurement $E_{ref}^+$ (set of events in the reference measurement), $N$ is the number of events in $E_{ref}^+$ that are in $\Omega$. + From 646da5c14dd0bcdeac890e2dcdc5eaeb95688295 Mon Sep 17 00:00:00 2001 From: jokasimr Date: Wed, 27 Nov 2024 11:05:09 +0100 Subject: [PATCH 02/27] Update estia-data-reduction.md --- docs/user-guide/estia-data-reduction.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-guide/estia-data-reduction.md b/docs/user-guide/estia-data-reduction.md index 923e419b..7c4eb94e 100644 --- a/docs/user-guide/estia-data-reduction.md +++ b/docs/user-guide/estia-data-reduction.md @@ -14,7 +14,7 @@ D^+ & 0 \\ \end{bmatrix} \begin{bmatrix} 1 - a^{\uparrow} & 1 - a^{\downarrow} \\ -a^{\uparrow} & a^{\downarrow} \\ +a^{\uparrow} & a^{\downarrow} \end{bmatrix} \begin{bmatrix} R^{\uparrow\uparrow} & R^{\downarrow\uparrow} \\ From 02b9abdee646488e81c5270c96512a11a143f4f1 Mon Sep 17 00:00:00 2001 From: jokasimr Date: Wed, 27 Nov 2024 11:05:52 +0100 Subject: [PATCH 03/27] Update estia-data-reduction.md Remove extra newlines --- docs/user-guide/estia-data-reduction.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/user-guide/estia-data-reduction.md b/docs/user-guide/estia-data-reduction.md index 7c4eb94e..f012b135 100644 --- a/docs/user-guide/estia-data-reduction.md +++ b/docs/user-guide/estia-data-reduction.md @@ -58,7 +58,7 @@ D^+ & 0 \\ \end{bmatrix} \begin{bmatrix} 1 - a^{\uparrow} & 1 - a^{\downarrow} \\ -a^{\uparrow} & a^{\downarrow} \\ +a^{\uparrow} & a^{\downarrow} \end{bmatrix} \begin{bmatrix} R^{\uparrow\uparrow} & R^{\downarrow\uparrow} \\ @@ -82,7 +82,7 @@ D^+ & 0 \\ \end{bmatrix} \begin{bmatrix} 1 - a^{\uparrow} & 1 - a^{\downarrow} \\ -a^{\uparrow} & a^{\downarrow} \\ +a^{\uparrow} & a^{\downarrow} \end{bmatrix} \begin{bmatrix} R^{\uparrow\uparrow} & R^{\downarrow\uparrow} \\ @@ -158,7 +158,7 @@ D^+ & 0 \\ \end{bmatrix} \begin{bmatrix} 1 - a^{\uparrow} & 1 - a^{\downarrow} \\ -a^{\uparrow} & a^{\downarrow} \\ +a^{\uparrow} & a^{\downarrow} \end{bmatrix} \begin{bmatrix} R_{ref}^{\uparrow\uparrow} & R_{ref}^{\downarrow\uparrow} \\ From e942c2e21f0df3cc5925d00f5dca604f6d671c28 Mon Sep 17 00:00:00 2001 From: jokasimr Date: Wed, 27 Nov 2024 11:07:45 +0100 Subject: [PATCH 04/27] Update estia-data-reduction.md --- docs/user-guide/estia-data-reduction.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/user-guide/estia-data-reduction.md b/docs/user-guide/estia-data-reduction.md index f012b135..e6340eea 100644 --- a/docs/user-guide/estia-data-reduction.md +++ b/docs/user-guide/estia-data-reduction.md @@ -44,6 +44,8 @@ and $I^-$ is the intensity of the neutron beam reflected by the analyzer, **For simplicity the second flipper was omitted in the above description.** +## Reducing a measurement + If the sample is measured at two different flipper settings $f=0$ and $f=1$, then we have ```math \begin{bmatrix} From 773c8b0ae79f2ffd21d9e873b13de320e8527dfc Mon Sep 17 00:00:00 2001 From: jokasimr Date: Wed, 27 Nov 2024 11:09:10 +0100 Subject: [PATCH 05/27] Update estia-data-reduction.md --- docs/user-guide/estia-data-reduction.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/user-guide/estia-data-reduction.md b/docs/user-guide/estia-data-reduction.md index e6340eea..57024f91 100644 --- a/docs/user-guide/estia-data-reduction.md +++ b/docs/user-guide/estia-data-reduction.md @@ -96,7 +96,7 @@ R^{\uparrow\downarrow} & R^{\downarrow\downarrow} \end{bmatrix}. ``` -To simplify the above expressions, collect the terms in the diagonal matrix $\mathbf{D}$ and the (typically full) matrix $\mathbf{a}$ +To simplify the above, collect the terms in the diagonal matrix $\mathbf{D}$ and the (typically full) matrix $\mathbf{a}$ ```math \begin{bmatrix} I^{0+} \\ @@ -141,7 +141,7 @@ R^{\downarrow\downarrow} \end{bmatrix} (q_{n+\frac{1}{2}}). ``` -Integrating $\mathbf{D}$ can be done using the reference measurement, $\mathbf{a}$ is known. +Integrating $\mathbf{D}$ can be done using the reference measurement. $\mathbf{a}$ is known. ### How to compute the integral over $D(\lambda, j)$? From 40098f49d3f63b96d6136446ae2e39490280f1bd Mon Sep 17 00:00:00 2001 From: jokasimr Date: Wed, 27 Nov 2024 11:14:40 +0100 Subject: [PATCH 06/27] Update estia-data-reduction.md --- docs/user-guide/estia-data-reduction.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-guide/estia-data-reduction.md b/docs/user-guide/estia-data-reduction.md index 57024f91..385d8fb7 100644 --- a/docs/user-guide/estia-data-reduction.md +++ b/docs/user-guide/estia-data-reduction.md @@ -39,7 +39,7 @@ and $I^-$ is the intensity of the neutron beam reflected by the analyzer, * $a^\uparrow$ is the analyzer reflectivity for spin up neutrons and $a^\downarrow$ is the analyzer reflectivity for spin down neutrons, * $p^\uparrow$ is the polarizer reflectivity for spin up neutrons and $p^\downarrow$ is the polarizer reflectivity for spin down neutrons, * $f$ is the probability of spin flip by the flipper, -* $D^\pm$ represents the inhomogeneity from the beam- and detector efficiency. They are different for the transmitted and the reflected beam +* $D^\pm$ represents the inhomogeneity from the beam- and detector efficiency (and all other polarization unrelated terms). They are different for the transmitted and the reflected beam because the transmitted and reflected beam hit different pixels. **For simplicity the second flipper was omitted in the above description.** From 36f0d6220d459d372663762d8ca0e5e54542fc2d Mon Sep 17 00:00:00 2001 From: jokasimr Date: Wed, 27 Nov 2024 11:15:19 +0100 Subject: [PATCH 07/27] Update estia-data-reduction.md --- docs/user-guide/estia-data-reduction.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-guide/estia-data-reduction.md b/docs/user-guide/estia-data-reduction.md index 385d8fb7..213bc03d 100644 --- a/docs/user-guide/estia-data-reduction.md +++ b/docs/user-guide/estia-data-reduction.md @@ -40,7 +40,7 @@ and $I^-$ is the intensity of the neutron beam reflected by the analyzer, * $p^\uparrow$ is the polarizer reflectivity for spin up neutrons and $p^\downarrow$ is the polarizer reflectivity for spin down neutrons, * $f$ is the probability of spin flip by the flipper, * $D^\pm$ represents the inhomogeneity from the beam- and detector efficiency (and all other polarization unrelated terms). They are different for the transmitted and the reflected beam - because the transmitted and reflected beam hit different pixels. + because the transmitted and reflected beam hit different areas of the detector. **For simplicity the second flipper was omitted in the above description.** From c63940056f40fcdee42d80f8e1e850e40f859ae9 Mon Sep 17 00:00:00 2001 From: jokasimr Date: Wed, 27 Nov 2024 11:19:29 +0100 Subject: [PATCH 08/27] Update estia-data-reduction.md --- docs/user-guide/estia-data-reduction.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-guide/estia-data-reduction.md b/docs/user-guide/estia-data-reduction.md index 213bc03d..9d09c4ce 100644 --- a/docs/user-guide/estia-data-reduction.md +++ b/docs/user-guide/estia-data-reduction.md @@ -141,7 +141,7 @@ R^{\downarrow\downarrow} \end{bmatrix} (q_{n+\frac{1}{2}}). ``` -Integrating $\mathbf{D}$ can be done using the reference measurement. $\mathbf{a}$ is known. +The integral on the righ-hand-side can be evaluated using the reference measurement. ### How to compute the integral over $D(\lambda, j)$? From 3cf1fabfda7a6ae898b6f5a6111a51d46fa4fa39 Mon Sep 17 00:00:00 2001 From: jokasimr Date: Wed, 27 Nov 2024 11:45:43 +0100 Subject: [PATCH 09/27] Update estia-data-reduction.md --- docs/user-guide/estia-data-reduction.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/user-guide/estia-data-reduction.md b/docs/user-guide/estia-data-reduction.md index 9d09c4ce..c59bc5c7 100644 --- a/docs/user-guide/estia-data-reduction.md +++ b/docs/user-guide/estia-data-reduction.md @@ -17,11 +17,14 @@ D^+ & 0 \\ a^{\uparrow} & a^{\downarrow} \end{bmatrix} \begin{bmatrix} +(1 - f_2) & f_2 \\ f_2 & (1 - f_2) +\end{bmatrix} +\begin{bmatrix} R^{\uparrow\uparrow} & R^{\downarrow\uparrow} \\ R^{\uparrow\downarrow} & R^{\downarrow\downarrow} \end{bmatrix} \begin{bmatrix} -(1 - f) & f \\ f & (1 - f) +(1 - f_1) & f_1 \\ f_1 & (1 - f_1) \end{bmatrix} \begin{bmatrix} 1 - p^{\uparrow} \\ @@ -38,7 +41,7 @@ and $I^-$ is the intensity of the neutron beam reflected by the analyzer, - etc.. * $a^\uparrow$ is the analyzer reflectivity for spin up neutrons and $a^\downarrow$ is the analyzer reflectivity for spin down neutrons, * $p^\uparrow$ is the polarizer reflectivity for spin up neutrons and $p^\downarrow$ is the polarizer reflectivity for spin down neutrons, -* $f$ is the probability of spin flip by the flipper, +* $f_1$ is the probability of spin flip by the polarizer spin flipper, $f_2$ is the probability of spin flip by the analyzer spin flipper * $D^\pm$ represents the inhomogeneity from the beam- and detector efficiency (and all other polarization unrelated terms). They are different for the transmitted and the reflected beam because the transmitted and reflected beam hit different areas of the detector. @@ -46,7 +49,7 @@ and $I^-$ is the intensity of the neutron beam reflected by the analyzer, ## Reducing a measurement -If the sample is measured at two different flipper settings $f=0$ and $f=1$, then we have +If the sample is measured at two different flipper settings $f_1=0, f_2=0$ and $f_1=1, f_2=0$, then we have four measurement in total: ```math \begin{bmatrix} I^{0+} \\ From 6f2e1f6d7079e23251fca70f0ff4baafde28ecec Mon Sep 17 00:00:00 2001 From: jokasimr Date: Wed, 27 Nov 2024 11:50:33 +0100 Subject: [PATCH 10/27] Update estia-data-reduction.md --- docs/user-guide/estia-data-reduction.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-guide/estia-data-reduction.md b/docs/user-guide/estia-data-reduction.md index c59bc5c7..1db2d777 100644 --- a/docs/user-guide/estia-data-reduction.md +++ b/docs/user-guide/estia-data-reduction.md @@ -1,6 +1,6 @@ ## Model -Intensities in the detector are related to the reflectivities of the sample by the model +Intensity in the detector is related to the reflectivity of the sample by the model ```math \begin{bmatrix} I^{+} \\ From 6585eb613ad7aa408cc3098727312203ac93f67c Mon Sep 17 00:00:00 2001 From: jokasimr Date: Wed, 27 Nov 2024 11:59:10 +0100 Subject: [PATCH 11/27] Update estia-data-reduction.md --- docs/user-guide/estia-data-reduction.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/user-guide/estia-data-reduction.md b/docs/user-guide/estia-data-reduction.md index 1db2d777..84a93f49 100644 --- a/docs/user-guide/estia-data-reduction.md +++ b/docs/user-guide/estia-data-reduction.md @@ -149,7 +149,7 @@ The integral on the righ-hand-side can be evaluated using the reference measurem ### How to compute the integral over $D(\lambda, j)$? -For a reference measurement using flipper setting $f=0$ we have +For a reference measurement using flipper setting $f_1=0, f_2=0$ we have ```math \begin{bmatrix} I_{ref}^{+} \\ @@ -190,7 +190,8 @@ D^- ``` where $\mathbf{ar}$ is a diagonal matrix. -For some $b,\Omega$ +The expression for $D$ above can be used to evaluate integrals of $D$ multiplied by explicitly known terms. +For example, for some term $b$ and region of integration $\Omega$ ```math \int_{\Omega} D^+(\lambda, j) b(\lambda, j) d\lambda j = From 12e1136480c2f40a01326c3a7dd9722d7ff41c92 Mon Sep 17 00:00:00 2001 From: jokasimr Date: Wed, 27 Nov 2024 12:09:31 +0100 Subject: [PATCH 12/27] Update estia-data-reduction.md --- docs/user-guide/estia-data-reduction.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/user-guide/estia-data-reduction.md b/docs/user-guide/estia-data-reduction.md index 84a93f49..47b5b87b 100644 --- a/docs/user-guide/estia-data-reduction.md +++ b/docs/user-guide/estia-data-reduction.md @@ -1,3 +1,7 @@ +# Polarization data reduction for ESTIA + +Based on https://confluence.ess.eu/display/ESTIA/Polarised+Neutron+Reflectometry+%28PNR%29+-+Reduction+Notes + ## Model Intensity in the detector is related to the reflectivity of the sample by the model From 38001a3e5a9ebe84748668c9ca404d91ae228953 Mon Sep 17 00:00:00 2001 From: jokasimr Date: Wed, 27 Nov 2024 12:11:55 +0100 Subject: [PATCH 13/27] Update estia-data-reduction.md --- docs/user-guide/estia-data-reduction.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/user-guide/estia-data-reduction.md b/docs/user-guide/estia-data-reduction.md index 47b5b87b..1c7dbc67 100644 --- a/docs/user-guide/estia-data-reduction.md +++ b/docs/user-guide/estia-data-reduction.md @@ -49,8 +49,6 @@ and $I^-$ is the intensity of the neutron beam reflected by the analyzer, * $D^\pm$ represents the inhomogeneity from the beam- and detector efficiency (and all other polarization unrelated terms). They are different for the transmitted and the reflected beam because the transmitted and reflected beam hit different areas of the detector. -**For simplicity the second flipper was omitted in the above description.** - ## Reducing a measurement If the sample is measured at two different flipper settings $f_1=0, f_2=0$ and $f_1=1, f_2=0$, then we have four measurement in total: From 9a5988dc46a1e2132b7309a433cb85b456213bb5 Mon Sep 17 00:00:00 2001 From: jokasimr Date: Wed, 27 Nov 2024 12:22:58 +0100 Subject: [PATCH 14/27] Update estia-data-reduction.md --- docs/user-guide/estia-data-reduction.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/user-guide/estia-data-reduction.md b/docs/user-guide/estia-data-reduction.md index 1c7dbc67..6ea10d28 100644 --- a/docs/user-guide/estia-data-reduction.md +++ b/docs/user-guide/estia-data-reduction.md @@ -147,9 +147,10 @@ R^{\downarrow\downarrow} (q_{n+\frac{1}{2}}). ``` The integral on the righ-hand-side can be evaluated using the reference measurement. +$R$ was moved outside of the integral because if $Q$ is almost constant so is $R(Q)$. -### How to compute the integral over $D(\lambda, j)$? +### How to use the reference measurement to compute the integral over $D(\lambda, j)$? For a reference measurement using flipper setting $f_1=0, f_2=0$ we have ```math From 4725687962d2db8a222c6f3bd06c45af09fc7cc7 Mon Sep 17 00:00:00 2001 From: jokasimr Date: Wed, 27 Nov 2024 13:53:37 +0100 Subject: [PATCH 15/27] Update estia-data-reduction.md --- docs/user-guide/estia-data-reduction.md | 61 ++++++------------------- 1 file changed, 13 insertions(+), 48 deletions(-) diff --git a/docs/user-guide/estia-data-reduction.md b/docs/user-guide/estia-data-reduction.md index 6ea10d28..fc466c34 100644 --- a/docs/user-guide/estia-data-reduction.md +++ b/docs/user-guide/estia-data-reduction.md @@ -12,10 +12,7 @@ I^{-} \end{bmatrix} \big(\lambda, j\big) = -\begin{bmatrix} -D^+ & 0 \\ -0 & D^- -\end{bmatrix} +D(\lambda, j) \begin{bmatrix} 1 - a^{\uparrow} & 1 - a^{\downarrow} \\ a^{\uparrow} & a^{\downarrow} @@ -46,8 +43,7 @@ and $I^-$ is the intensity of the neutron beam reflected by the analyzer, * $a^\uparrow$ is the analyzer reflectivity for spin up neutrons and $a^\downarrow$ is the analyzer reflectivity for spin down neutrons, * $p^\uparrow$ is the polarizer reflectivity for spin up neutrons and $p^\downarrow$ is the polarizer reflectivity for spin down neutrons, * $f_1$ is the probability of spin flip by the polarizer spin flipper, $f_2$ is the probability of spin flip by the analyzer spin flipper -* $D^\pm$ represents the inhomogeneity from the beam- and detector efficiency (and all other polarization unrelated terms). They are different for the transmitted and the reflected beam - because the transmitted and reflected beam hit different areas of the detector. +* $D$ represents the inhomogeneity from the beam- and detector efficiency (and all other polarization unrelated terms). ## Reducing a measurement @@ -59,10 +55,7 @@ I^{0-} \end{bmatrix} \big(\lambda, j\big) = -\begin{bmatrix} -D^+ & 0 \\ -0 & D^- -\end{bmatrix} +D(\lambda, j) \begin{bmatrix} 1 - a^{\uparrow} & 1 - a^{\downarrow} \\ a^{\uparrow} & a^{\downarrow} @@ -83,10 +76,7 @@ I^{1-} \end{bmatrix} \big(\lambda, j\big) = -\begin{bmatrix} -D^+ & 0 \\ -0 & D^- -\end{bmatrix} +D(\lambda, j) \begin{bmatrix} 1 - a^{\uparrow} & 1 - a^{\downarrow} \\ a^{\uparrow} & a^{\downarrow} @@ -101,7 +91,7 @@ R^{\uparrow\downarrow} & R^{\downarrow\downarrow} \end{bmatrix}. ``` -To simplify the above, collect the terms in the diagonal matrix $\mathbf{D}$ and the (typically full) matrix $\mathbf{a}$ +To simplify the above, collect the terms in the matrix $\mathbf{a}$ ```math \begin{bmatrix} I^{0+} \\ @@ -111,7 +101,7 @@ I^{1-} \end{bmatrix} \big(\lambda, j\big) = -\mathbf{D}(\lambda, j) +D(\lambda, j) \mathbf{a}(\lambda) \begin{bmatrix} R^{\uparrow\uparrow} \\ @@ -125,6 +115,7 @@ R^{\downarrow\downarrow} To compute the reflectivities, integrate over a region of (almost) constant $Q$ ```math \int_{Q\in[q_{n}, q_{n+1}]} +\mathbf{a}^{-1}(\lambda) \begin{bmatrix} I^{0+} \\ I^{0-} \\ @@ -135,8 +126,7 @@ I^{1-} d\lambda dj \approx \int_{Q\in[q_{n}, q_{n+1}]} -\mathbf{D}(\lambda, j) -\mathbf{a}(\lambda) +D(\lambda, j) d\lambda dj \begin{bmatrix} R^{\uparrow\uparrow} \\ @@ -160,10 +150,7 @@ I_{ref}^{-} \end{bmatrix} \big(\lambda, j\big) = -\begin{bmatrix} -D^+ & 0 \\ -0 & D^- -\end{bmatrix} +D(\lambda) \begin{bmatrix} 1 - a^{\uparrow} & 1 - a^{\downarrow} \\ a^{\uparrow} & a^{\downarrow} @@ -177,33 +164,11 @@ R_{ref}^{\uparrow\downarrow} & R_{ref}^{\downarrow\downarrow} 1 - p^{\downarrow} \end{bmatrix} ``` -or, simplified by collecting the known terms in the matrix $\mathbf{ar}$ -```math -\begin{bmatrix} -I_{ref}^{+} \\ -I_{ref}^{-} -\end{bmatrix} -\big(\lambda, j\big) -= -\mathbf{ar}(\lambda, j) -\begin{bmatrix} -D^+ \\ -D^- -\end{bmatrix} -``` -where $\mathbf{ar}$ is a diagonal matrix. - -The expression for $D$ above can be used to evaluate integrals of $D$ multiplied by explicitly known terms. -For example, for some term $b$ and region of integration $\Omega$ +or, simplified by collecting the known terms in $r^{\pm}$ ```math -\int_{\Omega} D^+(\lambda, j) b(\lambda, j) d\lambda j +\frac{1}{2}\bigg(\frac{I_{ref}^{+}(\lambda, j)}{r^+(\lambda, j)} + \frac{I_{ref}^{-}(\lambda, j)}{r^-(\lambda, j)}\bigg) = -\int_{\Omega} -\frac{I_{ref}^+(\lambda, j)} -{ar^+(\lambda, j)} -b(\lambda, j) -d\lambda j -\approx \frac{1}{N}\sum_{i\in E_{ref}^+, (\lambda_{i}, j_{i}) \in \Omega} \frac{b(\lambda_{i}, j_{i})}{ar^{+}(\lambda_{i}, j_{i})} +D(\lambda, j). ``` -where the last integral can be approximated using the reference measurement $E_{ref}^+$ (set of events in the reference measurement), $N$ is the number of events in $E_{ref}^+$ that are in $\Omega$. +The expression for $D$ above can be used to evaluate integrals of $D$. From 595fd7f654ff7bd58a998b9afb9bca3de576afa5 Mon Sep 17 00:00:00 2001 From: jokasimr Date: Wed, 27 Nov 2024 14:07:16 +0100 Subject: [PATCH 16/27] Update estia-data-reduction.md --- docs/user-guide/estia-data-reduction.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/user-guide/estia-data-reduction.md b/docs/user-guide/estia-data-reduction.md index fc466c34..4f2718e8 100644 --- a/docs/user-guide/estia-data-reduction.md +++ b/docs/user-guide/estia-data-reduction.md @@ -150,7 +150,7 @@ I_{ref}^{-} \end{bmatrix} \big(\lambda, j\big) = -D(\lambda) +D(\lambda, j) \begin{bmatrix} 1 - a^{\uparrow} & 1 - a^{\downarrow} \\ a^{\uparrow} & a^{\downarrow} @@ -162,13 +162,13 @@ R_{ref}^{\uparrow\downarrow} & R_{ref}^{\downarrow\downarrow} \begin{bmatrix} 1 - p^{\uparrow} \\ 1 - p^{\downarrow} -\end{bmatrix} +\end{bmatrix}. ``` -or, simplified by collecting the known terms in $r^{\pm}$ +But in practice, the analyzer/polarizer will be efficient enough to make only one of $I^\pm$ have enough intensity to be useful: ```math -\frac{1}{2}\bigg(\frac{I_{ref}^{+}(\lambda, j)}{r^+(\lambda, j)} + \frac{I_{ref}^{-}(\lambda, j)}{r^-(\lambda, j)}\bigg) +\frac{I_{ref}^{+}(\lambda, j)}{r^+(\lambda, j)} = D(\lambda, j). ``` -The expression for $D$ above can be used to evaluate integrals of $D$. +The expression for $D$ above can be used to evaluate integrals of $D$, but only in the region of the detector where the transmitted beam hits. From 01c401f799dae10a38787391befa0c8db5baee0c Mon Sep 17 00:00:00 2001 From: jokasimr Date: Wed, 27 Nov 2024 14:08:03 +0100 Subject: [PATCH 17/27] Update estia-data-reduction.md --- docs/user-guide/estia-data-reduction.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-guide/estia-data-reduction.md b/docs/user-guide/estia-data-reduction.md index 4f2718e8..daa0ebaa 100644 --- a/docs/user-guide/estia-data-reduction.md +++ b/docs/user-guide/estia-data-reduction.md @@ -164,7 +164,7 @@ R_{ref}^{\uparrow\downarrow} & R_{ref}^{\downarrow\downarrow} 1 - p^{\downarrow} \end{bmatrix}. ``` -But in practice, the analyzer/polarizer will be efficient enough to make only one of $I^\pm$ have enough intensity to be useful: +But in practice, the analyzer/polarizer will be efficient enough to make only one of $I_{ref}^\pm$ have enough intensity to be useful: ```math \frac{I_{ref}^{+}(\lambda, j)}{r^+(\lambda, j)} = From 5cf83030cf0dbf16b95fa2ab04b96aef5639e36a Mon Sep 17 00:00:00 2001 From: jokasimr Date: Wed, 27 Nov 2024 14:20:10 +0100 Subject: [PATCH 18/27] Update estia-data-reduction.md --- docs/user-guide/estia-data-reduction.md | 123 ++++++++++++++++++++++++ 1 file changed, 123 insertions(+) diff --git a/docs/user-guide/estia-data-reduction.md b/docs/user-guide/estia-data-reduction.md index daa0ebaa..3ff0d4b8 100644 --- a/docs/user-guide/estia-data-reduction.md +++ b/docs/user-guide/estia-data-reduction.md @@ -172,3 +172,126 @@ D(\lambda, j). ``` The expression for $D$ above can be used to evaluate integrals of $D$, but only in the region of the detector where the transmitted beam hits. +To measure $D$ for the entire detector we need to make several reference measurements with different flipper settings so that every part of the detector is illuminated in at least one measurement. +It might be unecessary to use all 4 flipper settings, but to illustrate the idea imagine we make reference measurements using all 4 flipper settings: +```math +\begin{bmatrix} +I_{ref}^{00+} \\ +I_{ref}^{00-} +\end{bmatrix} +\big(\lambda, j\big) += +D(\lambda, j) +\begin{bmatrix} +1 - a^{\uparrow} & 1 - a^{\downarrow} \\ +a^{\uparrow} & a^{\downarrow} +\end{bmatrix} +\begin{bmatrix} +R_{ref}^{\uparrow\uparrow} & R_{ref}^{\downarrow\uparrow} \\ +R_{ref}^{\uparrow\downarrow} & R_{ref}^{\downarrow\downarrow} +\end{bmatrix} +\begin{bmatrix} +1 - p^{\uparrow} \\ +1 - p^{\downarrow} +\end{bmatrix}. +``` +```math +\begin{bmatrix} +I_{ref}^{01+} \\ +I_{ref}^{01-} +\end{bmatrix} +\big(\lambda, j\big) += +D(\lambda, j) +\begin{bmatrix} +1 - a^{\uparrow} & 1 - a^{\downarrow} \\ +a^{\uparrow} & a^{\downarrow} +\end{bmatrix} +\begin{bmatrix} +\begin{bmatrix} +0 & 1 \\ 1 & 0 +\end{bmatrix} +R_{ref}^{\uparrow\uparrow} & R_{ref}^{\downarrow\uparrow} \\ +R_{ref}^{\uparrow\downarrow} & R_{ref}^{\downarrow\downarrow} +\end{bmatrix} +\begin{bmatrix} +1 - p^{\uparrow} \\ +1 - p^{\downarrow} +\end{bmatrix}. +``` +```math +\begin{bmatrix} +I_{ref}^{10+} \\ +I_{ref}^{10-} +\end{bmatrix} +\big(\lambda, j\big) += +D(\lambda, j) +\begin{bmatrix} +1 - a^{\uparrow} & 1 - a^{\downarrow} \\ +a^{\uparrow} & a^{\downarrow} +\end{bmatrix} +\begin{bmatrix} +R_{ref}^{\uparrow\uparrow} & R_{ref}^{\downarrow\uparrow} \\ +R_{ref}^{\uparrow\downarrow} & R_{ref}^{\downarrow\downarrow} +\end{bmatrix} +\begin{bmatrix} +0 & 1 \\ 1 & 0 +\end{bmatrix} +\begin{bmatrix} +1 - p^{\uparrow} \\ +1 - p^{\downarrow} +\end{bmatrix}. +``` +```math +\begin{bmatrix} +I_{ref}^{11+} \\ +I_{ref}^{11-} +\end{bmatrix} +\big(\lambda, j\big) += +D(\lambda, j) +\begin{bmatrix} +1 - a^{\uparrow} & 1 - a^{\downarrow} \\ +a^{\uparrow} & a^{\downarrow} +\end{bmatrix} +\begin{bmatrix} +0 & 1 \\ 1 & 0 +\end{bmatrix} +\begin{bmatrix} +R_{ref}^{\uparrow\uparrow} & R_{ref}^{\downarrow\uparrow} \\ +R_{ref}^{\uparrow\downarrow} & R_{ref}^{\downarrow\downarrow} +\end{bmatrix} +\begin{bmatrix} +0 & 1 \\ 1 & 0 +\end{bmatrix} +\begin{bmatrix} +1 - p^{\uparrow} \\ +1 - p^{\downarrow} +\end{bmatrix}. +``` + +Summing all 8 measurements gives us an expression for $D$ that ought to be valid for the entire detector: +```math +\frac{ +I_{ref}^{00+}(\lambda, j) + +I_{ref}^{00-}(\lambda, j) + +I_{ref}^{01+}(\lambda, j) + +I_{ref}^{01-}(\lambda, j) + +I_{ref}^{10+}(\lambda, j) + +I_{ref}^{10-}(\lambda, j) + +I_{ref}^{11+}(\lambda, j) + +I_{ref}^{11-}(\lambda, j) +}{ +r^00+(\lambda, j) +r^00-(\lambda, j) +r^01+(\lambda, j) +r^01-(\lambda, j) +r^10+(\lambda, j) +r^10-(\lambda, j) +r^11+(\lambda, j) +r^11-(\lambda, j) +} += +D(\lambda, j). +``` From 04319d7ea6d94dca22c9b93731b10f7af0ef943f Mon Sep 17 00:00:00 2001 From: jokasimr Date: Wed, 27 Nov 2024 14:20:52 +0100 Subject: [PATCH 19/27] Update estia-data-reduction.md --- docs/user-guide/estia-data-reduction.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-guide/estia-data-reduction.md b/docs/user-guide/estia-data-reduction.md index 3ff0d4b8..ecdd1093 100644 --- a/docs/user-guide/estia-data-reduction.md +++ b/docs/user-guide/estia-data-reduction.md @@ -208,9 +208,9 @@ D(\lambda, j) a^{\uparrow} & a^{\downarrow} \end{bmatrix} \begin{bmatrix} -\begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix} +\begin{bmatrix} R_{ref}^{\uparrow\uparrow} & R_{ref}^{\downarrow\uparrow} \\ R_{ref}^{\uparrow\downarrow} & R_{ref}^{\downarrow\downarrow} \end{bmatrix} From 7e064a8349dbcfc4815236e60fe75814824985ff Mon Sep 17 00:00:00 2001 From: jokasimr Date: Wed, 27 Nov 2024 14:21:58 +0100 Subject: [PATCH 20/27] Update estia-data-reduction.md --- docs/user-guide/estia-data-reduction.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/user-guide/estia-data-reduction.md b/docs/user-guide/estia-data-reduction.md index ecdd1093..f0f034d5 100644 --- a/docs/user-guide/estia-data-reduction.md +++ b/docs/user-guide/estia-data-reduction.md @@ -283,14 +283,14 @@ I_{ref}^{10-}(\lambda, j) + I_{ref}^{11+}(\lambda, j) + I_{ref}^{11-}(\lambda, j) }{ -r^00+(\lambda, j) -r^00-(\lambda, j) -r^01+(\lambda, j) -r^01-(\lambda, j) -r^10+(\lambda, j) -r^10-(\lambda, j) -r^11+(\lambda, j) -r^11-(\lambda, j) +r^{00+}(\lambda, j) + +r^{00-}(\lambda, j) + +r^{01+}(\lambda, j) + +r^{01-}(\lambda, j) + +r^{10+}(\lambda, j) + +r^{10-}(\lambda, j) + +r^{11+}(\lambda, j) + +r^{11-}(\lambda, j) } = D(\lambda, j). From eea79ca04053b0429f0dc934778706985e5f70ff Mon Sep 17 00:00:00 2001 From: jokasimr Date: Wed, 27 Nov 2024 14:23:14 +0100 Subject: [PATCH 21/27] Update estia-data-reduction.md --- docs/user-guide/estia-data-reduction.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/user-guide/estia-data-reduction.md b/docs/user-guide/estia-data-reduction.md index f0f034d5..972eb66c 100644 --- a/docs/user-guide/estia-data-reduction.md +++ b/docs/user-guide/estia-data-reduction.md @@ -193,7 +193,7 @@ R_{ref}^{\uparrow\downarrow} & R_{ref}^{\downarrow\downarrow} \begin{bmatrix} 1 - p^{\uparrow} \\ 1 - p^{\downarrow} -\end{bmatrix}. +\end{bmatrix} ``` ```math \begin{bmatrix} @@ -217,7 +217,7 @@ R_{ref}^{\uparrow\downarrow} & R_{ref}^{\downarrow\downarrow} \begin{bmatrix} 1 - p^{\uparrow} \\ 1 - p^{\downarrow} -\end{bmatrix}. +\end{bmatrix} ``` ```math \begin{bmatrix} @@ -241,7 +241,7 @@ R_{ref}^{\uparrow\downarrow} & R_{ref}^{\downarrow\downarrow} \begin{bmatrix} 1 - p^{\uparrow} \\ 1 - p^{\downarrow} -\end{bmatrix}. +\end{bmatrix} ``` ```math \begin{bmatrix} From 26872cfbb8030cd2eb4d0831168f48547a23a0c7 Mon Sep 17 00:00:00 2001 From: jokasimr Date: Wed, 27 Nov 2024 14:29:59 +0100 Subject: [PATCH 22/27] Update estia-data-reduction.md --- docs/user-guide/estia-data-reduction.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/user-guide/estia-data-reduction.md b/docs/user-guide/estia-data-reduction.md index 972eb66c..20504745 100644 --- a/docs/user-guide/estia-data-reduction.md +++ b/docs/user-guide/estia-data-reduction.md @@ -164,13 +164,15 @@ R_{ref}^{\uparrow\downarrow} & R_{ref}^{\downarrow\downarrow} 1 - p^{\downarrow} \end{bmatrix}. ``` -But in practice, the analyzer/polarizer will be efficient enough to make only one of $I_{ref}^\pm$ have enough intensity to be useful: +But in practice, the analyzer/polarizer will be efficient enough to make only one of $I_{ref}^\pm$ have enough intensity to be useful. For example: ```math \frac{I_{ref}^{+}(\lambda, j)}{r^+(\lambda, j)} = -D(\lambda, j). +D(\lambda, j) ``` -The expression for $D$ above can be used to evaluate integrals of $D$, but only in the region of the detector where the transmitted beam hits. +where $r^+$ is a known term involving the reflectivity of the supermirror and the pol-/analyzer efficiencies. +The expression for $D$ above can be used to evaluate integrals of $D$. +But in this case, only in the region of the detector where the transmitted beam hits, because we only got data in that region from our reference measurement. To measure $D$ for the entire detector we need to make several reference measurements with different flipper settings so that every part of the detector is illuminated in at least one measurement. It might be unecessary to use all 4 flipper settings, but to illustrate the idea imagine we make reference measurements using all 4 flipper settings: From d00b76e901eadaafc2119a669fcdc4077f8cdc19 Mon Sep 17 00:00:00 2001 From: jokasimr Date: Wed, 27 Nov 2024 14:30:53 +0100 Subject: [PATCH 23/27] Update estia-data-reduction.md --- docs/user-guide/estia-data-reduction.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/user-guide/estia-data-reduction.md b/docs/user-guide/estia-data-reduction.md index 20504745..787e1c80 100644 --- a/docs/user-guide/estia-data-reduction.md +++ b/docs/user-guide/estia-data-reduction.md @@ -171,8 +171,8 @@ But in practice, the analyzer/polarizer will be efficient enough to make only on D(\lambda, j) ``` where $r^+$ is a known term involving the reflectivity of the supermirror and the pol-/analyzer efficiencies. -The expression for $D$ above can be used to evaluate integrals of $D$. -But in this case, only in the region of the detector where the transmitted beam hits, because we only got data in that region from our reference measurement. +The expression for $D$ above can be used to evaluate integrals of $D$, +but in this case only in the region of the detector where the transmitted beam hits, because we only got data in that region from our reference measurement. To measure $D$ for the entire detector we need to make several reference measurements with different flipper settings so that every part of the detector is illuminated in at least one measurement. It might be unecessary to use all 4 flipper settings, but to illustrate the idea imagine we make reference measurements using all 4 flipper settings: From c71e5f30b4709eaa2d34e85be5483ac47b61929e Mon Sep 17 00:00:00 2001 From: jokasimr Date: Wed, 27 Nov 2024 14:35:25 +0100 Subject: [PATCH 24/27] Update estia-data-reduction.md --- docs/user-guide/estia-data-reduction.md | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/docs/user-guide/estia-data-reduction.md b/docs/user-guide/estia-data-reduction.md index 787e1c80..0bcbf50d 100644 --- a/docs/user-guide/estia-data-reduction.md +++ b/docs/user-guide/estia-data-reduction.md @@ -136,9 +136,30 @@ R^{\downarrow\downarrow} \end{bmatrix} (q_{n+\frac{1}{2}}). ``` -The integral on the righ-hand-side can be evaluated using the reference measurement. +The integral on the righ-hand-side can be evaluated using the reference measurement, call evaluated integral $\bar{D}(q_{n+{\frac{1}{2}}})$ $R$ was moved outside of the integral because if $Q$ is almost constant so is $R(Q)$. - +Finally we have +```math +\int_{Q\in[q_{n}, q_{n+1}]} +\mathbf{a}^{-1}(\lambda) +\bar{D}(q_{n+{\frac{1}{2}}}) +\begin{bmatrix} +I^{0+} \\ +I^{0-} \\ +I^{1+} \\ +I^{1-} +\end{bmatrix} +\big(\lambda, j\big) +d\lambda dj +\approx +\begin{bmatrix} +R^{\uparrow\uparrow} \\ +R^{\uparrow\downarrow} \\ +R^{\downarrow\uparrow} \\ +R^{\downarrow\downarrow} +\end{bmatrix} +(q_{n+\frac{1}{2}}). +``` ### How to use the reference measurement to compute the integral over $D(\lambda, j)$? From a4bc09292df0d3bad2f9c5a023908b236fbe288c Mon Sep 17 00:00:00 2001 From: jokasimr Date: Wed, 27 Nov 2024 14:36:13 +0100 Subject: [PATCH 25/27] Update estia-data-reduction.md --- docs/user-guide/estia-data-reduction.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-guide/estia-data-reduction.md b/docs/user-guide/estia-data-reduction.md index 0bcbf50d..fb5475f7 100644 --- a/docs/user-guide/estia-data-reduction.md +++ b/docs/user-guide/estia-data-reduction.md @@ -142,7 +142,7 @@ Finally we have ```math \int_{Q\in[q_{n}, q_{n+1}]} \mathbf{a}^{-1}(\lambda) -\bar{D}(q_{n+{\frac{1}{2}}}) +\bar{D}^{-1}(q_{n+{\frac{1}{2}}}) \begin{bmatrix} I^{0+} \\ I^{0-} \\ From f8f5c58d9c71c755898b968f686d3a3ee18b50bd Mon Sep 17 00:00:00 2001 From: jokasimr Date: Wed, 27 Nov 2024 14:36:53 +0100 Subject: [PATCH 26/27] Update estia-data-reduction.md --- docs/user-guide/estia-data-reduction.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/user-guide/estia-data-reduction.md b/docs/user-guide/estia-data-reduction.md index fb5475f7..35e429f0 100644 --- a/docs/user-guide/estia-data-reduction.md +++ b/docs/user-guide/estia-data-reduction.md @@ -136,8 +136,9 @@ R^{\downarrow\downarrow} \end{bmatrix} (q_{n+\frac{1}{2}}). ``` -The integral on the righ-hand-side can be evaluated using the reference measurement, call evaluated integral $\bar{D}(q_{n+{\frac{1}{2}}})$ +The integral on the righ-hand-side can be evaluated using the reference measurement, call evaluated integral $\bar{D}(q_{n+{\frac{1}{2}}})$. $R$ was moved outside of the integral because if $Q$ is almost constant so is $R(Q)$. + Finally we have ```math \int_{Q\in[q_{n}, q_{n+1}]} From ff27626fadc20db5d441ae60e0770949a8afcca6 Mon Sep 17 00:00:00 2001 From: Johannes Kasimir Date: Tue, 10 Dec 2024 14:45:36 +0100 Subject: [PATCH 27/27] feat: initial setup for estia workflow --- src/ess/estia/__init__.py | 85 +++++++++++++++ src/ess/estia/conversions.py | 97 +++++++++++++++++ src/ess/estia/normalization.py | 183 +++++++++++++++++++++++++++++++++ src/ess/estia/resolution.py | 116 +++++++++++++++++++++ src/ess/estia/types.py | 7 ++ src/ess/estia/workflow.py | 1 + 6 files changed, 489 insertions(+) create mode 100644 src/ess/estia/__init__.py create mode 100644 src/ess/estia/conversions.py create mode 100644 src/ess/estia/normalization.py create mode 100644 src/ess/estia/resolution.py create mode 100644 src/ess/estia/types.py create mode 100644 src/ess/estia/workflow.py diff --git a/src/ess/estia/__init__.py b/src/ess/estia/__init__.py new file mode 100644 index 00000000..dc33be71 --- /dev/null +++ b/src/ess/estia/__init__.py @@ -0,0 +1,85 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (c) 2023 Scipp contributors (https://github.com/scipp) +import importlib.metadata + +import sciline +import scipp as sc + +from ..reflectometry import providers as reflectometry_providers +from ..reflectometry import supermirror +from ..reflectometry.types import ( + BeamSize, + DetectorSpatialResolution, + NeXusDetectorName, + RunType, + SamplePosition, + BeamDivergenceLimits, +) +from . import conversions, load, orso, resolution, utils, figures +from .instrument_view import instrument_view +from .types import ( + AngularResolution, + SampleSizeResolution, + WavelengthResolution, +) + + +try: + __version__ = importlib.metadata.version(__package__ or __name__) +except importlib.metadata.PackageNotFoundError: + __version__ = "0.0.0" + + +providers = ( + *reflectometry_providers, + *load.providers, + *conversions.providers, + *resolution.providers, + *utils.providers, + *figures.providers, + *orso.providers, +) +""" +List of providers for setting up a Sciline pipeline. + +This provides a default Estia workflow including providers for loadings files. +""" + + +def default_parameters() -> dict: + return { + supermirror.MValue: sc.scalar(5, unit=sc.units.dimensionless), + supermirror.CriticalEdge: 0.022 * sc.Unit("1/angstrom"), + supermirror.Alpha: sc.scalar(0.25 / 0.088, unit=sc.units.angstrom), + BeamSize[RunType]: 2.0 * sc.units.mm, + DetectorSpatialResolution[RunType]: 0.0025 * sc.units.m, + SamplePosition[RunType]: sc.vector([0, 0, 0], unit="m"), + NeXusDetectorName[RunType]: "detector", + BeamDivergenceLimits: ( + sc.scalar(-0.75, unit='deg'), + sc.scalar(0.75, unit='deg'), + ), + } + + +def EstiaWorkflow() -> sciline.Pipeline: + """ + Workflow with default parameters for the Estia instrument. + """ + return sciline.Pipeline(providers=providers, params=default_parameters()) + + +__all__ = [ + "supermirror", + "conversions", + "load", + "orso", + "resolution", + "instrument_view", + "providers", + "default_parameters", + "WavelengthResolution", + "AngularResolution", + "SampleSizeResolution", + "EstiaWorkflow", +] diff --git a/src/ess/estia/conversions.py b/src/ess/estia/conversions.py new file mode 100644 index 00000000..f843bed6 --- /dev/null +++ b/src/ess/estia/conversions.py @@ -0,0 +1,97 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (c) 2023 Scipp contributors (https://github.com/scipp) +import scipp as sc + +from ..reflectometry.conversions import reflectometry_q +from ..reflectometry.types import ( + BeamDivergenceLimits, + BeamSize, + RawDetectorData, + ReducibleData, + RunType, + WavelengthBins, + YIndexLimits, + ZIndexLimits, +) + + +def theta(divergence_angle, sample_rotation, detector_rotation): + ''' + Angle of reflection. + + Computes the angle between the scattering direction of + the neutron and the sample surface. + ''' + return divergence_angle + detector_rotation - sample_rotation + + +def angle_of_divergence( + theta, sample_rotation, angle_to_center_of_beam, natural_incidence_angle +): + """ + Difference between the incident angle and the center of the incident beam. + Useful for filtering parts of the beam that have too high divergence. + + This is always in the interval [-0.75 deg, 0.75 deg], + but the divergence of the incident beam can also be reduced. + """ + return ( + theta + - sample_rotation + - angle_to_center_of_beam + - natural_incidence_angle.to(unit='rad') + ) + + +def wavelength( + event_time_offset, + # Other inputs +): + "Converts event_time_offset to wavelength" + # Use frame unwrapping from scippneutron + pass + + +def _not_between(v, a, b): + return (v < a) | (v > b) + + +def add_common_coords_and_masks( + da: RawDetectorData[RunType], + ylim: YIndexLimits, + zlims: ZIndexLimits, + bdlim: BeamDivergenceLimits, + wbins: WavelengthBins, + beam_size: BeamSize[RunType], +) -> ReducibleData[RunType]: + "Adds coords and masks that are useful for both reference and sample measurements." + da = da.transform_coords( + ("wavelength", "theta", "angle_of_divergence", "Q"), + { + "divergence_angle": "pixel_divergence_angle", + "wavelength": wavelength, + "theta": theta, + "angle_of_divergence": angle_of_divergence, + "Q": reflectometry_q, + }, + rename_dims=False, + keep_intermediate=False, + ) + da.masks["stripe_range"] = _not_between(da.coords["stripe"], *ylim) + da.masks['z_range'] = _not_between(da.coords["z_index"], *zlims) + da.bins.masks["divergence_too_large"] = _not_between( + da.bins.coords["angle_of_divergence"], + bdlim[0].to(unit=da.bins.coords["angle_of_divergence"].bins.unit), + bdlim[1].to(unit=da.bins.coords["angle_of_divergence"].bins.unit), + ) + da.bins.masks['wavelength'] = _not_between( + da.bins.coords['wavelength'], + wbins[0], + wbins[-1], + ) + # Correct for illumination of virtual source + da /= sc.sin(da.bins.coords['theta']) + return da + + +providers = (add_common_coords_and_masks,) diff --git a/src/ess/estia/normalization.py b/src/ess/estia/normalization.py new file mode 100644 index 00000000..5ecaf455 --- /dev/null +++ b/src/ess/estia/normalization.py @@ -0,0 +1,183 @@ +import scipp as sc + +from ..reflectometry.conversions import reflectometry_q +from ..reflectometry.supermirror import ( + Alpha, + CriticalEdge, + MValue, + supermirror_reflectivity, +) +from ..reflectometry.types import ( + DetectorSpatialResolution, + QBins, + ReducedReference, + ReducibleData, + Reference, + ReferenceRun, + ReflectivityOverQ, + ReflectivityOverZW, + Sample, + SampleRun, + WavelengthBins, +) +from .conversions import theta +from .resolution import ( + angular_resolution, + q_resolution, + sample_size_resolution, + wavelength_resolution, +) + + +def mask_events_where_supermirror_does_not_cover( + sam: ReducibleData[SampleRun], + ref: ReducedReference, + critical_edge: CriticalEdge, + mvalue: MValue, + alpha: Alpha, +) -> Sample: + """ + Mask events in regions of the detector the reference does not cover. + + Regions of the detector that the reference + measurement doesn't cover cannot be used to compute reflectivity. + + Preferably the reference measurement should cover the entire + detector, but sometimes that is not possible, for example + if the supermirror :math:`M` value was too limited or because the reference + was measured at too high angle. + + To figure out what events need to be masked, + compute the supermirror reflectivity as a function + of the :math:`Q` the event would have had if it had belonged to + the reference measurement. + """ + R = supermirror_reflectivity( + reflectometry_q( + sam.bins.coords["wavelength"], + theta( + sam.coords["pixel_divergence_angle"], + ref.coords["sample_rotation"], + ref.coords["detector_rotation"], + ), + ), + c=critical_edge, + m=mvalue, + alpha=alpha, + ) + sam.bins.masks["supermirror_does_not_cover"] = sc.isnan(R) + return sam + + +def reduce_reference( + reference: ReducibleData[ReferenceRun], + wavelength_bins: WavelengthBins, + critical_edge: CriticalEdge, + mvalue: MValue, + alpha: Alpha, +) -> ReducedReference: + """ + Reduces the reference measurement to estimate the + intensity distribution in the detector for + an ideal sample with reflectivity :math:`R = 1`. + """ + R = supermirror_reflectivity( + reference.bins.coords['Q'], + c=critical_edge, + m=mvalue, + alpha=alpha, + ) + reference.bins.masks['invalid'] = sc.isnan(R) + reference /= R + return reference.bins.concat(('stripe',)).hist(wavelength=wavelength_bins) + + +def reduce_sample_over_q( + sample: Sample, + reference: Reference, + qbins: QBins, +) -> ReflectivityOverQ: + """ + Computes reflectivity as ratio of + sample intensity and intensity from a sample + with ideal reflectivity. + + Returns reflectivity as a function of :math:`Q`. + """ + h = reference.flatten(to='Q').hist(Q=qbins) + R = sample.bins.concat().bin(Q=qbins) / h.data + R.coords['Q_resolution'] = sc.sqrt( + ( + (reference * reference.coords['Q_resolution'] ** 2) + .flatten(to='Q') + .hist(Q=qbins) + ) + / h + ).data + return R + + +def reduce_sample_over_zw( + sample: Sample, + reference: Reference, + wbins: WavelengthBins, +) -> ReflectivityOverZW: + """ + Computes reflectivity as ratio of + sample intensity and intensity from a sample + with ideal reflectivity. + + Returns reflectivity as a function of ``blade``, ``wire`` and :math:`\\wavelength`. + """ + R = sample.bins.concat(('stripe',)).bin(wavelength=wbins) / reference.data + R.masks["too_few_events"] = reference.data < sc.scalar(1, unit="counts") + return R + + +def evaluate_reference( + reference: ReducedReference, + sample: ReducibleData[SampleRun], + qbins: QBins, + detector_spatial_resolution: DetectorSpatialResolution[SampleRun], +) -> Reference: + """ + Adds a :math:`Q` and :math:`Q`-resolution coordinate to each bin of the ideal + intensity distribution. The coordinates are computed as if the data came from + the sample measurement, that is, they use the ``sample_rotation`` + and ``detector_rotation`` parameters from the sample measurement. + """ + ref = reference.copy() + ref.coords["sample_rotation"] = sample.coords["sample_rotation"] + ref.coords["detector_rotation"] = sample.coords["detector_rotation"] + ref.coords["sample_size"] = sample.coords["sample_size"] + ref.coords["detector_spatial_resolution"] = detector_spatial_resolution + ref.coords["wavelength"] = sc.midpoints(ref.coords["wavelength"]) + ref = ref.transform_coords( + ( + "Q", + "wavelength_resolution", + "sample_size_resolution", + "angular_resolution", + "Q_resolution", + ), + { + "divergence_angle": "pixel_divergence_angle", + "theta": theta, + "Q": reflectometry_q, + "wavelength_resolution": wavelength_resolution, + "sample_size_resolution": sample_size_resolution, + "angular_resolution": angular_resolution, + "Q_resolution": q_resolution, + }, + rename_dims=False, + ) + return sc.values(ref) + + +providers = ( + reduce_reference, + reduce_sample_over_q, + reduce_sample_over_zw, + evaluate_reference, + mask_events_where_supermirror_does_not_cover, +) diff --git a/src/ess/estia/resolution.py b/src/ess/estia/resolution.py new file mode 100644 index 00000000..3940e00f --- /dev/null +++ b/src/ess/estia/resolution.py @@ -0,0 +1,116 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (c) 2023 Scipp contributors (https://github.com/scipp) +import scipp as sc + +from ..reflectometry.tools import fwhm_to_std + + +def wavelength_resolution( + # What parameters are needed? +): + """ + Find the wavelength resolution contribution of the ESTIA instrument. + + Parameters + ---------- + + L1: + Distance from midpoint between choppers to sample. + L2: + Distance from sample to detector. + + Returns + ------- + : + The wavelength resolution variable, as standard deviation. + """ + # Don't yet know how to do this + raise NotImplementedError() + + +def sample_size_resolution( + L2, + sample_size, +): + """ + The resolution from the projected sample size, where it may be bigger + than the detector pixel resolution as described in Section 4.3.3 of the Amor + publication (doi: 10.1016/j.nima.2016.03.007). + + Parameters + ---------- + L2: + Distance from sample to detector. + sample_size: + Size of sample. + + Returns + ------- + : + Standard deviation of contribution from the sample size. + """ + return fwhm_to_std(sample_size / L2.to(unit=sample_size.unit)) + + +def angular_resolution( + theta, + L2, + detector_spatial_resolution, +): + """ + Determine the angular resolution of the ESTIA instrument. + + Parameters + ---------- + theta: + Angle of reflection. + L2: + Distance between sample and detector. + detector_spatial_resolution: + FWHM of detector pixel resolution. + + Returns + ------- + : + Angular resolution standard deviation + """ + return ( + fwhm_to_std( + sc.atan( + detector_spatial_resolution + / L2.to(unit=detector_spatial_resolution.unit) + ) + ).to(unit=theta.unit) + / theta + ) + + +def q_resolution( + Q, + angular_resolution, + wavelength_resolution, + sample_size_resolution, +): + """ + Compute resolution in Q. + + Parameters + ---------- + Q: + Momentum transfer. + angular_resolution: + Angular resolution contribution. + wavelength_resolution: + Wavelength resolution contribution. + sample_size_resolution: + Sample size resolution contribution. + + Returns + ------- + : + Q resolution function. + """ + return sc.sqrt( + (angular_resolution**2 + wavelength_resolution**2 + sample_size_resolution**2) + * Q**2 + ) diff --git a/src/ess/estia/types.py b/src/ess/estia/types.py new file mode 100644 index 00000000..024960f2 --- /dev/null +++ b/src/ess/estia/types.py @@ -0,0 +1,7 @@ +from typing import NewType + +import scipp as sc + +WavelengthResolution = NewType("WavelengthResolution", sc.Variable) +AngularResolution = NewType("AngularResolution", sc.Variable) +SampleSizeResolution = NewType("SampleSizeResolution", sc.Variable) diff --git a/src/ess/estia/workflow.py b/src/ess/estia/workflow.py new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/src/ess/estia/workflow.py @@ -0,0 +1 @@ +