Skip to content

Commit d4d3d94

Browse files
authored
Merge pull request #58 from mreineck/forward_adjoint
Draft: add ducc support for forward adjoint
2 parents 126e26e + e5b6f36 commit d4d3d94

File tree

12 files changed

+111
-16
lines changed

12 files changed

+111
-16
lines changed

.github/workflows/python.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,14 @@ jobs:
118118
mv source-distribution/*.tar.gz wheel-*/*.whl dist
119119
120120
- name: Publish distribution 📦 to Test PyPI
121-
if: ${{ github.ref != 'refs/tags/v1.4.0' }}
121+
if: ${{ github.ref != 'refs/tags/v1.5.0' }}
122122
uses: pypa/gh-action-pypi-publish@master
123123
with:
124124
password: ${{ secrets.TEST_PYPI_TOKEN }}
125125
repository_url: https://test.pypi.org/legacy/
126126

127127
- name: Publish distribution 📦 to PyPI
128-
if: ${{ github.ref == 'refs/tags/v1.4.0' }}
128+
if: ${{ github.ref == 'refs/tags/v1.5.0' }}
129129
uses: pypa/gh-action-pypi-publish@master
130130
with:
131131
password: ${{ secrets.PYPI_TOKEN }}

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.12)
22

33
project(
44
Ssht
5-
VERSION "1.4.0"
5+
VERSION "1.5.0"
66
DESCRIPTION "Fast and exact spin spherical harmonic transforms"
77
HOMEPAGE_URL "http://astro-informatics.github.io/ssht/"
88
LANGUAGES C)

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ spin spherical harmonic transforms based on the sampling theorem on the
2323
sphere derived in <a href="http://www.jasonmcewen.org/publication/mcewen-fssht/">McEwen & Wiaux (2011)</a>.
2424

