Skip to content

Commit 9e48ffe

Browse files
committed
fix: shape and size of the estia detector
1 parent 3bd32be commit 9e48ffe

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

docs/user-guide/estia/estia-mcstas-reduction.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
"wf[Filename[ReferenceRun]] = estia_mcstas_example('reference')\n",
5858
"\n",
5959
"wf[YIndexLimits] = sc.scalar(35), sc.scalar(64)\n",
60-
"wf[ZIndexLimits] = sc.scalar(0), sc.scalar(14 * 32)\n",
60+
"wf[ZIndexLimits] = sc.scalar(0), sc.scalar(48 * 32)\n",
6161
"wf[BeamDivergenceLimits] = sc.scalar(-0.75, unit='deg'), sc.scalar(0.75, unit='deg')\n",
6262
"wf[WavelengthBins] = sc.geomspace('wavelength', 3.5, 12, 2001, unit='angstrom')\n",
6363
"wf[QBins] = 1000\n",

src/ess/estia/load.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,14 @@ def load_mcstas_events(
3838
unit=da.coords['sample_rotation'].unit
3939
)
4040

41-
xbins = sc.linspace('x', -0.25, 0.25, 14 * 32 + 1)
42-
ybins = sc.linspace('y', -0.25, 0.25, 65)
43-
da = da.bin(x=xbins, y=ybins).rename_dims({'y': 'stripe'})
44-
da.coords['stripe'] = sc.arange('stripe', 0, 64)
45-
da.coords['z_index'] = sc.arange('x', 14 * 32 - 1, -1, -1)
41+
nblades = 48
42+
nwires = 32
43+
nstripes = 64
44+
xbins = sc.linspace('x', -0.25, 0.25, nblades * nwires + 1)
45+
ybins = sc.linspace('y', -0.13, 0.13, nstripes + 1)
46+
da = da.bin(y=ybins, x=xbins).rename_dims({'y': 'stripe'})
47+
da.coords['stripe'] = sc.arange('stripe', 0, nstripes)
48+
da.coords['z_index'] = sc.arange('x', nblades * nwires - 1, -1, -1)
4649

4750
# Information is not available in the mcstas output files, therefore it's hardcoded
4851
da.coords['sample_position'] = sc.vector([0.264298, -0.427595, 35.0512], unit='m')
@@ -64,7 +67,7 @@ def load_mcstas_events(
6467
x=sc.midpoints(da.coords['x']) * sc.scalar(1.0, unit='m'),
6568
y=sc.midpoints(da.coords['y']) * sc.scalar(1.0, unit='m'),
6669
z=sc.scalar(0.0, unit='m'),
67-
)
70+
).transpose(da.dims)
6871
da.coords['position'] = (
6972
da.coords['detector_position'] + rotation_by_detector_rotation * position
7073
)
@@ -82,7 +85,7 @@ def load_mcstas_events(
8285
)
8386
da.coords["beam_size"] = sc.scalar(2.0, unit='mm')
8487

85-
da = da.fold('x', sizes={'blade': 14, 'wire': 32})
88+
da = da.fold('x', sizes={'blade': nblades, 'wire': nwires})
8689
da.bins.coords.pop('L')
8790
da.bins.coords.pop('t')
8891
return DetectorData[RunType](da)

tests/estia/mcstas_data_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def estia_mcstas_pipeline() -> sciline.Pipeline:
3737
wf[Filename[ReferenceRun]] = estia_mcstas_reference_run()
3838

3939
wf[YIndexLimits] = sc.scalar(35), sc.scalar(64)
40-
wf[ZIndexLimits] = sc.scalar(0), sc.scalar(14 * 32)
40+
wf[ZIndexLimits] = sc.scalar(0), sc.scalar(48 * 32)
4141
wf[BeamDivergenceLimits] = sc.scalar(-1.0, unit='deg'), sc.scalar(1.0, unit='deg')
4242
wf[WavelengthBins] = sc.geomspace('wavelength', 3.5, 12, 2001, unit='angstrom')
4343
wf[QBins] = sc.geomspace('Q', 0.005, 0.1, 200, unit='1/angstrom')
@@ -79,8 +79,8 @@ def estia_mcstas_pipeline() -> sciline.Pipeline:
7979
def test_mcstas_compute_reducible_data(estia_mcstas_pipeline: sciline.Pipeline):
8080
estia_mcstas_pipeline[Filename[SampleRun]] = estia_mcstas_sample_run(11)
8181
da = estia_mcstas_pipeline.compute(ReducibleData[SampleRun])
82-
assert da.dims == ('blade', 'wire', 'stripe')
83-
assert da.shape == (14, 32, 64)
82+
assert da.dims == ('stripe', 'blade', 'wire')
83+
assert da.shape == (64, 48, 32)
8484
assert 'position' in da.coords
8585
assert 'sample_rotation' in da.coords
8686
assert 'detector_rotation' in da.coords

0 commit comments

Comments
 (0)