Skip to content

Commit b764f28

Browse files
authored
Merge pull request #28 from scipp/fix-wavelength-bounds
fix: re-add the optional wavelength edges
2 parents 2bd788f + 748c314 commit b764f28

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

docs/examples/amor.ipynb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
" Filename[Sample]: \"sample.nxs\",\n",
3737
" SampleRotation[Reference]: sc.scalar(0.8389, unit='deg'),\n",
3838
" Filename[Reference]: \"reference.nxs\",\n",
39+
" WavelengthEdges: sc.array(dims=['wavelength'], values=[2.4, 16.0], unit='angstrom'),\n",
3940
"}"
4041
]
4142
},
@@ -121,7 +122,7 @@
121122
],
122123
"metadata": {
123124
"kernelspec": {
124-
"display_name": "essreflectometry",
125+
"display_name": "Python 3 (ipykernel)",
125126
"language": "python",
126127
"name": "python3"
127128
},
@@ -139,5 +140,5 @@
139140
}
140141
},
141142
"nbformat": 4,
142-
"nbformat_minor": 2
143+
"nbformat_minor": 4
143144
}

src/essreflectometry/amor/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@
77

88
from .. import providers as reflectometry_providers
99
from .. import supermirror
10-
from ..types import BeamSize, DetectorSpatialResolution, Gravity, Run, SampleSize
10+
from ..types import (
11+
BeamSize,
12+
DetectorSpatialResolution,
13+
Gravity,
14+
Run,
15+
SampleSize,
16+
WavelengthEdges,
17+
)
1118
from . import beamline, conversions, load, resolution
1219
from .beamline import instrument_view_components
1320
from .instrument_view import instrument_view

src/essreflectometry/conversions.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# SPDX-License-Identifier: BSD-3-Clause
22
# Copyright (c) 2023 Scipp contributors (https://github.com/scipp)
3+
from typing import Optional
4+
35
import scipp as sc
46
from scipp.constants import h, m_n, pi
57
from scippneutron._utils import elem_dtype, elem_unit
@@ -16,6 +18,7 @@
1618
SpecularReflectionCoordTransformGraph,
1719
ThetaData,
1820
WavelengthData,
21+
WavelengthEdges,
1922
)
2023

2124

@@ -118,6 +121,7 @@ def specular_reflection() -> SpecularReflectionCoordTransformGraph:
118121
def tof_to_wavelength(
119122
data_array: RawData[Run],
120123
graph: SpecularReflectionCoordTransformGraph,
124+
wavelength_edges: Optional[WavelengthEdges],
121125
) -> WavelengthData[Run]:
122126
"""
123127
Use :code:`transform_coords` to convert from ToF to wavelength, cutoff high and
@@ -129,13 +133,17 @@ def tof_to_wavelength(
129133
Data array to convert.
130134
graph:
131135
Graph for :code:`transform_coords`.
136+
wavelength_edges:
137+
Bounds for wavelength values, exclude data outside of bounds.
132138
133139
Returns
134140
-------
135141
:
136142
New data array with wavelength dimension.
137143
"""
138144
data_array_wav = data_array.transform_coords(["wavelength"], graph=graph)
145+
if wavelength_edges is not None:
146+
data_array_wav = data_array_wav.bin({wavelength_edges.dim: wavelength_edges})
139147
# TODO
140148
# try:
141149
# from orsopy import fileio

src/essreflectometry/types.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ class IofQ(sciline.Scope[Run, sc.DataArray], sc.DataArray):
6666
QBins = NewType('QBins', sc.Variable)
6767
'''Bins for the momentum transfer histogram.'''
6868

69+
WavelengthEdges = NewType('WavelengthEdges', sc.Variable)
70+
'''Include only events within the specified edges.'''
71+
6972

7073
class Filename(sciline.Scope[Run, str], str):
7174
"""Filename of the event data nexus file."""

0 commit comments

Comments
 (0)