Skip to content

Commit ed48e6d

Browse files
committed
fix: shape and size of the estia detector
1 parent e191524 commit ed48e6d

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
@@ -37,11 +37,14 @@ def load_mcstas_events(
3737
unit=da.coords['sample_rotation'].unit
3838
)
3939

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

4649
# Information is not available in the mcstas output files, therefore it's hardcoded
4750
da.coords['sample_position'] = sc.vector([0.264298, -0.427595, 35.0512], unit='m')
@@ -63,7 +66,7 @@ def load_mcstas_events(
6366
x=sc.midpoints(da.coords['x']) * sc.scalar(1.0, unit='m'),
6467
y=sc.midpoints(da.coords['y']) * sc.scalar(1.0, unit='m'),
6568
z=sc.scalar(0.0, unit='m'),
66-
)
69+
).transpose(da.dims)
6770
da.coords['position'] = (
6871
da.coords['detector_position'] + rotation_by_detector_rotation * position
6972
)
@@ -81,7 +84,7 @@ def load_mcstas_events(
8184
)
8285
da.coords["beam_size"] = sc.scalar(2.0, unit='mm')
8386

84-
da = da.fold('x', sizes={'blade': 14, 'wire': 32})
87+
da = da.fold('x', sizes={'blade': nblades, 'wire': nwires})
8588
da.bins.coords.pop('L')
8689
da.bins.coords.pop('t')
8790
return RawDetectorData[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)