Skip to content

Commit deed436

Browse files
authored
Merge pull request #55 from mreineck/main
Draft/request for discussion: optional ducc0-based backend for SHTs
2 parents 8216fe3 + 44c0be8 commit deed436

File tree

14 files changed

+787
-150
lines changed

14 files changed

+787
-150
lines changed

.github/workflows/python.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
python -m pip install scikit-build
3232
3333
- name: Install pyssht
34-
run: pip install -e .[dev]
34+
run: pip install -e .[dev,ducc0]
3535

3636
- name: run pytest
3737
run: pytest tests/test_pyssht.py
@@ -85,7 +85,7 @@ jobs:
8585
- name: Setup environment
8686
run: |
8787
python -m pip install --upgrade pip wheel
88-
python -m pip install conan pytest
88+
python -m pip install conan pytest ducc0
8989
conan profile new default --detect
9090
9191
- name: Build wheels

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ SSHT.sublime-workspace
55
build/
66
*.DS_Store
77
*.idea/
8-
src/python/*.c
9-
src/python/*.so
8+
src/pyssht/*.c
9+
src/pyssht/*.so
1010

1111
CMakeCache.txt
1212
CMakeFiles/

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"conan",
1919
"pip!=20.0.0,!=20.0.1",
2020
"pytest",
21+
"ducc0>=0.16",
2122
]
2223

2324
long_description = (
@@ -35,7 +36,7 @@
3536
"Y. Wiaux",
3637
],
3738
install_requires=["numpy", "scipy"],
38-
extras_require={"dev": dev_requirements},
39+
extras_require={"dev": dev_requirements, "ducc0": ["ducc0>=0.16"]},
3940
description="Fast spin spherical transforms",
4041
long_description=long_description,
4142
long_description_content_type="text/markdown",

src/pyssht/CMakeLists.txt

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
add_cython_target(cython_sources pyssht.pyx C PY3)
2-
add_library(pyssht MODULE ${cython_sources})
3-
python_extension_module(pyssht)
4-
target_link_libraries(pyssht ssht)
5-
target_include_directories(pyssht PUBLIC "${PROJECT_SOURCE_DIR}/src/c"
6-
${NumPy_INCLUDE_DIRS})
1+
add_cython_target(cpyssht_sources cpyssht.pyx C PY3)
2+
add_cython_target(ducc0_sources ducc_interface.pyx C PY3)
3+
add_library(cpyssht MODULE ${cpyssht_sources})
4+
add_library(ducc_interface MODULE ${ducc0_sources})
5+
python_extension_module(cpyssht)
6+
python_extension_module(ducc_interface)
7+
target_link_libraries(cpyssht ssht)
8+
target_include_directories(cpyssht PUBLIC "${PROJECT_SOURCE_DIR}/src/c"
9+
${NumPy_INCLUDE_DIRS})
10+
target_include_directories(ducc_interface PUBLIC ${NumPy_INCLUDE_DIRS})
711
if(WIN32)
8-
target_compile_definitions(pyssht PUBLIC MS_WIN64)
12+
target_compile_definitions(cpyssht PUBLIC MS_WIN64)
13+
target_compile_definitions(ducc_interface PUBLIC MS_WIN64)
914
endif()
10-
install(TARGETS pyssht LIBRARY DESTINATION src/pyssht)
15+
install(TARGETS cpyssht ducc_interface LIBRARY DESTINATION src/pyssht)

src/pyssht/SSHT_Python_Documentation.md

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# SSHT Python Documentation
22

3-
This guide is intended to explain the python interface of SSHT. For a description of the workings of SSHT see [here](http://astro-informatics.github.io/ssht/ "SSHT documentation")
3+
This guide is intended to explain the python interface of SSHT. For a
4+
description of the workings of SSHT see
5+
[here](http://astro-informatics.github.io/ssht/ "SSHT documentation"). The
6+
python package also offers an interface to some of the functionality from
7+
[ducc0](https://pypi.org/project/ducc0/), including forward and inverse
8+
transforms.
49

510
## pyssht.forward
611

@@ -22,6 +27,11 @@ Performs the forward spherical harmonic transform.
2227
4. `'DH'` [Driscoll & Healy sampling]
2328
5. `'GL'` [Gauss-Legendre sampling]
2429
* `Reality` determines if the signal is real or complex, Boolean (default = False)
30+
* `backend` the backend that runs the transforms:
31+
1. `'SSHT'` this package
32+
2. `'ducc'` interface to [ducc0](https://pypi.org/project/ducc0/). "MW_pole"
33+
is not available in this backend.
34+
* `nthreads`: number of threads when calling into the `'ducc'` backend. Ignored otherwise.
2535

2636
#### Output
2737

@@ -54,6 +64,11 @@ Performs the inverse spherical harmonic transform.
5464
4. `'DH'` [Driscoll & Healy sampling]
5565
5. `'GL'` [Gauss-Legendre sampling]
5666
* `Reality` determines if the signal is real or complex, Boolean (default = False)
67+
* `backend` the backend that runs the transforms:
68+
1. `'SSHT'` this package
69+
2. `'ducc'` interface to [ducc0](https://pypi.org/project/ducc0/). "MW_pole"
70+
is not available in this backend.
71+
* `nthreads`: number of threads when calling into the `'ducc'` backend. Ignored otherwise.
5772

5873
#### Output
5974

@@ -105,6 +120,11 @@ Performs the adjoint of the inverse spherical harmonic transform.
105120
1. `'MW'` [McEwen & Wiaux sampling (default)]
106121
2. `'MWSS'` [McEwen & Wiaux symmetric sampling]
107122
* `Reality` determines if the signal is real or complex, Boolean (default = False)
123+
* `backend` the backend that runs the transforms:
124+
1. `'SSHT'` this package
125+
2. `'ducc'` interface to [ducc0](https://pypi.org/project/ducc0/). "MW_pole"
126+
is not available in this backend.
127+
* `nthreads`: number of threads when calling into the `'ducc'` backend. Ignored otherwise.
108128

109129
#### Output
110130

@@ -770,10 +790,13 @@ Function to rotate a set of spherical harmonic coefficients by the set of Euler
770790
* `beta` rotation angle \(\beta\), type `double`
771791
* `gamma` rotation angle \(\gamma\), type `double`
772792
* `L` the band limit of the signal, non-zero positive integer
773-
* `dl_array` if set should be the precomputed small Wigner D matrix for angle \(\beta\) and harmonic band limit `L`. If not set this is calculated in the function.
793+
* `dl_array` if set should be the precomputed small Wigner D matrix for angle \(\beta\) and harmonic band limit `L`. If not set this is calculated in the function. (This parameter is ignored when using the `ducc` backend.)
774794
* `M` if set is the azimuthal band limit of the function to be rotated, default `M=L`.
775795
* `Axisymmetric` set if the function is axisymmetric and axisymmetric harmonic coefficients are parsed.
776-
* `Keep_dl` if set the output is changed to allow one to keep the computed `dl_array`
796+
* `Keep_dl` if set the output is changed to allow one to keep the computed `dl_array`. (This parameter is ignored when using the `ducc` backend.)
797+
* `backend` the backend that runs the transforms:
798+
1. `'SSHT'` this package
799+
2. `'ducc'` interface to [ducc0](https://pypi.org/project/ducc0/)
777800

778801
#### Output
779802

src/pyssht/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44

55
__doc__ = (Path(__file__).parent / "SSHT_Python_Documentation.md").read_text()
66

7-
from .pyssht import *
7+
from pyssht.exceptions import ssht_spin_error, ssht_input_error # type: ignore
8+
from pyssht.cpyssht import *

0 commit comments

Comments
 (0)