Skip to content

Commit

Permalink
Merge pull request #71 from SasView/release_0.9.0
Browse files Browse the repository at this point in the history
Merge release 0.9.0 branch into master
  • Loading branch information
krzywon authored Jul 15, 2024
2 parents cf12507 + e70bec6 commit a113ad6
Show file tree
Hide file tree
Showing 21 changed files with 94,568 additions and 160 deletions.
25 changes: 7 additions & 18 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,22 @@ jobs:
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
python-version: ['3.9', '3.10', '3.11']
python-version: ['3.10', '3.11']
fail-fast: false

steps:

- name: Obtain SasData source from git
uses: actions/checkout@v1
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

### Caching of pip downloads and local wheel builds
- name: Get pip cache dir
id: pip-cache
run: |
echo "name={$(pip cache dir)}" >> $GITHUB_OUTPUT
- name: Obtain pip cache (Linux)
uses: actions/cache@v2
with:
path: ${{ steps.pip-cache.outputs.name }}
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/test.yml') }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.python-version }}-
${{ runner.os }}-pip-
cache: 'pip'
cache-dependency-path: |
**/ci.yml
**/requirements*.txt
### Installation of build-dependencies

Expand Down
3 changes: 1 addition & 2 deletions LICENSE.TXT
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
Copyright (c) 2009-2022, SasView Developers

Copyright (c) 2009-2024, SasView Developers

All rights reserved.

Expand Down
3 changes: 2 additions & 1 deletion docs/source/rst_prolog
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.. Set up some substitutions to make life easier...

.. |Ang| unicode:: U+212B
.. |Ang^-1| replace:: |Ang|\ :sup:`-1`
.. |Ang^-1| replace:: |Ang|\ :sup:`-1`
.. |delta| unicode:: U+03B4
37 changes: 37 additions & 0 deletions docs/source/user/RELEASE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,43 @@ Features
========
Wheel, egg, and tar.gz files are available on `pypi <https://pypi.org/project/sasdata/>`_.

New in Version 0.9.0
--------------------
This is an enhancement release with updates to the unit conversion routines, the ability to load data from URIs, the
addition of a wedge slicer and other slicer enhancements.

What's Changed
^^^^^^^^^^^^^^

Feature Enhancements
____________________
* Refactor nxsunit by @krzywon in https://github.com/SasView/sasdata/pull/13
* Enable the sector slicing to allow both sides independantly by @butlerpd in https://github.com/SasView/sasdata/pull/36
* Load data from URIs by @krzywon in https://github.com/SasView/sasdata/pull/37
* SasData counterpart to SasView SlicerExtension_1344 by @jack-rooks in https://github.com/SasView/sasdata/pull/61

Bug Fixes
_________
* Fixing Issue #40 (but properly this time) by @ehewins in https://github.com/SasView/sasdata/pull/42
* changed xaxis label for updated SESANS nomenclature from z to delta by @caitwolf in https://github.com/SasView/sasdata/pull/60
* Fix delta in sesans docs by @caitwolf in https://github.com/SasView/sasdata/pull/65

Documentation Changes
_____________________
* Rework readme by @krzywon in https://github.com/SasView/sasdata/pull/15
* Building sasdata documentation by @krzywon in https://github.com/SasView/sasdata/pull/53
* Generate Developer Docs by @krzywon in https://github.com/SasView/sasdata/pull/56

Infrastructure Changes
______________________
* Remove entry_point from setup.py by @krzywon in https://github.com/SasView/sasdata/pull/2
* Dependency cleanup by @krzywon in https://github.com/SasView/sasdata/pull/33
* Move example data to sasdata by @krzywon in https://github.com/SasView/sasdata/pull/49
* CI updates by @krzywon in https://github.com/SasView/sasdata/pull/50
* Restrict lxml to versions less than 5.0 by @krzywon in https://github.com/SasView/sasdata/pull/63
* Update example data by @smk78 in https://github.com/SasView/sasdata/pull/58
* Fix broken unit test(s) by @krzywon in https://github.com/SasView/sasdata/pull/68

