Skip to content

Commit 9658a66

Browse files
authored
Merge branch 'main' into publish-reduce-scitiff
2 parents 4140529 + 0fd5fbf commit 9658a66

37 files changed

Lines changed: 2119 additions & 964 deletions

.github/workflows/nightly.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ jobs:
123123
with:
124124
version: "0.7.21"
125125
python-version: "3.11"
126-
cache-suffix: ${{ matrix.package }}
126+
cache-suffix: ${{ matrix.package }}-lower-bound
127127
- name: Test with lowest direct dependencies
128128
working-directory: packages/${{ matrix.package }}
129129
run: uv run --extra=test --resolution=lowest-direct pytest
@@ -150,7 +150,7 @@ jobs:
150150
with:
151151
version: "0.7.21"
152152
python-version: "3.11"
153-
cache-suffix: ${{ matrix.package }}
153+
cache-suffix: ${{ matrix.package }}-latest
154154
- name: Test with latest dependencies
155155
working-directory: packages/${{ matrix.package }}
156156
run: uv run --extra=test --resolution=highest pytest

packages/essdiffraction/docs/api-reference/index.md

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
11
# API Reference
22

3+
## ESSdiffraction
4+
5+
### Submodules
6+
7+
```{eval-rst}
8+
.. currentmodule:: ess.diffraction
9+
10+
.. autosummary::
11+
:toctree: ../generated/modules
12+
:template: module-template.rst
13+
:recursive:
14+
15+
pdf
16+
peaks
17+
```
18+
319
## ESSpowder
420

521
### Module Attributes
22+
623
```{eval-rst}
724
.. currentmodule:: ess.powder
825
@@ -37,17 +54,14 @@
3754
grouping
3855
logging
3956
masking
40-
peaks
4157
smoothing
42-
transform
4358
types
4459
```
4560

4661
## DREAM
4762

4863
### Workflows
4964

50-
5165
```{eval-rst}
5266
.. currentmodule:: ess.dream
5367
@@ -103,15 +117,20 @@
103117

104118
### Workflows
105119

106-
107120
```{eval-rst}
108121
.. currentmodule:: ess.beer
109122
110123
.. autosummary::
111124
:toctree: ../generated/functions
112125
126+
BeerMcStasWorkflowPulseShaping
127+
BeerMcStasWorkflowPulseShapingAnalytical
113128
BeerModMcStasWorkflowKnownPeaks
114129
BeerModMcStasWorkflow
130+
BeerPowderWorkflow
131+
BeerPowderWorkflowAnalytical
132+
BeerPowderMcStasWorkflow
133+
BeerPowderMcStasWorkflowAnalytical
115134
```
116135

117136
### Top-level functions
@@ -122,7 +141,8 @@
122141
.. autosummary::
123142
:toctree: ../generated/functions
124143
125-
load_beer_mcstas
144+
dhkl_peaks_from_cif
145+
load_beer_mcstas
126146
```
127147

128148
### Submodules
@@ -137,14 +157,14 @@
137157
conversions
138158
data
139159
io
160+
mcstas
140161
workflow
141162
```
142163

143164
## MAGIC
144165

145166
### Workflows
146167

147-
148168
```{eval-rst}
149169
.. currentmodule:: ess.magic
150170

