Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions packages/essspectroscopy/src/ess/bifrost/detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from ess.spectroscopy.indirect.conversion import add_spectrometer_coords
from ess.spectroscopy.types import (
Analyzer,
DetectorPositionOffset,
EmptyDetector,
NeXusComponent,
NeXusTransformation,
Expand Down Expand Up @@ -86,7 +85,6 @@ def get_calibrated_detector_bifrost(
analyzer: Analyzer[RunType],
*,
transform: NeXusTransformation[snx.NXdetector, RunType],
offset: DetectorPositionOffset[RunType],
primary_graph: PrimarySpecCoordTransformGraph[RunType],
secondary_graph: SecondarySpecCoordTransformGraph[RunType],
) -> EmptyDetector[RunType]:
Expand All @@ -107,8 +105,6 @@ def get_calibrated_detector_bifrost(
Loaded analyzer parameters.
transform:
Transformation that determines the detector position.
offset:
Offset to add to the detector position.
primary_graph:
Coordinate transformation graph for the primary spectrometer.
secondary_graph:
Expand All @@ -122,9 +118,7 @@ def get_calibrated_detector_bifrost(
Detector geometry and spectrometer coordinates.
"""

da = get_base_calibrated_detector_bifrost(
detector, analyzer, transform=transform, offset=offset
)
da = get_base_calibrated_detector_bifrost(detector, analyzer, transform=transform)
da = da.rename(dim_0='tube', dim_1='length')

arc, channel = arc_and_channel_from_detector_number(da.coords['detector_number'])
Expand All @@ -147,7 +141,6 @@ def get_base_calibrated_detector_bifrost(
analyzer: Analyzer[RunType],
*,
transform: NeXusTransformation[snx.NXdetector, RunType],
offset: DetectorPositionOffset[RunType],
) -> sc.DataArray:
"""Extract the data array corresponding to a detector's signal field.

Expand All @@ -163,8 +156,6 @@ def get_base_calibrated_detector_bifrost(
Loaded analyzer parameters.
transform:
Transformation that determines the detector position.
offset:
Offset to add to the detector position.

Returns
-------
Expand All @@ -173,9 +164,14 @@ def get_base_calibrated_detector_bifrost(
"""

from ess.reduce.nexus import compute_detector_position, extract_signal_data_array
from ess.reduce.nexus.workflow import no_offset

da = extract_signal_data_array(detector)
position = compute_detector_position(da, transform=transform, offset=offset)
# BIFROST's detectors ride the rotating tank, so a lab-frame offset added after
# the transform cannot express any correction one would actually want; the
# transformation chain is the handle. compute_detector_position requires the
# argument, so pin it to zero here.
position = compute_detector_position(da, transform=transform, offset=no_offset)
return _assign_detector_position(da, position)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import scippnexus as snx
from ess.spectroscopy.types import (
Analyzer,
DetectorPositionOffset,
ElasticMonitor,
EmptyDetector,
NeXusComponent,
Expand All @@ -17,16 +16,13 @@
RunType,
)

from ess.reduce.nexus.types import MonitorPositionOffset

from ..detector import _assign_detector_position, get_base_calibrated_detector_bifrost


def get_calibrated_bragg_peak_monitor(
monitor: NeXusComponent[ElasticMonitor, RunType],
*,
transform: NeXusTransformation[ElasticMonitor, RunType],
offset: MonitorPositionOffset[RunType, ElasticMonitor],
) -> EmptyDetector[RunType]:
"""Extract the data array corresponding to the Bragg peak monitor's signal field.

Expand All @@ -43,8 +39,6 @@ def get_calibrated_bragg_peak_monitor(
Loaded NeXus monitor.
transform:
Transformation that determines the monitor position.
offset:
Offset to add to the monitor position.

Returns
-------
Expand All @@ -55,9 +49,7 @@ def get_calibrated_bragg_peak_monitor(

da = extract_signal_data_array(monitor)
unit = transform.value.unit
position = transform.value * sc.vector([0.0, 0.0, 0.0], unit=unit) + offset.to(
unit=unit
)
position = transform.value * sc.vector([0.0, 0.0, 0.0], unit=unit)
return EmptyDetector[RunType](_assign_detector_position(da, position))


Expand Down Expand Up @@ -96,7 +88,6 @@ def get_calibrated_bragg_peak_detector(
analyzer: Analyzer[RunType],
*,
transform: NeXusTransformation[snx.NXdetector, RunType],
offset: DetectorPositionOffset[RunType],
) -> EmptyDetector[RunType]:
"""Extract the data array corresponding to a detector's signal field.

Expand All @@ -112,17 +103,13 @@ def get_calibrated_bragg_peak_detector(
Loaded analyzer parameters.
transform:
Transformation that determines the detector position.
offset:
Offset to add to the detector position.

Returns
-------
:
Detector with geometry coordinates.
"""
return get_base_calibrated_detector_bifrost(
detector, analyzer, transform=transform, offset=offset
)
return get_base_calibrated_detector_bifrost(detector, analyzer, transform=transform)


providers = (get_calibrated_bragg_peak_monitor, assemble_bragg_peak_monitor_data)
Expand Down
Loading