New in Version 0.8.1
--------------------
This is a point release to fix a build issue. The `sasdata.data_utils` package was omitted from setup.py causing an
Expand Down
6 changes: 3 additions & 3 deletions docs/source/user/data/data_formats_help.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ between users.
Following the header are up to 8 space-delimited columns of experimental
variables of which the first 4 columns are required. In order, these are:

- Spin-echo length (z, in Angstroms)
- Depolarization (:math:`log(P/P_0)/(lambda^2 * thickness)`, in Angstrom :sup:`-1` cm :sup:`-1`\ )
- Spin-echo length (:math:`\delta`, in Angstroms)
- Depolarization (:math:`log(P/P_0)/(\lambda^2 * thickness)`, in Angstrom :sup:`-1` cm :sup:`-1`\ )
- Depolarization error (also in in Angstrom :sup:`-1` cm :sup:`-1`\ ) (i.e. the measurement error)
- Spin-echo length error (:math:`\Delta`\ z, in Angstroms) (i.e. the experimental resolution)
- Spin-echo length error (:math:`\Delta \delta`, in Angstroms) (i.e. the experimental resolution)
- Neutron wavelength (:math:`\lambda`, in Angstroms)
- Neutron wavelength error (:math:`\Delta \lambda`, in Angstroms)
- Normalized polarization (:math:`P/P_0`, unitless)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ h5py
lxml < 5.0

# Calculation
numpy
numpy==1.*

# Unit testing
pytest
Expand Down
2 changes: 1 addition & 1 deletion sasdata/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
from pathlib import Path

__version__ = "0.8.1"
__version__ = "0.9.0"

# An importable path to the example data to
data_path: Path = Path(os.path.join(Path(os.path.dirname(__file__)), 'example_data'))
53 changes: 45 additions & 8 deletions sasdata/data_util/manipulations.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,19 +362,42 @@ def _avg(self, data2D, maj):
qy_data = data2D.qy_data[np.isfinite(data2D.data)]
mask_data = data2D.mask[np.isfinite(data2D.data)]

# Bin width calculation returns negative values when either axis has no points above 0.
self.bin_width = abs(self.bin_width)

# Build array of Q intervals
if maj == 'x':
if self.fold:
x_min = 0
# Set x_max based on which is further from Qx = 0
x_max = max(abs(self.x_min),abs(self.x_max))
# Set x_min based on which is closer to Qx = 0, but will have different limits depending on whether
# x_min and x_max are on the same side of Qx = 0
if self.x_min*self.x_max >= 0: # If on same side
x_min = min(abs(self.x_min),abs(self.x_max))
else:
x_min = 0
else:
x_max = self.x_max
x_min = self.x_min
nbins = int(math.ceil((self.x_max - x_min) / self.bin_width))
y_max = self.y_max
y_min = self.y_min
nbins = int(math.ceil((x_max - x_min) / self.bin_width))
elif maj == 'y':
if self.fold:
y_min = 0
# Set y_max based on which is further from Qy = 0
y_max = max(abs(self.y_min), abs(self.y_max))
# Set y_min based on which is closer to Qy = 0, but will have different limits depending on whether
# y_min and y_max are on the same side of Qy = 0
if self.y_min * self.y_max >= 0: # If on same side
y_min = min(abs(self.y_min), abs(self.y_max))
else:
y_min = 0
else:
y_max = self.y_max
y_min = self.y_min
nbins = int(math.ceil((self.y_max - y_min) / self.bin_width))
x_max = self.x_max
x_min = self.x_min
nbins = int(math.ceil((y_max - y_min) / self.bin_width))
else:
raise RuntimeError("_Slab._avg: unrecognized axis %s" % str(maj))

