Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ScippNeutron's metadata utilities #124

Merged
merged 7 commits into from
Feb 18, 2025
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
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ requires-python = ">=3.10"
# Make sure to list one dependency per line.
dependencies = [
"dask",
"essreduce>=24.12.0",
"essreduce>=25.02.4",
"graphviz",
"numpy",
"plopp",
"pythreejs",
"sciline>=24.06.0",
"scipp>=24.09.1",
"scippneutron>=24.11.0",
"scippneutron>=25.02.0",
"scippnexus>=23.12.0",
]

Expand Down
4 changes: 2 additions & 2 deletions requirements/base.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
# --- END OF CUSTOM SECTION ---
# The following was generated by 'tox -e deps', DO NOT EDIT MANUALLY!
dask
essreduce>=24.12.0
essreduce>=25.02.4
graphviz
numpy
plopp
pythreejs
sciline>=24.06.0
scipp>=24.09.1
scippneutron>=24.11.0
scippneutron>=25.02.0
scippnexus>=23.12.0
38 changes: 25 additions & 13 deletions requirements/base.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# SHA1:1c545a5dfb8b66d23509534f3ddf41f94ead839c
# SHA1:4b779f60b811ecde0982bc9dc5df5ed5b296b876
#
# This file is autogenerated by pip-compile-multi
# To update, run:
#
# pip-compile-multi
#
annotated-types==0.7.0
# via pydantic
asttokens==3.0.0
# via stack-data
click==8.1.8
Expand All @@ -19,14 +21,16 @@ cyclebane==24.10.0
# via sciline
cycler==0.12.1
# via matplotlib
dask==2025.1.0
dask==2025.2.0
# via -r base.in
decorator==5.1.1
# via ipython
essreduce==25.2.0
dnspython==2.7.0
# via email-validator
email-validator==2.2.0
# via scippneutron
essreduce==25.2.4
# via -r base.in
exceptiongroup==1.2.2
# via ipython
executing==2.2.0
# via stack-data
fonttools==4.56.0
Expand All @@ -39,8 +43,8 @@ h5py==3.12.1
# via
# scippneutron
# scippnexus
importlib-metadata==8.6.1
# via dask
idna==3.10
# via email-validator
ipydatawidgets==4.3.5
# via pythreejs
ipython==8.32.0
Expand All @@ -55,6 +59,8 @@ jupyterlab-widgets==3.0.13
# via ipywidgets
kiwisolver==1.4.8
# via matplotlib
lazy-loader==0.4
# via scippneutron
locket==1.0.0
# via partd
matplotlib==3.10.0
Expand All @@ -67,7 +73,7 @@ mpltoolbox==24.5.1
# via scippneutron
networkx==3.4.2
# via cyclebane
numpy==2.2.2
numpy==2.2.3
# via
# -r base.in
# contourpy
Expand All @@ -82,6 +88,7 @@ numpy==2.2.2
packaging==24.2
# via
# dask
# lazy-loader
# matplotlib
parso==0.8.4
# via jedi
Expand All @@ -101,13 +108,18 @@ ptyprocess==0.7.0
# via pexpect
pure-eval==0.2.3
# via stack-data
pydantic==2.10.6
# via scippneutron
pydantic-core==2.27.2
# via pydantic
pygments==2.19.1
# via ipython
pyparsing==3.2.1
# via matplotlib
python-dateutil==2.9.0.post0
# via
# matplotlib
# scippneutron
# scippnexus
pythreejs==2.4.2
# via -r base.in
Expand All @@ -123,7 +135,7 @@ scipp==25.2.0
# essreduce
# scippneutron
# scippnexus
scippneutron==25.1.0
scippneutron==25.2.0
# via
# -r base.in
# essreduce
Expand All @@ -132,7 +144,7 @@ scippnexus==24.11.1
# -r base.in
# essreduce
# scippneutron
scipy==1.15.1
scipy==1.15.2
# via
# scippneutron
# scippnexus
Expand All @@ -155,10 +167,10 @@ traitlets==5.14.3
traittypes==0.2.1
# via ipydatawidgets
typing-extensions==4.12.2
# via ipython
# via
# pydantic
# pydantic-core
wcwidth==0.2.13
# via prompt-toolkit
widgetsnbextension==4.0.13
# via ipywidgets
zipp==3.21.0
# via importlib-metadata
6 changes: 1 addition & 5 deletions requirements/basetest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ certifi==2025.1.31
# via requests
charset-normalizer==3.4.1
# via requests
exceptiongroup==1.2.2
# via pytest
idna==3.10
# via requests
iniconfig==2.0.0
# via pytest
numpy==2.2.2
numpy==2.2.3
# via pandas
packaging==24.2
# via
Expand All @@ -39,8 +37,6 @@ requests==2.32.3
# via pooch
six==1.17.0
# via python-dateutil
tomli==2.2.1
# via pytest
tzdata==2025.1
# via pandas
urllib3==2.3.0
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 @@ -28,7 +26,7 @@ async-lru==2.0.4
# via jupyterlab
cffi==1.17.1
# via argon2-cffi-bindings
copier==9.4.1
copier==9.5.0
# via -r dev.in
dunamai==1.23.0
# via copier
Expand Down Expand Up @@ -87,10 +85,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
11 changes: 4 additions & 7 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
attrs==25.1.0
# via
# jsonschema
Expand Down Expand Up @@ -44,8 +42,6 @@ docutils==0.21.2
# sphinxcontrib-bibtex
fastjsonschema==2.21.1
# via nbformat
idna==3.10
# via requests
imagesize==1.4.1
# via sphinx
ipykernel==6.29.5
Expand Down Expand Up @@ -116,7 +112,7 @@ platformdirs==4.3.6
# pooch
pooch==1.8.2
# via -r docs.in
psutil==6.1.1
psutil==7.0.0
# via ipykernel
pyarrow==19.0.0
# via -r docs.in
Expand Down Expand Up @@ -182,8 +178,6 @@ sphinxcontrib-serializinghtml==2.0.0
# via sphinx
tinycss2==1.4.0
# via bleach
tomli==2.2.1
# via sphinx
tornado==6.4.2
# via
# ipykernel
Expand All @@ -196,3 +190,6 @@ webencodings==0.5.1
# via
# bleach
# tinycss2

