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
11 changes: 10 additions & 1 deletion packages/essdiffraction/src/ess/beer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

import importlib.metadata

import lazy_loader as lazy

from .mcstas import load_beer_mcstas
from .peakfinding import dhkl_peaks_from_cif
from .workflow import (
Expand All @@ -26,7 +28,14 @@
except importlib.metadata.PackageNotFoundError:
__version__ = "0.0.0"

del importlib
# The diagnostics subpackage needs ipywidgets, which is optional. Import it only on
# first access so that the workflows can be used without ipywidgets.
__getattr__, _, _ = lazy.attach(
__name__,
submodules=['diagnostics'],
)

del _, importlib, lazy

__all__ = [
'BeerMcStasWorkflowPulseShaping',
Expand Down
10 changes: 10 additions & 0 deletions packages/essdiffraction/src/ess/beer/diagnostics/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2026 Scipp contributors (https://github.com/scipp)
"""Instrument diagnostics for BEER."""

from .load_nexus import load_detectors, load_monitors

__all__ = [
'load_detectors',
'load_monitors',
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2026 Scipp contributors (https://github.com/scipp)

from ess.reduce.diagnostics import load_nexus

load_detectors = load_nexus.load_detectors
load_monitors = load_nexus.load_monitors
10 changes: 10 additions & 0 deletions packages/essspectroscopy/src/ess/bifrost/diagnostics/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2026 Scipp contributors (https://github.com/scipp)
"""Instrument diagnostics for BIFROST."""

from .load_nexus import load_detectors, load_monitors

__all__ = [
'load_detectors',
'load_monitors',
]
31 changes: 31 additions & 0 deletions packages/essspectroscopy/src/ess/bifrost/diagnostics/load_nexus.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2026 Scipp contributors (https://github.com/scipp)

from pathlib import Path
from typing import Any

import scipp as sc

from ess.reduce.diagnostics import load_nexus

load_monitors = load_nexus.load_monitors


def load_detectors(
filename: str | Path,
*,
detectors: list[str] | str | None = None,
) -> sc.DataGroup[Any]:
"""Load detector data from a NeXus file.

See :func:`ess.reduce.diagnostics.load_nexus.load_detectors`.
"""
detectors = load_nexus.load_detectors(filename, detectors=detectors)
return detectors.apply(_rename_detector_dims)


def _rename_detector_dims(da: sc.DataArray) -> sc.DataArray:
for old, new in (('dim_0', 'tube'), ('dim_1', 'length')):
if old in da.dims:
da = da.rename({old: new})
return da
Loading