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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ requires-python = ">=3.10"
dependencies = [
"sciline>=24.06.2",
"scipp>=25.01.0",
"scippneutron>=24.11.0",
"scippneutron>=25.02.0",
"scippnexus>=24.11.0",
]

Expand Down
2 changes: 1 addition & 1 deletion requirements/base.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
# The following was generated by 'tox -e deps', DO NOT EDIT MANUALLY!
sciline>=24.06.2
scipp>=25.01.0
scippneutron>=24.11.0
scippneutron>=25.02.0
scippnexus>=24.11.0
31 changes: 26 additions & 5 deletions requirements/base.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,34 @@
# SHA1:d18487328be0c30ec0a6929501d1c4a58c71bd48
# SHA1:0aac37186f254abb39dbd8f3c3c6ad52bafc0553
#
# This file is autogenerated by pip-compile-multi
# To update, run:
#
# pip-compile-multi
#
annotated-types==0.7.0
# via pydantic
contourpy==1.3.1
# via matplotlib
cyclebane==24.10.0
# via sciline
cycler==0.12.1
# via matplotlib
dnspython==2.7.0
# via email-validator
email-validator==2.2.0
# via scippneutron
fonttools==4.56.0
# via matplotlib
h5py==3.12.1
# via
# scippneutron
# scippnexus
idna==3.10
# via email-validator
kiwisolver==1.4.8
# via matplotlib
lazy-loader==0.4
# via scippneutron
matplotlib==3.10.0
# via
# mpltoolbox
Expand All @@ -27,7 +37,7 @@ mpltoolbox==24.5.1
# via scippneutron
networkx==3.4.2
# via cyclebane
numpy==2.2.2
numpy==2.2.3
# via
# contourpy
# h5py
Expand All @@ -37,16 +47,23 @@ numpy==2.2.2
# scippneutron
# scipy
packaging==24.2
# via matplotlib
# via
# lazy-loader
# matplotlib
pillow==11.1.0
# via matplotlib
plopp==24.10.0
# via scippneutron
pydantic==2.10.6
# via scippneutron
pydantic-core==2.27.2
# via pydantic
pyparsing==3.2.1
# via matplotlib
python-dateutil==2.9.0.post0
# via
# matplotlib
# scippneutron
# scippnexus
sciline==24.10.0
# via -r base.in
Expand All @@ -55,15 +72,19 @@ scipp==25.2.0
# -r base.in
# scippneutron
# scippnexus
scippneutron==25.1.0
scippneutron==25.2.0
# via -r base.in
scippnexus==24.11.1
# via
# -r base.in
# scippneutron
scipy==1.15.1
scipy==1.15.2
# via
# scippneutron
# scippnexus
six==1.17.0
# via python-dateutil
typing-extensions==4.12.2
# via
# pydantic
# pydantic-core
12 changes: 2 additions & 10 deletions requirements/basetest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ cycler==0.12.1
# via matplotlib
decorator==5.1.1
# via ipython
exceptiongroup==1.2.2
# via
# ipython
# pytest
executing==2.2.0
# via stack-data
fonttools==4.56.0
Expand All @@ -47,7 +43,7 @@ matplotlib==3.10.0
# via plopp
matplotlib-inline==0.1.7
# via ipython
numpy==2.2.2
numpy==2.2.3
# via
# contourpy
# matplotlib
Expand Down Expand Up @@ -90,7 +86,7 @@ requests==2.32.3
# via pooch
scipp==25.2.0
# via tof
scipy==1.15.1
scipy==1.15.2
# via
# -r basetest.in
# tof
Expand All @@ -100,16 +96,12 @@ stack-data==0.6.3
# via ipython
tof==25.2.0
# via -r basetest.in
tomli==2.2.1
# via pytest
traitlets==5.14.3
# via
# comm
# ipython
# ipywidgets
# matplotlib-inline
typing-extensions==4.12.2
# via ipython
urllib3==2.3.0
# via requests
wcwidth==0.2.13
Expand Down
6 changes: 0 additions & 6 deletions requirements/ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,8 @@ requests==2.32.3
# via -r ci.in
smmap==5.0.2
# via gitdb
tomli==2.2.1
# via
# pyproject-api
# tox
tox==4.24.1
# via -r ci.in
typing-extensions==4.12.2
# via tox
urllib3==2.3.0
# via requests
virtualenv==20.29.2
Expand Down
8 changes: 1 addition & 7 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
-r static.txt
-r test.txt
-r wheels.txt
annotated-types==0.7.0
# via pydantic
anyio==4.8.0
# via
# httpx
Expand All @@ -32,7 +30,7 @@ click==8.1.8
# via
# pip-compile-multi
# pip-tools
copier==9.4.1
copier==9.5.0
# via -r dev.in
dunamai==1.23.0
# via copier
Expand Down Expand Up @@ -91,10 +89,6 @@ prometheus-client==0.21.1
# via jupyter-server
pycparser==2.22
# via cffi
pydantic==2.10.6
# via copier
pydantic-core==2.27.2
# via pydantic
python-json-logger==3.2.1
# via jupyter-events
questionary==2.1.0
Expand Down
17 changes: 1 addition & 16 deletions requirements/docs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ accessible-pygments==0.0.5
# via pydata-sphinx-theme
alabaster==1.0.0
# via sphinx
appnope==0.1.4
# via ipykernel
asttokens==3.0.0
# via stack-data
attrs==25.1.0
Expand Down Expand Up @@ -48,16 +46,12 @@ docutils==0.21.2
# nbsphinx
# pydata-sphinx-theme
# sphinx
exceptiongroup==1.2.2
# via ipython
executing==2.2.0
# via stack-data
fastjsonschema==2.21.1
# via nbformat
graphviz==0.20.3
# via -r docs.in
idna==3.10
# via requests
imagesize==1.4.1
# via sphinx
importlib-resources==6.5.2
Expand Down Expand Up @@ -141,7 +135,7 @@ platformdirs==4.3.6
# via jupyter-core
prompt-toolkit==3.0.50
# via ipython
psutil==6.1.1
psutil==7.0.0
# via ipykernel
ptyprocess==0.7.0
# via pexpect
Expand Down Expand Up @@ -209,8 +203,6 @@ tinycss2==1.4.0
# via bleach
tof==25.2.0
# via -r docs.in
tomli==2.2.1
# via sphinx
tornado==6.4.2
# via
# ipykernel
Expand All @@ -228,13 +220,6 @@ traitlets==5.14.3
# nbconvert
# nbformat
# nbsphinx
typing-extensions==4.12.2
# via
# beautifulsoup4
# ipython
# mistune
# pydata-sphinx-theme
# referencing
urllib3==2.3.0
# via requests
wcwidth==0.2.13
Expand Down
11 changes: 2 additions & 9 deletions requirements/nightly.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ dnspython==2.7.0
# via email-validator
email-validator==2.2.0
# via scippneutron
exceptiongroup==1.2.2
# via
# ipython
# pytest
executing==2.2.0
# via stack-data
fonttools==4.56.0
Expand Down Expand Up @@ -74,7 +70,7 @@ mpltoolbox==24.5.1
# via scippneutron
networkx==3.4.2
# via cyclebane
numpy==2.2.2
numpy==2.2.3
# via
# contourpy
# h5py
Expand Down Expand Up @@ -142,7 +138,7 @@ scippnexus @ git+https://github.com/scipp/scippnexus@main
# via
# -r nightly.in
# scippneutron
scipy==1.15.1
scipy==1.15.2
# via
# -r nightly.in
# scippneutron
Expand All @@ -154,8 +150,6 @@ stack-data==0.6.3
# via ipython
tof @ git+https://github.com/scipp/tof@main
# via -r nightly.in
tomli==2.2.1
# via pytest
traitlets==5.14.3
# via
# comm
Expand All @@ -164,7 +158,6 @@ traitlets==5.14.3
# matplotlib-inline
typing-extensions==4.12.2
# via
# ipython
# pydantic
# pydantic-core
urllib3==2.3.0
Expand Down
2 changes: 0 additions & 2 deletions requirements/wheels.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,3 @@ packaging==24.2
# via build
pyproject-hooks==1.2.0
# via build
tomli==2.2.1
# via build
18 changes: 17 additions & 1 deletion src/ess/reduce/nexus/_nexus_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@
from contextlib import AbstractContextManager, contextmanager, nullcontext
from dataclasses import dataclass
from math import prod
from typing import cast
from typing import TypeVar, cast

