Skip to content

Commit

Permalink
Merge pull request #77 from scipp/use-new-hist-bin
Browse files Browse the repository at this point in the history
Use new `scipp.bin` dim argument to avoid workaroundsUse new hist bin
  • Loading branch information
SimonHeybrock committed Sep 4, 2024
2 parents f18c3c6 + f037eba commit bf074db
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 49 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ dependencies = [
"pythreejs",
"orsopy",
"sciline>=24.6.0",
"scipp>=23.8.0",
"scipp>=24.09.1", # Fixed new hist/bin API
"scippneutron>=24.7.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 @@ -9,6 +9,6 @@ plopp
pythreejs
orsopy
sciline>=24.6.0
scipp>=23.8.0
scipp>=24.09.1
scippneutron>=24.7.0
essreduce
40 changes: 25 additions & 15 deletions requirements/base.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SHA1:03305bbd69a8ade40d4806be66defcfa33bb2197
# SHA1:c59f85e6dbc38ae7eeef3ce1e4f681c07f43ff24
#
# This file is autogenerated by pip-compile-multi
# To update, run:
Expand All @@ -13,19 +13,21 @@ cloudpickle==3.0.0
# via dask
comm==0.2.2
# via ipywidgets
contourpy==1.2.1
contourpy==1.3.0
# via matplotlib
cyclebane==24.6.0
# via sciline
cycler==0.12.1
# via matplotlib
dask==2024.8.0
dask==2024.8.2
# via -r base.in
decorator==5.1.1
# via ipython
essreduce==24.8.0
essreduce==24.9.0
# via -r base.in
executing==2.0.1
exceptiongroup==1.2.2
# via ipython
executing==2.1.0
# via stack-data
fonttools==4.53.1
# via matplotlib
Expand All @@ -37,19 +39,21 @@ h5py==3.11.0
# via
# scippneutron
# scippnexus
importlib-metadata==8.4.0
# via dask
ipydatawidgets==4.3.5
# via pythreejs
ipython==8.26.0
ipython==8.27.0
# via ipywidgets
ipywidgets==8.1.3
ipywidgets==8.1.5
# via
# ipydatawidgets
# pythreejs
jedi==0.19.1
# via ipython
jupyterlab-widgets==3.0.11
jupyterlab-widgets==3.0.13
# via ipywidgets
kiwisolver==1.4.5
kiwisolver==1.4.6
# via matplotlib
locket==1.0.0
# via partd
Expand All @@ -63,7 +67,7 @@ mpltoolbox==24.5.1
# via scippneutron
networkx==3.3
# via cyclebane
numpy==2.0.1
numpy==2.1.1
# via
# contourpy
# h5py
Expand Down Expand Up @@ -100,7 +104,7 @@ pure-eval==0.2.3
# via stack-data
pygments==2.18.0
# via ipython
pyparsing==3.1.2
pyparsing==3.1.4
# via matplotlib
python-dateutil==2.9.0.post0
# via
Expand All @@ -113,8 +117,10 @@ pyyaml==6.0.2
# via
# dask
# orsopy
sciline==24.6.2
# via -r base.in
sciline==24.6.3
# via
# -r base.in
# essreduce
scipp==24.9.1
# via
# -r base.in
Expand All @@ -127,7 +133,7 @@ scippnexus==24.8.1
# via
# essreduce
# scippneutron
scipy==1.14.0
scipy==1.14.1
# via
# scippneutron
# scippnexus
Expand All @@ -151,7 +157,11 @@ traitlets==5.14.3
# traittypes
traittypes==0.2.1
# via ipydatawidgets
typing-extensions==4.12.2
# via ipython
wcwidth==0.2.13
# via prompt-toolkit
widgetsnbextension==4.0.11
widgetsnbextension==4.0.13
# via ipywidgets
zipp==3.20.1
# via importlib-metadata
4 changes: 2 additions & 2 deletions requirements/basetest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
#
# pip-compile-multi
#
certifi==2024.7.4
certifi==2024.8.30
# via requests
charset-normalizer==3.3.2
# via requests
exceptiongroup==1.2.2
# via pytest
idna==3.7
idna==3.8
# via requests
iniconfig==2.0.0
# via pytest
Expand Down
6 changes: 3 additions & 3 deletions requirements/ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
#
# pip-compile-multi
#
cachetools==5.4.0
cachetools==5.5.0
# via tox
certifi==2024.7.4
certifi==2024.8.30
# via requests
chardet==5.2.0
# via tox
Expand All @@ -25,7 +25,7 @@ gitdb==4.0.11
# via gitpython
gitpython==3.1.43
# via -r ci.in
idna==3.7
idna==3.8
# via requests
packaging==24.1
# via
Expand Down
6 changes: 3 additions & 3 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ h11==0.14.0
# via httpcore
httpcore==1.0.5
# via httpx
httpx==0.27.0
httpx==0.27.2
# via jupyterlab
isoduration==20.11.0
# via jsonschema
Expand All @@ -67,7 +67,7 @@ jupyter-server==2.14.2
# notebook-shim
jupyter-server-terminals==0.5.3
# via jupyter-server
jupyterlab==4.2.4
jupyterlab==4.2.5
# via -r dev.in
jupyterlab-server==2.27.3
# via jupyterlab
Expand Down Expand Up @@ -115,7 +115,7 @@ terminado==0.18.1
# jupyter-server-terminals
toposort==1.10
# via pip-compile-multi
types-python-dateutil==2.9.0.20240316
types-python-dateutil==2.9.0.20240821
# via arrow
uri-template==1.3.0
# via jsonschema
Expand Down
8 changes: 4 additions & 4 deletions requirements/docs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ beautifulsoup4==4.12.3
# pydata-sphinx-theme
bleach==6.1.0
# via nbconvert
certifi==2024.7.4
certifi==2024.8.30
# via requests
charset-normalizer==3.3.2
# via requests
Expand All @@ -40,7 +40,7 @@ docutils==0.21.2
# sphinx
fastjsonschema==2.20.0
# via nbformat
idna==3.7
idna==3.8
# via requests
imagesize==1.4.1
# via sphinx
Expand Down Expand Up @@ -110,7 +110,7 @@ psutil==6.0.0
# via ipykernel
pydata-sphinx-theme==0.15.4
# via -r docs.in
pyzmq==26.1.0
pyzmq==26.2.0
# via
# ipykernel
# jupyter-client
Expand Down Expand Up @@ -139,7 +139,7 @@ sphinx==8.0.2
# sphinx-autodoc-typehints
# sphinx-copybutton
# sphinx-design
sphinx-autodoc-typehints==2.2.3
sphinx-autodoc-typehints==2.3.0
# via -r docs.in
sphinx-copybutton==0.5.2
# via -r docs.in
Expand Down
2 changes: 1 addition & 1 deletion requirements/mypy.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# pip-compile-multi
#
-r test.txt
mypy==1.11.1
mypy==1.11.2
# via -r mypy.in
mypy-extensions==1.0.0
# via mypy
32 changes: 17 additions & 15 deletions requirements/nightly.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ cloudpickle==3.0.0
# via dask
comm==0.2.2
# via ipywidgets
contourpy==1.2.1
contourpy==1.3.0
# via matplotlib
cyclebane==24.6.0
# via sciline
cycler==0.12.1
# via matplotlib
dask==2024.8.0
dask==2024.8.2
# via -r nightly.in
decorator==5.1.1
# via ipython
essreduce==24.8.0
essreduce==24.9.0
# via -r nightly.in
executing==2.0.1
executing==2.1.0
# via stack-data
fonttools==4.53.1
# via matplotlib
Expand All @@ -38,21 +38,21 @@ h5py==3.11.0
# via
# scippneutron
# scippnexus
importlib-metadata==8.2.0
importlib-metadata==8.4.0
# via dask
ipydatawidgets==4.3.5
# via pythreejs
ipython==8.26.0
ipython==8.27.0
# via ipywidgets
ipywidgets==8.1.3
ipywidgets==8.1.5
# via
# ipydatawidgets
# pythreejs
jedi==0.19.1
# via ipython
jupyterlab-widgets==3.0.11
jupyterlab-widgets==3.0.13
# via ipywidgets
kiwisolver==1.4.5
kiwisolver==1.4.6
# via matplotlib
locket==1.0.0
# via partd
Expand All @@ -66,7 +66,7 @@ mpltoolbox==24.5.1
# via scippneutron
networkx==3.3
# via cyclebane
numpy==2.0.1
numpy==2.1.1
# via
# contourpy
# h5py
Expand Down Expand Up @@ -99,7 +99,7 @@ pure-eval==0.2.3
# via stack-data
pygments==2.18.0
# via ipython
pyparsing==3.1.2
pyparsing==3.1.4
# via matplotlib
python-dateutil==2.9.0.post0
# via
Expand All @@ -113,7 +113,9 @@ pyyaml==6.0.2
# dask
# orsopy
sciline @ git+https://github.com/scipp/sciline@main
# via -r nightly.in
# via
# -r nightly.in
# essreduce
scipp @ https://github.com/scipp/scipp/releases/download/nightly/scipp-nightly-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
# via
# -r nightly.in
Expand All @@ -127,7 +129,7 @@ scippnexus @ git+https://github.com/scipp/scippnexus@main
# -r nightly.in
# essreduce
# scippneutron
scipy==1.14.0
scipy==1.14.1
# via
# scippneutron
# scippnexus
Expand Down Expand Up @@ -155,7 +157,7 @@ typing-extensions==4.12.2
# via ipython
wcwidth==0.2.13
# via prompt-toolkit
widgetsnbextension==4.0.11
widgetsnbextension==4.0.13
# via ipywidgets
zipp==3.20.0
zipp==3.20.1
# via importlib-metadata
2 changes: 1 addition & 1 deletion src/ess/reflectometry/corrections.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def compute_reference_intensity(
with the experiment parameters (such as sample rotation).
Therefore it can be used to normalize sample measurements.
"""
b = da.bins.concat(set(da.dims) - set(da.coords["z_index"].dims)).bin(wavelength=wb)
b = da.bin(wavelength=wb, dim=set(da.dims) - set(da.coords["z_index"].dims))
h = b.hist()
h.masks["too_few_events"] = h.data < sc.scalar(1, unit="counts")
# Add a Q coordinate to each bin, the Q is not completely unique in every bin,
Expand Down
5 changes: 2 additions & 3 deletions src/ess/reflectometry/normalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ def normalization_factor(
"""
sample_q = (
da.bins.concat(set(da.dims) - set(da.coords["z_index"].dims))
.bin(wavelength=wbins)
da.bin(wavelength=wbins, dim=set(da.dims) - set(da.coords["z_index"].dims))
.bins.coords["Q"]
.bins.mean()
)
Expand Down Expand Up @@ -112,7 +111,7 @@ def reflectivity_over_q(
Reflectivity as a function of Q
"""
return NormalizedIofQ(
da.bins.concat().bin(Q=qbins) / sc.values(n.flatten(to="Q").hist(Q=qbins))
da.bin(Q=qbins, dim=da.dims) / sc.values(n.hist(Q=qbins, dim=n.dims))
)


Expand Down

0 comments on commit bf074db

Please sign in to comment.