Skip to content

Commit 9506593

Browse files
committed
refactor: rename ioq to reflectivity and add resolution as coord
1 parent ce78cb1 commit 9506593

File tree

8 files changed

+33
-20
lines changed

8 files changed

+33
-20
lines changed

docs/user-guide/amor/amor-reduction.ipynb

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@
1818
"## Setup"
1919
]
2020
},
21+
{
22+
"cell_type": "code",
23+
"execution_count": null,
24+
"metadata": {},
25+
"outputs": [],
26+
"source": [
27+
"import warnings\n",
28+
"warnings.filterwarnings('ignore')"
29+
]
30+
},
2131
{
2232
"cell_type": "code",
2333
"execution_count": null,
@@ -85,7 +95,7 @@
8595
"metadata": {},
8696
"outputs": [],
8797
"source": [
88-
"workflow.visualize(NormalizedIofQ, graph_attr={'rankdir': 'LR'})"
98+
"workflow.visualize(ReflectivityOverQ, graph_attr={'rankdir': 'LR'})"
8999
]
90100
},
91101
{
@@ -128,7 +138,7 @@
128138
"metadata": {},
129139
"outputs": [],
130140
"source": [
131-
"workflow.visualize(NormalizedIofQ, graph_attr={'rankdir': 'LR'})"
141+
"workflow.visualize(ReflectivityOverQ, graph_attr={'rankdir': 'LR'})"
132142
]
133143
},
134144
{
@@ -158,7 +168,7 @@
158168
"for file, angle in runs.items():\n",
159169
" workflow[Filename[SampleRun]] = amor.data.amor_sample_run(file)\n",
160170
" workflow[SampleRotation[SampleRun]] = angle\n",
161-
" results[file] = workflow.compute(NormalizedIofQ).hist()\n",
171+
" results[file] = workflow.compute(ReflectivityOverQ).hist()\n",
162172
"\n",
163173
"sc.plot(results, norm='log', vmin=1e-4)"
164174
]
@@ -185,7 +195,8 @@
185195
"outputs": [],
186196
"source": [
187197
"from ess.reflectometry.tools import combine_curves\n",
188-
"combine_curves(results_scaled.values(), workflow.compute(QBins)).plot(norm='log')"
198+
"c = combine_curves(results_scaled.values(), workflow.compute(QBins))\n",
199+
"c.plot(norm='log')"
189200
]
190201
},
191202
{

docs/user-guide/amor/compare-to-eos.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
" print(key, '... ', end='')\n",
124124
" workflow[SampleRotation[SampleRun]] = sc.scalar(angle + 0.05, unit='deg')\n",
125125
" workflow[Filename[SampleRun]] = amor.data.amor_sample_run(key)\n",
126-
" da = workflow.compute(NormalizedIofQ).hist()\n",
126+
" da = workflow.compute(ReflectivityOverQ).hist()\n",
127127
" da.coords['Q'] = sc.midpoints(da.coords['Q'], dim='Q')\n",
128128
" results['ess'][key] = da\n",
129129
" print('Done!')"

src/ess/amor/orso.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
OrsoIofQDataset,
1515
OrsoReduction,
1616
)
17-
from ..reflectometry.types import NormalizedIofQ, QResolution
17+
from ..reflectometry.types import QResolution, ReflectivityOverQ
1818

1919

