Skip to content

Commit

Permalink
Merge pull request #50 from scipp/new-sciline-release
Browse files Browse the repository at this point in the history
Compatibility with new sciline
  • Loading branch information
jokasimr authored Jun 18, 2024
2 parents 449ed90 + 657957c commit acf1cba
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 50 deletions.
26 changes: 14 additions & 12 deletions docs/user-guide/amor/amor-reduction.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -147,19 +147,20 @@
"metadata": {},
"outputs": [],
"source": [
"workflow[Filename[SampleRun]] = amor.data.amor_sample_run(608)\n",
"workflow[SampleRotation[SampleRun]] = sc.scalar(0.85, unit='deg')\n",
"ioq8 = workflow.compute(NormalizedIofQ).hist()\n",
"\n",
"workflow[Filename[SampleRun]] = amor.data.amor_sample_run(609)\n",
"workflow[SampleRotation[SampleRun]] = sc.scalar(2.25, unit='deg')\n",
"ioq9 = workflow.compute(NormalizedIofQ).hist()\n",
"runs = {\n",
" '608': sc.scalar(0.85, unit='deg'),\n",
" '609': sc.scalar(2.25, unit='deg'),\n",
" '610': sc.scalar(3.65, unit='deg'),\n",
" '611': sc.scalar(5.05, unit='deg'),\n",
"}\n",
"\n",
"workflow[Filename[SampleRun]] = amor.data.amor_sample_run(610)\n",
"workflow[SampleRotation[SampleRun]] = sc.scalar(3.65, unit='deg')\n",
"ioq10 = workflow.compute(NormalizedIofQ).hist()\n",
"results = {}\n",
"for file, angle in runs.items():\n",
" workflow[Filename[SampleRun]] = amor.data.amor_sample_run(file)\n",
" workflow[SampleRotation[SampleRun]] = angle\n",
" results[file] = workflow.compute(NormalizedIofQ).hist()\n",
"\n",
"sc.plot({'608': ioq8, '609': ioq9, '610': ioq10}, norm='log', vmin=1e-4)"
"sc.plot(results, norm='log', vmin=1e-4)"
]
},
{
Expand Down Expand Up @@ -353,7 +354,8 @@
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3"
"pygments_lexer": "ipython3",
"version": "3.10.13"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ dependencies = [
"plopp",
"pythreejs",
"orsopy",
"sciline>=23.9.1",
"sciline>=24.6.0",
"scipp>=23.8.0",
"scippneutron>=23.9.0",
"essreduce",
Expand Down
2 changes: 1 addition & 1 deletion requirements/base.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ graphviz
plopp
pythreejs
orsopy
sciline>=23.9.1
sciline>=24.6.0
scipp>=23.8.0
scippneutron>=23.9.0
essreduce
18 changes: 11 additions & 7 deletions requirements/base.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SHA1:1b431955cc8f1e9144b3b02f13d86b0693935140
# SHA1:e11d135cfcc0ae8694f1a9061a0aaea415f470f2
#
# This file is autogenerated by pip-compile-multi
# To update, run:
Expand All @@ -19,9 +19,11 @@ comm==0.2.2
# via ipywidgets
contourpy==1.2.1
# via matplotlib
cyclebane==24.6.0
# via sciline
cycler==0.12.1
# via matplotlib
dask==2024.5.2
dask==2024.6.0
# via -r base.in
decorator==5.1.1
# via ipython
Expand Down Expand Up @@ -65,7 +67,9 @@ matplotlib==3.9.0
# via plopp
matplotlib-inline==0.1.7
# via ipython
numpy==1.26.4
networkx==3.3
# via cyclebane
numpy==2.0.0
# via
# contourpy
# h5py
Expand All @@ -92,7 +96,7 @@ pillow==10.3.0
# via matplotlib
platformdirs==4.2.2
# via pooch
plopp==24.5.0
plopp==24.6.0
# via
# -r base.in
# scippneutron
Expand Down Expand Up @@ -121,7 +125,7 @@ pyyaml==6.0.1
# orsopy
requests==2.32.3
# via pooch
sciline==24.4.1
sciline==24.6.0
# via -r base.in
scipp==24.5.1
# via
Expand All @@ -131,7 +135,7 @@ scipp==24.5.1
# scippnexus
scippneutron==24.5.0
# via -r base.in
scippnexus==24.3.1
scippnexus==24.6.0
# via
# essreduce
# scippneutron
Expand Down Expand Up @@ -161,7 +165,7 @@ traittypes==0.2.1
# via ipydatawidgets
typing-extensions==4.12.2
# via ipython
urllib3==2.2.1
urllib3==2.2.2
# via requests
wcwidth==0.2.13
# via prompt-toolkit
Expand Down
4 changes: 2 additions & 2 deletions requirements/ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ colorama==0.4.6
# via tox
distlib==0.3.8
# via virtualenv
filelock==3.14.0
filelock==3.15.1
# via
# tox
# virtualenv
Expand Down Expand Up @@ -50,7 +50,7 @@ tomli==2.0.1
# tox
tox==4.15.1
# via -r ci.in
urllib3==2.2.1
urllib3==2.2.2
# via requests
virtualenv==20.26.2
# via tox
4 changes: 2 additions & 2 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jinja2-ansible-filters==1.3.2
# via copier
json5==0.9.25
# via jupyterlab-server
jsonpointer==2.4
jsonpointer==3.0.0
# via jsonschema
jsonschema[format-nongpl]==4.22.0
# via
Expand Down Expand Up @@ -87,7 +87,7 @@ prometheus-client==0.20.0
# via jupyter-server
pycparser==2.22
# via cffi
pydantic==2.7.3
pydantic==2.7.4
# via copier
pydantic-core==2.18.4
# via pydantic
Expand Down
2 changes: 1 addition & 1 deletion requirements/docs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ docutils==0.21.2
# nbsphinx
# pydata-sphinx-theme
# sphinx
fastjsonschema==2.19.1
fastjsonschema==2.20.0
# via nbformat
imagesize==1.4.1
# via sphinx
Expand Down
13 changes: 9 additions & 4 deletions requirements/nightly.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ cyclebane==24.6.0
# via sciline
cycler==0.12.1
# via matplotlib
dask==2024.5.2
dask==2024.6.0
# via -r nightly.in
decorator==5.1.1
# via ipython
Expand Down Expand Up @@ -63,17 +63,22 @@ kiwisolver==1.4.5
locket==1.0.0
# via partd
matplotlib==3.9.0
# via plopp
# via
# mpltoolbox
# plopp
matplotlib-inline==0.1.7
# via ipython
mpltoolbox==24.5.1
# via scippneutron
networkx==3.3
# via cyclebane
numpy==1.26.4
numpy==2.0.0
# via
# contourpy
# h5py
# ipydatawidgets
# matplotlib
# mpltoolbox
# pythreejs
# scipp
# scippneutron
Expand Down Expand Up @@ -160,7 +165,7 @@ traittypes==0.2.1
# via ipydatawidgets
typing-extensions==4.12.2
# via ipython
urllib3==2.2.1
urllib3==2.2.2
# via requests
wcwidth==0.2.13
# via prompt-toolkit
Expand Down
2 changes: 1 addition & 1 deletion requirements/static.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ cfgv==3.4.0
# via pre-commit
distlib==0.3.8
# via virtualenv
filelock==3.14.0
filelock==3.15.1
# via virtualenv
identify==2.5.36
# via pre-commit
Expand Down
16 changes: 8 additions & 8 deletions src/ess/reflectometry/orso.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import os
import platform
from datetime import datetime, timezone
from typing import Any, NewType, Optional
from typing import Any, NewType

from dateutil.parser import parse as parse_datetime
from orsopy.fileio import base as orso_base
Expand Down Expand Up @@ -109,8 +109,8 @@ def parse_orso_sample(filename: Filename[SampleRun]) -> OrsoSample:

def build_orso_measurement(
sample_filename: Filename[SampleRun],
reference_filename: Optional[Filename[ReferenceRun]],
instrument: Optional[OrsoInstrument],
reference_filename: Filename[ReferenceRun],
instrument: OrsoInstrument,
) -> OrsoMeasurement:
"""Assemble ORSO measurement metadata."""
# TODO populate timestamp
Expand All @@ -133,7 +133,7 @@ def build_orso_measurement(
)


def build_orso_reduction(creator: Optional[OrsoCreator]) -> OrsoReduction:
def build_orso_reduction(creator: OrsoCreator) -> OrsoReduction:
"""Construct ORSO reduction metadata.
This assumes that ess.reflectometry is the primary piece of software
Expand All @@ -157,10 +157,10 @@ def build_orso_reduction(creator: Optional[OrsoCreator]) -> OrsoReduction:


def build_orso_data_source(
owner: Optional[OrsoOwner],
sample: Optional[OrsoSample],
experiment: Optional[OrsoExperiment],
measurement: Optional[OrsoMeasurement],
owner: OrsoOwner,
sample: OrsoSample,
experiment: OrsoExperiment,
measurement: OrsoMeasurement,
) -> OrsoDataSource:
"""Assemble an ORSO DataSource."""
return OrsoDataSource(
Expand Down
18 changes: 7 additions & 11 deletions tests/orso_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@

from ess import amor, reflectometry
from ess.reflectometry import orso
from ess.reflectometry.types import Filename, SampleRun
from ess.reflectometry.types import Filename, ReferenceRun, SampleRun


def test_build_orso_data_source():
pipeline = sciline.Pipeline(
(*amor.load.providers, *orso.providers),
params={Filename[SampleRun]: amor.data.amor_old_sample_run()},
params={
Filename[SampleRun]: amor.data.amor_old_sample_run(),
Filename[ReferenceRun]: amor.data.amor_old_reference_run(),
},
)
pipeline[orso.OrsoInstrument] = None
data_source = pipeline.compute(orso.OrsoDataSource)
expected = fileio.data_source.DataSource(
owner=fileio.base.Person(
Expand All @@ -31,21 +35,13 @@ def test_build_orso_data_source():
measurement=fileio.data_source.Measurement(
data_files=[fileio.base.File(file="sample.nxs")],
# We would need the full pipeline to determine this:
additional_files=[],
additional_files=[fileio.File("reference.nxs", comment="supermirror")],
instrument_settings=None,
),
)
assert data_source == expected


def test_build_orso_reduction_without_creator():
pipeline = sciline.Pipeline(orso.providers)
reduction = pipeline.compute(orso.OrsoReduction)
assert reduction.software.name == "ess.reflectometry"
assert reduction.software.version == str(reflectometry.__version__)
assert reduction.creator is None


def test_build_orso_reduction_with_creator():
creator = fileio.base.Person(
name="Erika Mustermann", affiliation="ESS", contact="[email protected]"
Expand Down

0 comments on commit acf1cba

Please sign in to comment.