https://github.com/astro-informatics/s2ball
Differentiable and accelerated wavelet transform on the ball with JAX
Science Score: 23.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
○codemeta.json file
-
○.zenodo.json file
-
✓DOI references
Found 3 DOI reference(s) in README -
✓Academic publication links
Links to: arxiv.org -
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (11.7%) to scientific vocabulary
Keywords
ball
differentiable-programming
harmonic-analysis
jax
wavelet-transform
Last synced: 5 months ago
·
JSON representation
Repository
Differentiable and accelerated wavelet transform on the ball with JAX
Basic Info
- Host: GitHub
- Owner: astro-informatics
- License: mit
- Language: Python
- Default Branch: main
- Homepage: https://astro-informatics.github.io/s2ball/
- Size: 4.6 MB
Statistics
- Stars: 6
- Watchers: 3
- Forks: 0
- Open Issues: 0
- Releases: 0
Topics
ball
differentiable-programming
harmonic-analysis
jax
wavelet-transform
Created about 3 years ago
· Last pushed about 2 years ago
Metadata Files
Readme
README.rst
.. image:: https://github.com/astro-informatics/s2ball/actions/workflows/tests.yml/badge.svg?branch=main
:target: https://github.com/astro-informatics/s2ball/actions/workflows/tests.yml
.. image:: https://codecov.io/gh/astro-informatics/s2ball/graph/badge.svg?token=12JWTZPO96
:target: https://codecov.io/gh/astro-informatics/s2ball
.. image:: https://img.shields.io/badge/License-MIT-yellow.svg
:target: https://opensource.org/licenses/MIT
.. image:: https://badge.fury.io/py/s2ball.svg
:target: https://badge.fury.io/py/s2ball
.. image:: http://img.shields.io/badge/arXiv-2402.01282-orange.svg?style=flat
:target: https://arxiv.org/abs/2402.01282
.. image:: https://img.shields.io/badge/all_contributors-2-orange.svg?style=flat-square
:target: #contributors-
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/psf/black
===================================================================
|logo| Differentiable and accelerated wavelet transform on the ball
===================================================================
.. |logo| raw:: html
`S2BALL` is a JAX package which provides support for automatically
differentiable and greatly accelerated generalized Fourier transforms on the sphere,
rotation group, and ball. Furthermore, we support extremely efficient and differentiable
Wigner-Laguerre wavelets which can be up to 22,000 times faster
than their ``C`` counterparts, discussed in related works by `Leistedt & McEwen 2012
`_ and `Price & McEwen 2021 `_.
The transforms `S2BALL` provides are optimally fast but come with a substantial memory
overhead and cannot be used above a harmonic bandlimit of L ~ 256, at least with current GPU memory
limitations. That being said, many applications are more than comfortable at these resolutions, for
which these JAX transforms are ideally suited, *e.g.* geophysical modelling, diffusion
tensor imaging, multiscale molecular modelling. For those with machine learning in mind,
it should be explicitly noted that these transforms are indeed equivariant to their respective groups.
Wavelet Filters on the Ball :ringed_planet:
--------------------------------------------
The filters `S2BALL` provides were originally derived by `Leistedt & McEwen 2012
`_ and are constructed by tesselating both harmonic space
and the radial half-line with infinitely differentiable Cauchy-Schwartz functions. This tesselation
gives rise to the follow frequency space localisation
|filter_support|
.. |filter_support| image:: ./docs/assets/figures/ball_filter_support.png
:width: 90%
The above is the frequency space localisation of the wavelet filters, however one can also view wavelet filters in pixel space. Visualising these filters is somewhat tricky as the ball is a 3-dimensional surface embedded in 4-dimensional space. We can, however, straightforwardly view a spherical slice of the ball for each radial node
|filter_support_pixel|
.. |filter_support_pixel| image:: ./docs/assets/figures/ball_filter_support_pixelspace.png
:width: 90%
Installation :computer:
---------------------------
The Python dependencies for the `S2BALL` package are listed in the file
`requirements/requirements-core.txt` and will be automatically installed
into the active python environment by `pip `_ when running
.. code-block:: bash
pip install .
from the root directory of the repository. Unit tests can then be
executed to ensure the installation was successful by running
.. code-block:: bash
pytest tests/
Alternatively, the `S2BALL` package may be installed directly from PyPi by running
.. code-block:: bash
pip install s2ball
Basic Usage :rocket:
---------------------------
To apply the generalised Fourier transforms supported by `S2BALL` one need only
import the package and apply the respective transform, which is as simple as doing the
following:
.. code-block:: Python
from s2ball.transform import *
import numpy as np
# Load some data
f = np.load("path_to_your_data.npy")
+-------------------------------------------------------+------------------------------------------------------------+
|and for data on the sphere with shape :math:`[L, 2L-1]`|or data on SO(3) with shape :math:`[2N-1, L, 2L-1]` |
| | |
|.. code-block:: Python |.. code-block:: Python |
| | |
| L = L | L = L; N = N |
| | |
| # Compute harmonic coefficients | # Compute Wigner coefficients |
| flm = harmonic.forward(f, L) | flmn = wigner.forward(f, L, N) |
| | |
| # Sythensise signal f | # Sythensise signal f |
| f = harmonic.inverse(flm, L) | f = wigner.inverse(flmn, L, N) |
+-------------------------------------------------------+------------------------------------------------------------+
+---------------------------------------------------+---------------------------------------------------------+
|or data on the ball with shape :math:`[P, L, 2L-1]`|or with shape :math:`[P, 2N-1, L, 2L-1]` |
| | |
|.. code-block:: Python |.. code-block:: Python |
| | |
| L = L; P = P | L = L; N = N; P = P |
| | |
| # Compute spherical-Laguerre coefficients | # Compute Wigner coefficients |
| flmp = laguerre.forward(f, L, P) | flmnp = wigner_laguerre.forward(f, L, N, P) |
| | |
| # Sythensise signal f | # Sythensise signal f |
| f = laguerre.inverse(flmp, L, P) | f = wigner_laguerre.inverse(flmnp, L, N, P) |
+---------------------------------------------------+---------------------------------------------------------+
However, for repeated application of these transforms it is optimal to instead precompile
various kernels which can be placed on device to minimise i/o during *e.g.* training. This
operational mode can be seen throughout our examples, found `here
`_.
Computational Benchmarking :hourglass_flowing_sand:
--------------------------------------------------
The various generalized Fourier and wavelet transforms supported by `S2BALL` were
benchmarked against their ``C`` counterparts over a variety of parameter configurations.
Each benchmark has been averaged over many runs, though here we provide only the mean.
All CPU based operations were executed on a single core from a AMD EPYC 7702 64-core
processor, whereas all JAX operations were executed on a single NVIDIA A100 graphics
processing unit. The Jupyter notebooks for each benchmark can be found `here
`_.
Note that benchmarking is restricted to scalar (spin 0 ) fields, though spin is supported
throughout `S2BALL`. Further note that for Wigner tests we set N=5, and in our
Laguerre and wavelet benchmarking we set N=1, as FLAG/FLAGLET otherwise take
excessive compute. Finally, `S2BALL` transforms trivially support batching and
so can, in many cases, gain several more orders of magnitude acceleration.
|harmonic| |wigner|
|laguerre| |wavelet|
.. |harmonic| image:: ./docs/assets/figures/harmonic.png
:width: 48%
.. |wigner| image:: ./docs/assets/figures/wigner.png
:width: 48%
.. |laguerre| image:: ./docs/assets/figures/laguerre.png
:width: 48%
.. |wavelet| image:: ./docs/assets/figures/wavelet.png
:width: 48%
Contributors ✨
-----------------------------------
Thanks goes to these wonderful people (`emoji
key `_):
.. raw:: html
Attribution :books:
-------------------
Should this code be used in any way, we kindly request that the following article is
referenced. A BibTeX entry for this reference may look like:
.. code-block::
@article{price:s2ball,
author = "Matthew A. Price and Alicja Polanska and Jessica Whitney and Jason D. McEwen",
title = "Differentiable and accelerated directional wavelet transform on the sphere and ball",
year = "2024",
eprint = "arXiv:2402.01282"
}
This work is provided as part of a collection of `JAX` harmonic analysis packages which include
.. code-block::
@article{price:s2fft,
author = "Matthew A. Price and Jason D. McEwen",
title = "Differentiable and accelerated spherical harmonic and Wigner transforms",
journal = "Journal of Computational Physics, submitted",
year = "2023",
eprint = "arXiv:2311.14670"
}
You might also like to consider citing our related papers on which this code builds:
.. code-block::
@article{leistedt:flaglets,
author = "Boris Leistedt and Jason D. McEwen",
title = "Exact wavelets on the ball",
journal = "IEEE Trans. Sig. Proc.",
year = "2012",
volume = "60",
number = "12",
pages = "6257--6269",
eprint = "arXiv:1205.0792",
doi = "110.1109/TSP.2012.2215030"
}
.. code-block::
@article{mcewen:fssht,
author = "Jason D. McEwen and Yves Wiaux",
title = "A novel sampling theorem on the sphere",
journal = "IEEE Trans. Sig. Proc.",
year = "2011",
volume = "59",
number = "12",
pages = "5876--5887",
eprint = "arXiv:1110.6298",
doi = "10.1109/TSP.2011.2166394"
}
.. code-block::
@article{mcewen:so3,
author = "Jason D. McEwen and Martin B{\"u}ttner and Boris ~Leistedt and Hiranya V. Peiris and Yves Wiaux",
title = "A novel sampling theorem on the rotation group",
journal = "IEEE Sig. Proc. Let.",
year = "2015",
volume = "22",
number = "12",
pages = "2425--2429",
eprint = "arXiv:1508.03101",
doi = "10.1109/LSP.2015.2490676"
}
License :memo:
---------------
`S2BALL` is released under the MIT license (see `LICENSE.txt `_).
.. code-block::
We provide this code under an MIT open-source licence with the hope that it will be of use to a wider community.
Copyright 2024 Matthew Price, Jason McEwen and contributors.
`S2BALL` is free software made available under the MIT License. For details see the LICENSE file.
Owner
- Name: AstroInfo Team @ UCL
- Login: astro-informatics
- Kind: organization
- Location: United Kingdom
- Website: http://www.jasonmcewen.org/
- Repositories: 29
- Profile: https://github.com/astro-informatics
GitHub Events
Total
- Watch event: 1
Last Year
- Watch event: 1
Dependencies
.github/workflows/docs.yml
actions
- JamesIves/github-pages-deploy-action 4.1.5 composite
- actions/checkout v2.3.1 composite
- actions/setup-python v2 composite
.github/workflows/tests.yml
actions
- actions/checkout v2.3.1 composite
- actions/setup-python v2 composite
requirements/requirements-core.txt
pypi
- colorlog *
- jax >=0.3.13
- jaxlib *
- numpy >=1.20
- pyssht *
- pyyaml *
requirements/requirements-docs.txt
pypi
- ipython >=7.16.1
- jupyter >=1.0.0
- nbsphinx-link >=1.3.0
- pydata-sphinx-theme >=0.12.0
- sphinx >=5.0.0
- sphinx-copybutton *
- sphinx-git >=11.0.0
- sphinx-tabs >=3.2.0
- sphinx_rtd_theme *
- sphinx_toolbox >=2.15.0
- sphinxcontrib-bibtex >=2.4.1
- sphinxcontrib-texfigure >=0.1.3
- sphinxemoji *
requirements/requirements-tests.txt
pypi
- codecov * test
- pytest * test
- pytest-cov * test
- so3 * test
setup.py
pypi