packages/essdiffraction/docs/conf.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,12 @@
249249
# build already tests if those plots can be made.
250250
# So we simply disable plots in doctests.
251251
doctest_global_setup = """
252+
# Private import because of https://github.com/mctools/ncrystal/issues/361
253+
from NCrystal._common import set_ncrystal_print_fct
252254
import numpy as np
253255
256+
set_ncrystal_print_fct(lambda *args, **kwargs: None)
257+
254258
try:
255259
import scipp as sc
256260

packages/essdiffraction/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ dependencies = [
3333
"graphviz>=0.20",
3434
"essreduce>=26.6.0",
3535
"numpy>=2",
36-
"plopp>=26.2.0",
36+
"plopp>=26.5.0",
3737
"pythreejs>=2.4.1",
3838
"tof>=25.12.0",
3939
"ncrystal[cif]>=4.1.0",

packages/essdiffraction/src/ess/beer/__init__.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,17 @@
77

88
import importlib.metadata
99

10-
from .io import load_beer_mcstas
10+
from .mcstas import load_beer_mcstas
1111
from .peakfinding import dhkl_peaks_from_cif
1212
from .workflow import (
1313
BeerMcStasWorkflowPulseShaping,
14+
BeerMcStasWorkflowPulseShapingAnalytical,
1415
BeerModMcStasWorkflow,
1516
BeerModMcStasWorkflowKnownPeaks,
17+
BeerPowderMcStasWorkflow,
18+
BeerPowderMcStasWorkflowAnalytical,
19+
BeerPowderWorkflow,
20+
BeerPowderWorkflowAnalytical,
1621
default_parameters,
1722
)
1823

@@ -25,8 +30,13 @@
2530

2631
__all__ = [
2732
'BeerMcStasWorkflowPulseShaping',
33+
'BeerMcStasWorkflowPulseShapingAnalytical',
2834
'BeerModMcStasWorkflow',
2935
'BeerModMcStasWorkflowKnownPeaks',
36+
'BeerPowderMcStasWorkflow',
37+
'BeerPowderMcStasWorkflowAnalytical',
38+
'BeerPowderWorkflow',
39+
'BeerPowderWorkflowAnalytical',
3040
'__version__',
3141
'default_parameters',
3242
'dhkl_peaks_from_cif',

packages/essdiffraction/src/ess/beer/clustering.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from ess.powder.types import RunType
33
from scipy.signal import find_peaks, medfilt
44

5-
from .conversions import tof_from_t0_estimate_graph
5+
from .conversions import tof_from_nominal_time_at_chopper_graph
66
from .types import (
77
GeometryCoordTransformGraph,
88
RawDetector,
@@ -13,7 +13,7 @@
1313
def cluster_events_by_streak(
1414
da: RawDetector[RunType], gg: GeometryCoordTransformGraph
1515
) -> StreakClusteredData[RunType]:
16-
graph = tof_from_t0_estimate_graph(da, gg)
16+
graph = tof_from_nominal_time_at_chopper_graph(da, gg)
1717

1818
da = da.transform_coords(['dspacing'], graph=graph)
1919
da.bins.coords['coarse_d'] = da.bins.coords.pop('dspacing').to(unit='angstrom')

packages/essdiffraction/src/ess/beer/conversions.py

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ def compute_wavelength_in_each_cluster(
1919
da: StreakClusteredData[RunType],
2020
chopper_delay: WavelengthDefinitionChopperDelay,
2121
mod_period: ModulationPeriod,
22-
graph: GeometryCoordTransformGraph,
2322
) -> WavelengthDetector[RunType]:
2423
"""Fits a line through each cluster, the intercept of the line is t0.
2524
The line is fitted using linear regression with an outlier removal procedure.
@@ -38,7 +37,7 @@ def compute_wavelength_in_each_cluster(
3837
if isinstance(da, sc.DataGroup):
3938
return sc.DataGroup(
4039
{
41-
k: compute_wavelength_in_each_cluster(v, mod_period)
40+
k: compute_wavelength_in_each_cluster(v, chopper_delay, mod_period)
4241
for k, v in da.items()
4342
}
4443
)
@@ -133,7 +132,7 @@ def _compute_d_given_list_of_peaks(
133132
/ (scipp.constants.h / scipp.constants.m_n)
134133
).to(unit=f'{time_of_arrival.unit}/angstrom')
135134
for dhkl in dhkl_list:
136-
dt = sc.abs(t - dhkl * const)
135+
dt = sc.abs(t - dhkl * const - pulse_length / 2)
137136
dt_in_range = dt < pulse_length / 2
138137
no_dt_found = sc.isnan(dtfound)
139138
dtfound = sc.where(dt_in_range, sc.where(no_dt_found, dt, dtfound), dtfound)
@@ -191,34 +190,16 @@ def _tof_from_dhkl(
191190
return out
192191

193192

194-
def t0_estimate(
195-
wavelength_estimate: sc.Variable,
196-
source_to_wavelength_definition_chopper_distance: sc.Variable,
197-
) -> sc.Variable:
198-
"""
199-
Computes the time a neutron reaches a chopper at
200-
``source_to_wavelength_chopper_distance`` distance from the source
201-
if it has wavelength ``wavelength_estimate``.
202-
"""
203-
return (
204-
sc.constants.m_n
205-
/ sc.constants.h
206-
* wavelength_estimate
207-
* source_to_wavelength_definition_chopper_distance.to(
208-
unit=wavelength_estimate.unit
209-
)
210-
).to(unit='s')
211-
212-
213-
def tof_from_t0_estimate_graph(
193+
def tof_from_nominal_time_at_chopper_graph(
214194
da: RawDetector[RunType],
215195
gg: GeometryCoordTransformGraph,
216196
) -> ElasticCoordTransformGraph[RunType]:
217197
"""Graph for computing ``wavelength`` in pulse shaping chopper modes."""
218198
return {
219199
**gg,
220-
't0': t0_estimate,
221-
'tof': lambda time_of_arrival, t0: time_of_arrival - t0,
200+
'tof': lambda time_of_arrival, nominal_time_at_chopper: (
201+
time_of_arrival - nominal_time_at_chopper
202+
),
222203
'time_of_arrival': time_of_arrival,
223204
}
224205

@@ -287,7 +268,7 @@ def wavelength_detector(
287268
)
288269
convert_pulse_shaping = (
289270
geometry_graph,
290-
tof_from_t0_estimate_graph,
271+
tof_from_nominal_time_at_chopper_graph,
291272
wavelength_detector,
292273
)
293274
providers = (compute_wavelength_in_each_cluster, geometry_graph)

packages/essdiffraction/src/ess/beer/data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
# Simulations from new model with corrected(?) moderator to detector
3232
# distance.
3333
# For correct reduction you need to use
34-
# beer.io.mcstas_chopper_delay_from_mode_new_simulations
34+
# beer.mcstas.mcstas_chopper_delay_from_mode_new_simulations
3535
# to obtain the correct WavelengthDefinitionChopperDelay for these files.
3636
"silicon-mode10-new-model.h5": "md5:98500830f27700fc719634e1acd49944",
3737
"silicon-mode16-new-model.h5": "md5:393f9287e7d3f97ceedbe64343918413",

0 commit comments

Comments
 (0)