Expand All @@ -392,10 +415,24 @@ def _avg(self, data2D, maj):
frac_x = 0
frac_y = 0
# get ROI
if self.x_min <= qx_data[npts] and self.x_max > qx_data[npts]:
frac_x = 1
if self.y_min <= qy_data[npts] and self.y_max > qy_data[npts]:
frac_y = 1
if self.fold:
# If folded, need to satisfy absolute value of Q, but also make sure we're only pulling
# from data inside the box (an issue when the box is not centered on 0)
if maj == 'x':
if self.x_min <= qx_data[npts] < self.x_max and x_min <= abs(qx_data[npts]) < x_max:
frac_x = 1
if self.y_min <= qy_data[npts] < self.y_max:
frac_y = 1
elif maj == 'y': # The case where maj != 'x' or 'y' was handled earlier
if self.y_min <= qy_data[npts] < self.y_max and y_min <= abs(qy_data[npts]) < y_max:
frac_y = 1
if self.x_min <= qx_data[npts] < self.x_max:
frac_x = 1
else:
if self.x_min <= qx_data[npts] < self.x_max:
frac_x = 1
if self.y_min <= qy_data[npts] < self.y_max:
frac_y = 1
frac = frac_x * frac_y

if frac == 0:
Expand Down
2 changes: 1 addition & 1 deletion sasdata/dataloader/readers/sesans_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def get_file_contents(self):
self.current_datainfo.source.wavelength_unit = lam_unit
self.current_datainfo.source.wavelength = lam
self.current_datainfo.filename = self.filepath.name
self.current_dataset.xaxis(r"\rm{z}", x_unit)
self.current_dataset.xaxis(r"\delta", x_unit)
# Adjust label to ln P/(lam^2 t), remove lam column refs
self.current_dataset.yaxis(r"\rm{ln(P)/(t \lambda^2)}", y_unit)
# Store loading process information
Expand Down
105 changes: 105 additions & 0 deletions sasdata/example_data/magnetic_data/S50_15kG_horizSector_RF+.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
0.0111179 7.27845 0.116389 0.00214635
0.0122637 6.917 0.124569 0.00215353
0.0133044 6.67641 0.121596 0.00215824
0.0142695 6.58246 0.0990066 0.00217468
0.0153097 6.19897 0.0952062 0.0021891
0.0164391 5.92162 0.0858106 0.00220081
0.0175642 5.56036 0.0893136 0.00220978
0.018671 5.44436 0.0811117 0.00222896
0.019819 5.28556 0.0859812 0.00224856
0.0208599 4.74469 0.0813528 0.00226266
0.0219009 4.72968 0.0814051 0.00227425
0.0229124 4.31734 0.0711567 0.00229247
0.0238691 4.15703 0.0659863 0.00231264
0.0249094 3.83388 0.0622195 0.00233097
0.0259314 3.54063 0.050994 0.00234616
0.0270286 3.30922 0.0520788 0.00236343
0.0281072 3.03682 0.0471857 0.00239002
0.0292123 2.80118 0.0474372 0.00241299
0.0302523 2.57104 0.0455598 0.00243152
0.0312924 2.28601 0.0430925 0.00244784
0.0323325 2.18288 0.0419826 0.00247655
0.0333725 1.84627 0.0385636 0.0025014
0.0344126 1.70983 0.037105 0.00252312
0.035416 1.60411 0.0318589 0.00254165
0.0365081 1.38664 0.0309317 0.00257011
0.0375614 1.21361 0.0269386 0.00259829
0.0386006 1.07701 0.0256986 0.00262288
0.0396397 0.96008 0.0242338 0.0026448
0.0406788 0.872797 0.0233857 0.00267082
0.041718 0.779462 0.0221108 0.00270137
0.042757 0.67138 0.0209221 0.00272867
0.0437961 0.602752 0.0205557 0.00275324
0.0448351 0.535966 0.0195852 0.00277753
0.045231 0.573528 0.00747213 0.00376592
0.0458741 0.498762 0.0187304 0.00281058
0.0469289 0.459767 0.0171527 0.0028408
0.0479674 0.461399 0.0169186 0.00286774
0.0490297 0.46056 0.0165682 0.0028928
0.0500582 0.434842 0.0156696 0.00292616
0.0510962 0.457578 0.0157622 0.00295809
0.0513766 0.463026 0.00935895 0.00389759
0.0521342 0.455116 0.0157404 0.00298722
0.0531722 0.485569 0.0163063 0.00301389
0.05421 0.533085 0.0166086 0.00304558
0.0552479 0.525686 0.017213 0.00307957
0.0554721 0.560855 0.0103743 0.00398938
0.0562856 0.557377 0.016955 0.00311073
0.0573232 0.581227 0.017594 0.00313941
0.0583839 0.652921 0.0176332 0.00317008
0.0594138 0.685919 0.0176704 0.00320561
0.0595661 0.6734 0.0113103 0.00408522
0.0604509 0.707277 0.0175836 0.00323858
0.0615022 0.73008 0.0173613 0.00326947
0.0625389 0.792362 0.0178895 0.00329773
0.0635755 0.788111 0.0176729 0.00333516
0.0636583 0.82649 0.0127892 0.00418459
0.064612 0.848716 0.0180303 0.00336979
0.0656484 0.842921 0.0181712 0.00340194
0.0664017 0.868429 0.0256048 0.0034239
0.0677487 0.919334 0.0137777 0.00428697
0.0719536 0.94416 0.00989674 0.00430514
0.0760332 0.923015 0.00967703 0.00454924
0.0801111 0.862031 0.00936877 0.00466261
0.0841869 0.741194 0.00855311 0.00469578
0.0882604 0.610844 0.00762803 0.00492299
0.0923314 0.472767 0.0067149 0.00491516
0.0963997 0.369468 0.00591919 0.00513173
0.100465 0.273393 0.00536381 0.00521558
0.104527 0.22622 0.00501629 0.00542648
0.108587 0.196379 0.00479826 0.00540005
0.112642 0.195667 0.00475226 0.00560174
0.116694 0.213378 0.00483945 0.00580325
0.120857 0.243105 0.00416868 0.00590824
0.124898 0.259325 0.00424748 0.00610577
0.128934 0.25816 0.00421884 0.00615501
0.132967 0.251338 0.00416982 0.00634753
0.136996 0.248161 0.00418467 0.0063786
0.141021 0.230785 0.00405622 0.00656598
0.145041 0.205217 0.00390759 0.00675315
0.149056 0.17115 0.00368282 0.00694012
0.153067 0.150404 0.00348856 0.00712686
0.157073 0.120111 0.00335358 0.00731337
0.161074 0.111692 0.00326286 0.00749965
0.165184 0.100348 0.00271856 0.00759196
0.169915 0.0945483 0.00244782 0.00765396
0.17494 0.0978769 0.00234334 0.00788033
0.179947 0.100369 0.00250316 0.00782385
0.184671 0.0993578 0.00256916 0.00802923
0.189027 0.105491 0.00277034 0.00821863
0.192981 0.100213 0.00276534 0.00839053
0.196929 0.0902609 0.00266131 0.00856217
0.20087 0.0862154 0.00265127 0.00873354
0.204805 0.0825386 0.00256142 0.00890463
0.208848 0.0748894 0.00233143 0.00908041
0.212768 0.0678413 0.00228525 0.00925083
0.216681 0.0669027 0.00224416 0.00942097
0.220587 0.0654959 0.00221285 0.00959081
0.224487 0.0569142 0.00222199 0.00976036
0.228379 0.0533512 0.00217913 0.0099296
0.232848 0.0575319 0.0020205 0.0101239
0.237604 0.054073 0.0019038 0.0103307
0.24254 0.0538097 0.00182623 0.0105453
0.247432 0.0503629 0.00204843 0.010758
0.251583 0.0479654 0.00211937 0.0107767
0.255534 0.0502307 0.00193817 0.010946
Loading

0 comments on commit a113ad6

Please sign in to comment.