20-
def build_orso_instrument(events: NormalizedIofQ) -> OrsoInstrument:
20+
def build_orso_instrument(events: ReflectivityOverQ) -> OrsoInstrument:
2121
"""Build ORSO instrument metadata from intermediate reduction results for Amor.
2222
2323
This assumes specular reflection and sets the incident angle equal to the computed
@@ -33,7 +33,7 @@ def build_orso_instrument(events: NormalizedIofQ) -> OrsoInstrument:
3333

3434

3535
def build_orso_iofq_dataset(
36-
iofq: NormalizedIofQ,
36+
iofq: ReflectivityOverQ,
3737
sigma_q: QResolution,
3838
data_source: OrsoDataSource,
3939
reduction: OrsoReduction,

src/ess/amor/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
from ess.reflectometry.types import (
44
DetectorRotation,
5-
NormalizedIofQ,
65
QBins,
76
ReflectivityData,
7+
ReflectivityOverQ,
88
RunType,
99
SampleRotation,
1010
SampleRun,
@@ -112,7 +112,7 @@ def diagnostic_view(
112112
lath: WavelengthThetaFigure,
113113
laz: WavelengthZIndexFigure,
114114
qth: QThetaFigure,
115-
ioq: NormalizedIofQ,
115+
ioq: ReflectivityOverQ,
116116
) -> ReflectivityDiagnosticsView:
117117
ioq = ioq.hist().plot(norm="log")
118118
return (ioq + laz) / (lath + qth)

src/ess/reflectometry/normalize.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
FootprintCorrectedData,
1010
IdealReferenceIntensity,
1111
NormalizationFactor,
12-
NormalizedIofQ,
1312
QBins,
13+
QResolution,
1414
ReflectivityData,
15+
ReflectivityOverQ,
1516
SampleRun,
1617
WavelengthBins,
1718
)
@@ -94,7 +95,8 @@ def reflectivity_over_q(
9495
da: FootprintCorrectedData[SampleRun],
9596
n: NormalizationFactor,
9697
qbins: QBins,
97-
) -> NormalizedIofQ:
98+
qres: QResolution,
99+
) -> ReflectivityOverQ:
98100
"""
99101
Normalize the sample measurement by the (ideally calibrated) supermirror.
100102
@@ -110,9 +112,9 @@ def reflectivity_over_q(
110112
:
111113
Reflectivity as a function of Q
112114
"""
113-
return NormalizedIofQ(
114-
da.bin(Q=qbins, dim=da.dims) / sc.values(n.hist(Q=qbins, dim=n.dims))
115-
)
115+
reflectivity = da.bin(Q=qbins, dim=da.dims) / sc.values(n.hist(Q=qbins, dim=n.dims))
116+
reflectivity.coords['Q_resolution'] = qres.data
117+
return ReflectivityOverQ(reflectivity)
116118

117119

118120
def reflectivity_per_event(

src/ess/reflectometry/reductions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# SPDX-License-Identifier: BSD-3-Clause
22
# Copyright (c) 2023 Scipp contributors (https://github.com/scipp)
33

4-
from .types import NormalizedIofQ, NormalizedIofQ1D
4+
from .types import ReflectivityOverQ, ReflectivityOverQ1D
55

66

7-
def average_over_detectors(iofq: NormalizedIofQ) -> NormalizedIofQ1D:
7+
def average_over_detectors(iofq: ReflectivityOverQ) -> ReflectivityOverQ1D:
88
"""Average over all detector pixels."""
99
return iofq.mean(dim='detector_number')
1010

src/ess/reflectometry/types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class FootprintCorrectedData(sciline.Scope[RunType, sc.DataArray], sc.DataArray)
6464
NormalizationFactor = NewType("NormalizationFactor", sc.DataArray)
6565
""":code`IdealReferenceIntensity` with added coordinate "sample"-Q"""
6666

67-
NormalizedIofQ = NewType("NormalizedIofQ", sc.DataArray)
67+
ReflectivityOverQ = NewType("ReflectivityOverQ", sc.DataArray)
6868
"""Intensity histogram over momentum transfer
6969
normalized by the calibrated reference measurement."""
7070

tests/amor/pipeline_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
from ess.reflectometry import orso
1414
from ess.reflectometry.types import (
1515
Filename,
16-
NormalizedIofQ,
1716
QBins,
1817
ReferenceRun,
18+
ReflectivityOverQ,
1919
SampleRotation,
2020
SampleRun,
2121
SampleSize,
@@ -57,7 +57,7 @@ def amor_pipeline() -> sciline.Pipeline:
5757

5858

5959
def test_run_data_pipeline(amor_pipeline: sciline.Pipeline):
60-
res = amor_pipeline.compute(NormalizedIofQ)
60+
res = amor_pipeline.compute(ReflectivityOverQ)
6161
assert "Q" in res.coords
6262

6363

0 commit comments

Comments
 (0)