import scipp as sc
import scippnexus as snx

from ..logging import get_logger
from .types import (
Beamline,
FilePath,
Measurement,
NeXusAllLocationSpec,
NeXusEntryName,
NeXusFile,
Expand All @@ -27,6 +29,8 @@
class NoNewDefinitionsType: ...


_Model = TypeVar('_Model', Beamline, Measurement)

NoNewDefinitions = NoNewDefinitionsType()


Expand Down Expand Up @@ -74,6 +78,18 @@ def load_all_components(
return components


def load_metadata(
file_path: FilePath | NeXusFile | NeXusGroup,
model: type[_Model],
*,
entry_name: NeXusEntryName | None = None,
definitions: Mapping | NoNewDefinitionsType = NoNewDefinitions,
) -> _Model:
with _open_nexus_file(file_path, definitions=definitions) as f:
entry = _unique_child_group(f, snx.NXentry, entry_name)
return model.from_nexus_entry(entry)


def compute_component_position(dg: sc.DataGroup) -> sc.DataGroup:
# In some downstream packages we use some of the Nexus components which attempt
# to compute positions without having actual Nexus data defining depends_on chains.
Expand Down
8 changes: 8 additions & 0 deletions src/ess/reduce/nexus/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import sciline
import scipp as sc
import scippnexus as snx
from scippneutron import metadata as scn_meta

FilePath = NewType('FilePath', Path)
"""Full path to a NeXus file on disk."""
Expand Down Expand Up @@ -177,6 +178,13 @@ class TransmissionRun(Generic[ScatteringRunType]):
UniqueComponent = TypeVar('UniqueComponent', snx.NXsample, snx.NXsource)
"""Components that can be identified by their type as there will only be one."""

Beamline = scn_meta.Beamline
"""Beamline metadata."""
Measurement = scn_meta.Measurement
"""measurement metadata."""
Source = scn_meta.Source
"""Neutron source metadata."""


class NeXusName(sciline.Scope[Component, str], str):
"""Name of a component in a NeXus file."""
Expand Down
Loading