2525
**SSHT** can also interface with [ducc0](https://pypi.org/project/ducc0/) and
26-
*use it as a backend for the forward, inverse and inverse adjoint transforms.
26+
use it as a backend for spherical harmonic transforms and rotations.
2727

2828

2929
## INSTALLATION
@@ -82,4 +82,4 @@ SSHT is released under the GPL-3 license. For further details see
8282

8383
## AUTHORS
8484

85-
SSHT was initially written by [Jason McEwen](http://www.jasonmcewen.org/) but significant contributors have since been made by a number of <a href="https://github.com/astro-informatics/ssht/graphs/contributors">others</a>.
85+
SSHT was initially written by [Jason McEwen](http://www.jasonmcewen.org/) but significant contributors have since been made by a number of <a href="https://github.com/astro-informatics/ssht/graphs/contributors">others</a>.

docs/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ <h2>News</h2>
5151

5252
<ul>
5353

54+
<li><strong>July 2021</strong><br />
55+
Release of SSHT 1.5.0 (<a href="https://pypi.org/project/ducc0/">ducc0</a> forward adjoint)
5456
<li><strong>July 2021</strong><br />
5557
Release of SSHT 1.4.0 (<a href="https://pypi.org/project/ducc0/">ducc0</a>interface)
5658
<li><strong>February 2021</strong><br />

makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# ======== COMPILER ========
22

33
CC = gcc
4-
OPT = -std=c99 -pedantic -Wall -O3 -fopenmp -DSSHT_VERSION=\"1.4.0\" -DSSHT_BUILD=\"`git rev-parse HEAD`\"
4+
OPT = -std=c99 -pedantic -Wall -O3 -fopenmp -DSSHT_VERSION=\"1.5.0\" -DSSHT_BUILD=\"`git rev-parse HEAD`\"
55
#OPT = -Wall -g -fopenmp -DSSHT_VERSION=\"1.0b1\" -DSSHT_BUILD=\"`git rev-parse HEAD`\"
66

77

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 1.4.0
2+
current_version = 1.5.0
33
commit = False
44
tag = False
55
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(rc(?P<rc>\d+))?

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"conan",
1919
"pip!=20.0.0,!=20.0.1",
2020
"pytest",
21-
"ducc0>=0.16",
21+
"ducc0>=0.18",
2222
]
2323

2424
long_description = (
@@ -27,7 +27,7 @@
2727

2828
setup(
2929
name="pyssht",
30-
version="1.4.0",
30+
version="1.5.0",
3131
author=[
3232
"J. D. McEwen",
3333
"C. R. G. Wallis",
@@ -36,7 +36,7 @@
3636
"Y. Wiaux",
3737
],
3838
install_requires=["numpy", "scipy"],
39-
extras_require={"dev": dev_requirements, "ducc0": ["ducc0>=0.16"]},
39+
extras_require={"dev": dev_requirements, "ducc0": ["ducc0>=0.18"]},
4040
description="Fast spin spherical transforms",
4141
long_description=long_description,
4242
long_description_content_type="text/markdown",

src/pyssht/SSHT_Python_Documentation.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ Performs the adjoint of the forward spherical harmonic transform.
9898
1. `'MW'` [McEwen & Wiaux sampling (default)]
9999
2. `'MWSS'` [McEwen & Wiaux symmetric sampling]
100100
* `Reality` determines if the signal is real or complex, Boolean (default = False)
101+
* `backend` the backend that runs the transforms:
102+
1. `'SSHT'` this package
103+
2. `'ducc'` interface to [ducc0](https://pypi.org/project/ducc0/).
104+
* `nthreads`: number of threads when calling into the `'ducc'` backend. Ignored otherwise.
101105

102106
#### Output
103107

@@ -122,8 +126,7 @@ Performs the adjoint of the inverse spherical harmonic transform.
122126
* `Reality` determines if the signal is real or complex, Boolean (default = False)
123127
* `backend` the backend that runs the transforms:
124128
1. `'SSHT'` this package
125-
2. `'ducc'` interface to [ducc0](https://pypi.org/project/ducc0/). "MW_pole"
126-
is not available in this backend.
129+
2. `'ducc'` interface to [ducc0](https://pypi.org/project/ducc0/).
127130
* `nthreads`: number of threads when calling into the `'ducc'` backend. Ignored otherwise.
128131

129132
#### Output

src/pyssht/cpyssht.pyx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -612,11 +612,15 @@ def inverse_adjoint(f, int L, int Spin=0, str Method='MW', bint Reality=False, s
612612
return flm
613613

614614

615-
def forward_adjoint(flm, int L, int Spin=0, str Method='MW', bint Reality=False, str backend="SSHT"):
616-
from pyssht.parameters import method
615+
def forward_adjoint(flm, int L, int Spin=0, str Method='MW', bint Reality=False, str backend="SSHT", **kwargs):
616+
from pyssht.ducc_interface import forward_adjoint as _ducc0_forward_adjoint
617+
from pyssht.parameters import method, Ducc
617618

618619
params = method(Method, spin=Spin, reality=Reality, backend=backend)
619620

621+
if isinstance(params, Ducc):
622+
return _ducc0_forward_adjoint(flm, L, params.spin, params.method, params.reality, params.nthreads)
623+
620624
if flm.ndim != 1:
621625
raise ssht_input_error('flm must be 1D numpy array')
622626

src/pyssht/ducc_interface.pyx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,3 +205,39 @@ def forward(f, L, Spin, Method, Reality, int nthreads = 1):
205205
geometry=gdict[Method]), L)
206206
res *= -1
207207
return res
208+
209+
210+
def forward_adjoint(np.ndarray flm, Py_ssize_t L, Py_ssize_t Spin, str Method, bint Reality, int nthreads = 1):
211+
ducc0 = import_ducc0()
212+
gdict = {"DH":"F1", "MW":"MW", "MWSS":"CC", "GL":"GL"}
213+
theta = _get_theta(L, Method)
214+
ntheta = theta.shape[0]
215+
nphi = 2*L-1
216+
if Method == 'MWSS':
217+
nphi += 1
218+
if Reality:
219+
return ducc0.sht.experimental.adjoint_analysis_2d(
220+
alm=_extract_real_alm(flm, L).reshape((1,-1)),
221+
ntheta=ntheta,
222+
nphi=nphi,
223+
lmax=L-1,
224+
nthreads=nthreads,
225+
spin=0,
226+
geometry=gdict[Method])[0]
227+
elif Spin == 0:
228+
alm = _extract_complex_alm(flm, L)
229+
flmr = _build_real_flm(alm[0], L)
230+
flmi = _build_real_flm(alm[1], L)
231+
return forward_adjoint(flmr, L, 0, Method, True) + 1j*forward_adjoint(flmi, L, 0, Method, True)
232+
else:
233+
tmp=ducc0.sht.experimental.adjoint_analysis_2d(
234+
alm=_extract_complex_alm(flm, L),
235+
ntheta=ntheta,
236+
nphi=nphi,
237+
lmax=L-1,
238+
nthreads=nthreads,
239+
spin=Spin,
240+
geometry=gdict[Method])
241+
res = -1j*tmp[1]
242+
res -= tmp[0]
243+
return res

0 commit comments

Comments
 (0)