# The following packages are considered to be unsafe in a requirements file:
# setuptools
17 changes: 3 additions & 14 deletions requirements/nightly.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ cyclebane==24.10.0
# via sciline
cycler==0.12.1
# via matplotlib
dask==2025.1.0
dask==2025.2.0
# via -r nightly.in
decorator==5.1.1
# via ipython
Expand All @@ -38,10 +38,6 @@ email-validator==2.2.0
# via scippneutron
essreduce @ git+https://github.com/scipp/essreduce@main
# via -r nightly.in
exceptiongroup==1.2.2
# via
# ipython
# pytest
executing==2.2.0
# via stack-data
fonttools==4.56.0
Expand All @@ -58,8 +54,6 @@ idna==3.10
# via
# email-validator
# requests
importlib-metadata==8.6.1
# via dask
iniconfig==2.0.0
# via pytest
ipydatawidgets==4.3.5
Expand Down Expand Up @@ -92,7 +86,7 @@ mpltoolbox==24.5.1
# via scippneutron
networkx==3.4.2
# via cyclebane
numpy==2.2.2
numpy==2.2.3
# via
# -r nightly.in
# contourpy
Expand Down Expand Up @@ -181,16 +175,14 @@ scippnexus @ git+https://github.com/scipp/scippnexus@main
# -r nightly.in
# essreduce
# scippneutron
scipy==1.15.1
scipy==1.15.2
# via
# scippneutron
# scippnexus
six==1.17.0
# via python-dateutil
stack-data==0.6.3
# via ipython
tomli==2.2.1
# via pytest
toolz==1.0.0
# via
# dask
Expand All @@ -207,7 +199,6 @@ traittypes==0.2.1
# via ipydatawidgets
typing-extensions==4.12.2
# via
# ipython
# pydantic
# pydantic-core
tzdata==2025.1
Expand All @@ -218,5 +209,3 @@ wcwidth==0.2.13
# via prompt-toolkit
widgetsnbextension==4.0.13
# via ipywidgets
zipp==3.21.0
# via importlib-metadata
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
29 changes: 23 additions & 6 deletions src/ess/dream/io/cif.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,24 @@
from scippneutron.io import cif

from ess.powder.calibration import OutputCalibrationData
from ess.powder.types import CIFAuthors, IofTof, ReducedTofCIF
from ess.powder.types import (
Beamline,
CIFAuthors,
IofTof,
ReducedTofCIF,
ReducerSoftwares,
Source,
)


def prepare_reduced_tof_cif(
da: IofTof, *, authors: CIFAuthors, calibration: OutputCalibrationData
da: IofTof,
*,
authors: CIFAuthors,
beamline: Beamline,
source: Source,
reducers: ReducerSoftwares,
calibration: OutputCalibrationData,
) -> ReducedTofCIF:
"""Construct a CIF builder with reduced data in d-spacing.

Expand All @@ -24,6 +37,12 @@ def prepare_reduced_tof_cif(
Reduced 1d data with a ``'tof'`` dimension and coordinate.
authors:
List of authors to write to the file.
beamline:
Information about the beamline that the data was produced at.
source:
Information about the neutron source.
reducers:
List of software pieces used to reduce the data.
calibration:
Coefficients for conversion between d-spacing and final ToF.
See :meth:`scippneutron.io.cif.CIF.with_powder_calibration`.
Expand All @@ -34,14 +53,12 @@ def prepare_reduced_tof_cif(
An object that contains the reduced data and metadata.
Us its ``save`` method to write the CIF file.
"""
from .. import __version__

to_save = _prepare_data(da)
return ReducedTofCIF(
cif.CIF('reduced_tof')
.with_reducers(f'ess.dream v{__version__}')
.with_reducers(*(reducer.compact_repr for reducer in reducers))
.with_authors(*authors)
.with_beamline(beamline='DREAM', facility='ESS')
.with_beamline(beamline, source)
.with_powder_calibration(calibration.to_cif_format())
.with_reduced_powder_data(to_save)
)
Expand Down
Loading