Skip to content

Commit

Permalink
Merge pull request #151 from scipp/use-ess-reduce-uncertainty
Browse files Browse the repository at this point in the history
Use ess.reduce.uncertainty
  • Loading branch information
SimonHeybrock authored Jul 10, 2024
2 parents d0386b9 + 39088ab commit a186d7e
Show file tree
Hide file tree
Showing 15 changed files with 58 additions and 197 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ requires-python = ">=3.10"
dependencies = [
"dask",
"graphviz",
"essreduce",
"essreduce>=24.07.1",
"numpy",
"pandas",
"plopp",
Expand Down
2 changes: 1 addition & 1 deletion requirements/base.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# The following was generated by 'tox -e deps', DO NOT EDIT MANUALLY!
dask
graphviz
essreduce
essreduce>=24.07.1
numpy
pandas
plopp
Expand Down
20 changes: 10 additions & 10 deletions requirements/base.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SHA1:a419141758f6ec7372e221342a4009155e24e0b3
# SHA1:de9b98c06b7f66e8a4b7ad3c33a255c987e96668
#
# This file is autogenerated by pip-compile-multi
# To update, run:
Expand All @@ -7,7 +7,7 @@
#
asttokens==2.4.1
# via stack-data
certifi==2024.6.2
certifi==2024.7.4
# via requests
charset-normalizer==3.3.2
# via requests
Expand All @@ -23,19 +23,19 @@ cyclebane==24.6.0
# via sciline
cycler==0.12.1
# via matplotlib
dask==2024.6.2
dask==2024.7.0
# via -r base.in
decorator==5.1.1
# via ipython
essreduce==24.6.0
essreduce==24.7.1
# via -r base.in
exceptiongroup==1.2.1
# via ipython
executing==2.0.1
# via stack-data
fonttools==4.53.0
fonttools==4.53.1
# via matplotlib
fsspec==2024.6.0
fsspec==2024.6.1
# via dask
graphviz==0.20.3
# via -r base.in
Expand All @@ -49,7 +49,7 @@ importlib-metadata==8.0.0
# via dask
ipydatawidgets==4.3.5
# via pythreejs
ipython==8.25.0
ipython==8.26.0
# via ipywidgets
ipywidgets==8.1.3
# via
Expand All @@ -63,7 +63,7 @@ kiwisolver==1.4.5
# via matplotlib
locket==1.0.0
# via partd
matplotlib==3.9.0
matplotlib==3.9.1
# via
# mpltoolbox
# plopp
Expand Down Expand Up @@ -99,7 +99,7 @@ partd==1.4.2
# via dask
pexpect==4.9.0
# via ipython
pillow==10.3.0
pillow==10.4.0
# via matplotlib
platformdirs==4.2.2
# via pooch
Expand Down Expand Up @@ -140,7 +140,7 @@ scipp==24.6.0
# essreduce
# scippneutron
# scippnexus
scippneutron==24.6.0
scippneutron==24.7.0
# via -r base.in
scippnexus==24.6.0
# via
Expand Down
4 changes: 2 additions & 2 deletions requirements/ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#
cachetools==5.3.3
# via tox
certifi==2024.6.2
certifi==2024.7.4
# via requests
chardet==5.2.0
# via tox
Expand Down Expand Up @@ -48,7 +48,7 @@ tomli==2.0.1
# via
# pyproject-api
# tox
tox==4.15.1
tox==4.16.0
# via -r ci.in
urllib3==2.2.2
# via requests
Expand Down
12 changes: 6 additions & 6 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ async-lru==2.0.4
# via jupyterlab
cffi==1.16.0
# via argon2-cffi-bindings
copier==9.2.0
copier==9.3.1
# via -r dev.in
dunamai==1.21.1
dunamai==1.21.2
# via copier
fqdn==1.5.1
# via jsonschema
Expand All @@ -50,7 +50,7 @@ json5==0.9.25
# via jupyterlab-server
jsonpointer==3.0.0
# via jsonschema
jsonschema[format-nongpl]==4.22.0
jsonschema[format-nongpl]==4.23.0
# via
# jupyter-events
# jupyterlab-server
Expand All @@ -67,7 +67,7 @@ jupyter-server==2.14.1
# notebook-shim
jupyter-server-terminals==0.5.3
# via jupyter-server
jupyterlab==4.2.2
jupyterlab==4.2.3
# via -r dev.in
jupyterlab-server==2.27.2
# via jupyterlab
Expand All @@ -87,9 +87,9 @@ prometheus-client==0.20.0
# via jupyter-server
pycparser==2.22
# via cffi
pydantic==2.7.4
pydantic==2.8.2
# via copier
pydantic-core==2.18.4
pydantic-core==2.20.1
# via pydantic
python-json-logger==2.0.7
# via jupyter-events
Expand Down
6 changes: 3 additions & 3 deletions requirements/docs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ fastjsonschema==2.20.0
# via nbformat
imagesize==1.4.1
# via sphinx
ipykernel==6.29.4
ipykernel==6.29.5
# via -r docs.in
jinja2==3.1.4
# via
# myst-parser
# nbconvert
# nbsphinx
# sphinx
jsonschema==4.22.0
jsonschema==4.23.0
# via nbformat
jsonschema-specifications==2023.12.1
# via jsonschema
Expand Down Expand Up @@ -106,7 +106,7 @@ referencing==0.35.1
# via
# jsonschema
# jsonschema-specifications
rpds-py==0.18.1
rpds-py==0.19.0
# via
# jsonschema
# referencing
Expand Down
2 changes: 1 addition & 1 deletion requirements/nightly.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# The following was generated by 'tox -e deps', DO NOT EDIT MANUALLY!
dask
graphviz
essreduce
essreduce>=24.07.1
numpy
pandas
pythreejs
Expand Down
18 changes: 9 additions & 9 deletions requirements/nightly.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SHA1:5bcc8aaff2015158a2013bfbad166d4226952cc9
# SHA1:942b2a0d63bab480e4dfe7e345ab2839de386dd8
#
# This file is autogenerated by pip-compile-multi
# To update, run:
Expand All @@ -8,7 +8,7 @@
-r basetest.txt
asttokens==2.4.1
# via stack-data
certifi==2024.6.2
certifi==2024.7.4
# via requests
charset-normalizer==3.3.2
# via requests
Expand All @@ -24,17 +24,17 @@ cyclebane==24.6.0
# via sciline
cycler==0.12.1
# via matplotlib
dask==2024.6.2
dask==2024.7.0
# via -r nightly.in
decorator==5.1.1
# via ipython
essreduce==24.6.0
essreduce==24.7.1
# via -r nightly.in
executing==2.0.1
# via stack-data
fonttools==4.53.0
fonttools==4.53.1
# via matplotlib
fsspec==2024.6.0
fsspec==2024.6.1
# via dask
graphviz==0.20.3
# via -r nightly.in
Expand All @@ -48,7 +48,7 @@ importlib-metadata==8.0.0
# via dask
ipydatawidgets==4.3.5
# via pythreejs
ipython==8.25.0
ipython==8.26.0
# via ipywidgets
ipywidgets==8.1.3
# via
Expand All @@ -62,7 +62,7 @@ kiwisolver==1.4.5
# via matplotlib
locket==1.0.0
# via partd
matplotlib==3.9.0
matplotlib==3.9.1
# via
# mpltoolbox
# plopp
Expand Down Expand Up @@ -93,7 +93,7 @@ partd==1.4.2
# via dask
pexpect==4.9.0
# via ipython
pillow==10.3.0
pillow==10.4.0
# via matplotlib
platformdirs==4.2.2
# via pooch
Expand Down
2 changes: 1 addition & 1 deletion requirements/static.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ distlib==0.3.8
# via virtualenv
filelock==3.15.4
# via virtualenv
identify==2.5.36
identify==2.6.0
# via pre-commit
nodeenv==1.9.1
# via pre-commit
Expand Down
2 changes: 1 addition & 1 deletion src/ess/sans/beam_center_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import numpy as np
import sciline
import scipp as sc
from ess.reduce.uncertainty import UncertaintyBroadcastMode
from scipp.core import concepts

from .conversions import (
Expand Down Expand Up @@ -36,7 +37,6 @@
QBins,
ReturnEvents,
SampleRun,
UncertaintyBroadcastMode,
WavelengthBands,
WavelengthBins,
WavelengthMask,
Expand Down
16 changes: 5 additions & 11 deletions src/ess/sans/i_of_q.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import uuid

import scipp as sc
from ess.reduce.uncertainty import UncertaintyBroadcastMode, broadcast_uncertainties
from scipp.scipy.interpolate import interp1d

from .common import mask_range
Expand Down Expand Up @@ -31,11 +32,9 @@
RunType,
SampleRun,
ScatteringRunType,
UncertaintyBroadcastMode,
WavelengthBins,
WavelengthMonitor,
)
from .uncertainty import broadcast_with_upper_bound_variances


def preprocess_monitor_data(
Expand Down Expand Up @@ -65,7 +64,7 @@ def preprocess_monitor_data(
background. Everything outside this range is treated as background counts.
uncertainties:
The mode for broadcasting uncertainties. See
:py:class:`UncertaintyBroadcastMode` for details.
:py:class:`ess.reduce.uncertainty.UncertaintyBroadcastMode` for details.
Returns
-------
Expand All @@ -87,14 +86,9 @@ def preprocess_monitor_data(
monitor = monitor.rebin(wavelength=wavelength_bins)

if background is not None:
if uncertainties == UncertaintyBroadcastMode.drop:
monitor -= sc.values(background)
elif uncertainties == UncertaintyBroadcastMode.upper_bound:
monitor -= broadcast_with_upper_bound_variances(
background, sizes=monitor.sizes
)
else:
monitor -= background
monitor -= broadcast_uncertainties(
background, prototype=monitor, mode=uncertainties
)
return CleanMonitor(monitor)


Expand Down
Loading

0 comments on commit a186d7e

Please sign in to comment.