Skip to content

Commit

Permalink
Merge pull request #67 from scipp/wavelength-binning-union
Browse files Browse the repository at this point in the history
Allow both bin edges and number of bins in parameter `WavelengthBins`
  • Loading branch information
jokasimr authored Jun 24, 2024
2 parents 39b9ed1 + d3ba44b commit 0db19b2
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 37 deletions.
9 changes: 4 additions & 5 deletions docs/examples/scaling_workflow.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,11 @@
"import sciline as sl\n",
"import scipp as sc\n",
"\n",
"from ess.nmx.mtz_io import (\n",
" providers as mtz_io_providers,\n",
" default_parameters as mtz_io_params,\n",
")\n",
"from ess.nmx.mtz_io import providers as mtz_io_providers, default_parameters as mtz_io_params\n",
"from ess.nmx.mtz_io import SpaceGroupDesc\n",
"from ess.nmx.scaling import scaling_providers, scaling_params\n",
"from ess.nmx.scaling import providers as scaling_providers, default_parameters as scaling_params\n",
"from ess.nmx.scaling import (\n",
" WavelengthBins,\n",
" FilteredEstimatedScaledIntensities,\n",
" ReferenceWavelength,\n",
" ScaledIntensityLeftTailThreshold,\n",
Expand All @@ -101,6 +99,7 @@
" ),\n",
" **mtz_io_params,\n",
" **scaling_params,\n",
" WavelengthBins: 250,\n",
" },\n",
")\n",
"pl"
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,10 @@ requires-python = ">=3.10"
dependencies = [
"dask",
"graphviz",
"numpy<2.0.0",
"plopp",
"sciline>=24.06.0",
"scipp>=23.8.0",
"scippnexus>=23.9.0",
"scippnexus>=23.12.0",
"pooch",
"pandas",
"gemmi",
Expand Down
3 changes: 1 addition & 2 deletions requirements/base.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
# The following was generated by 'tox -e deps', DO NOT EDIT MANUALLY!
dask
graphviz
numpy<2.0.0
plopp
sciline>=24.06.0
scipp>=23.8.0
scippnexus>=23.9.0
scippnexus>=23.12.0
pooch
pandas
gemmi
Expand Down
19 changes: 11 additions & 8 deletions requirements/base.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SHA1:d990037ca721ab7b651343616ad51b7121679fd1
# SHA1:bea70253436877e109e43f0839bf995cf4bbc84f
#
# This file is autogenerated by pip-compile-multi
# To update, run:
Expand All @@ -19,7 +19,7 @@ cyclebane==24.6.0
# via sciline
cycler==0.12.1
# via matplotlib
dask==2024.6.0
dask==2024.6.2
# via -r base.in
defusedxml==0.7.1
# via -r base.in
Expand All @@ -35,6 +35,8 @@ h5py==3.11.0
# via scippnexus
idna==3.7
# via requests
importlib-metadata==7.2.1
# via dask
kiwisolver==1.4.5
# via matplotlib
locket==1.0.0
Expand All @@ -43,9 +45,8 @@ matplotlib==3.9.0
# via plopp
networkx==3.3
# via cyclebane
numpy==1.26.4
numpy==2.0.0
# via
# -r base.in
# contourpy
# h5py
# matplotlib
Expand All @@ -65,7 +66,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
pooch==1.8.2
# via -r base.in
Expand All @@ -82,13 +83,13 @@ pyyaml==6.0.1
# via dask
requests==2.32.3
# via pooch
sciline==24.6.0
sciline==24.6.1
# via -r base.in
scipp==24.6.0
# via
# -r base.in
# scippnexus
scippnexus==24.3.1
scippnexus==24.6.0
# via -r base.in
scipy==1.13.1
# via scippnexus
Expand All @@ -100,5 +101,7 @@ toolz==0.12.1
# partd
tzdata==2024.1
# via pandas
urllib3==2.2.1
urllib3==2.2.2
# via requests
zipp==3.19.2
# via importlib-metadata
8 changes: 4 additions & 4 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.15.1
filelock==3.15.4
# via
# tox
# virtualenv
Expand All @@ -38,7 +38,7 @@ platformdirs==4.2.2
# virtualenv
pluggy==1.5.0
# via tox
pyproject-api==1.6.1
pyproject-api==1.7.1
# via tox
requests==2.32.3
# via -r ci.in
Expand All @@ -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
virtualenv==20.26.3
# via tox
4 changes: 2 additions & 2 deletions requirements/docs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ pexpect==4.9.0
# via ipython
prompt-toolkit==3.0.47
# via ipython
psutil==5.9.8
psutil==6.0.0
# via ipykernel
ptyprocess==0.7.0
# via pexpect
Expand Down Expand Up @@ -173,7 +173,7 @@ sphinx==7.3.7
# sphinx-autodoc-typehints
# sphinx-copybutton
# sphinx-design
sphinx-autodoc-typehints==2.1.1
sphinx-autodoc-typehints==2.2.2
# via -r docs.in
sphinx-copybutton==0.5.2
# via -r docs.in
Expand Down
1 change: 0 additions & 1 deletion requirements/nightly.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# The following was generated by 'tox -e deps', DO NOT EDIT MANUALLY!
dask
graphviz
numpy<2.0.0
pooch
pandas
gemmi
Expand Down
11 changes: 5 additions & 6 deletions requirements/nightly.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SHA1:cf810ac50e2bcd3c53242a4261e4ec4706454425
# SHA1:38452d7c1b37c7bcf4e0819d4f3cfcbe168c62ad
#
# This file is autogenerated by pip-compile-multi
# To update, run:
Expand All @@ -20,7 +20,7 @@ cyclebane==24.6.0
# via sciline
cycler==0.12.1
# via matplotlib
dask==2024.6.0
dask==2024.6.2
# via -r nightly.in
defusedxml==0.7.1
# via -r nightly.in
Expand All @@ -36,7 +36,7 @@ h5py==3.11.0
# via scippnexus
idna==3.7
# via requests
importlib-metadata==7.1.0
importlib-metadata==7.2.1
# via dask
kiwisolver==1.4.5
# via matplotlib
Expand All @@ -46,9 +46,8 @@ matplotlib==3.9.0
# via plopp
networkx==3.3
# via cyclebane
numpy==1.26.4
numpy==2.0.0
# via
# -r nightly.in
# contourpy
# h5py
# matplotlib
Expand Down Expand Up @@ -98,7 +97,7 @@ toolz==0.12.1
# partd
tzdata==2024.1
# via pandas
urllib3==2.2.1
urllib3==2.2.2
# via requests
zipp==3.19.2
# via importlib-metadata
4 changes: 2 additions & 2 deletions 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.15.1
filelock==3.15.4
# via virtualenv
identify==2.5.36
# via pre-commit
Expand All @@ -21,5 +21,5 @@ pre-commit==3.7.1
# via -r static.in
pyyaml==6.0.1
# via pre-commit
virtualenv==20.26.2
virtualenv==20.26.3
# via pre-commit
9 changes: 4 additions & 5 deletions src/ess/nmx/scaling.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
# Copyright (c) 2024 Scipp contributors (https://github.com/scipp)
from collections.abc import Callable, Mapping
from dataclasses import dataclass
from typing import NewType, TypeVar
from typing import NewType, TypeVar, Union

import scipp as sc

from .mtz_io import NMXMtzDataArray

# User defined or configurable types
WavelengthBins = NewType("WavelengthBins", sc.Variable)
WavelengthBins = NewType("WavelengthBins", Union[sc.Variable, int])
"""User configurable wavelength binning"""
ReferenceWavelength = NewType("ReferenceWavelength", sc.Variable | None)
"""The wavelength to select reference intensities."""
Expand Down Expand Up @@ -438,8 +438,7 @@ def calculate_wavelength_scale_factor(
return WavelengthScaleFactors(scale_factor)


# Providers and default parameters
scaling_providers = (
providers = (
cut_tails,
get_wavelength_binned,
get_reference_wavelength,
Expand All @@ -451,7 +450,7 @@ def calculate_wavelength_scale_factor(
)
"""Providers for scaling data."""

scaling_params = {
default_parameters = {
WavelengthBins: sc.linspace("wavelength", 2.6, 3.6, 250, unit="angstrom"),
ScaledIntensityLeftTailThreshold: DEFAULT_LEFT_TAIL_THRESHOLD,
ScaledIntensityRightTailThreshold: DEFAULT_RIGHT_TAIL_THRESHOLD,
Expand Down

0 comments on commit 0db19b2

Please sign in to comment.