GithubHelp home page GithubHelp logo

astro-informatics / s2wav Goto Github PK

View Code? Open in Web Editor NEW
12.0 3.0 0.0 11.93 MB

Differentiable and accelerated wavelet transform on the sphere with JAX

Home Page: https://astro-informatics.github.io/s2wav/

License: MIT License

Jupyter Notebook 10.51% Python 89.49%
dictionary differentiable-programming jax sphere spherical-harmonics wavelet-transform

s2wav's Introduction

image image image image image All Contributors Open In Colab

Differentiable and accelerated wavelet transform on the sphere

S2WAV is a python package for computing wavelet transforms on the sphere and rotation group, both in JAX and PyTorch. It leverages autodiff to provide differentiable transforms, which are also deployable on modern hardware accelerators (e.g. GPUs and TPUs), and can be mapped across multiple accelerators.

More specifically, S2WAV provides support for scale-discretised wavelet transforms on the sphere and rotation group (for both real and complex signals), with support for adjoints where needed, and comes with a variety of different optimisations (e.g. precompute or not, multi-resolution algorithms) that one may select depending on available resources and desired angular resolution $L$. S2WAV is a sister package of S2FFT, both of which are part of the SAX project, which aims to provide comprehensive support for differentiable transforms on the sphere and rotation group.

Tip

As of version 1.0.0 S2WAV also provides partial frontend support for PyTorch. In future this will be expanded to full support. Also note that this release also provides JAX support for existing C spherical harmonic libraries, specifically SSHT. This works be wrapping python bindings with custom JAX frontends. Note that currently this C to JAX interoperability is limited to CPU.

Wavelet Transform โšก

S2WAV is an updated implementation of the scale-discretised wavelet transform on the sphere, which builds upon the papers of Leistedt et al 2013 and McEwen et al 2017. This wavelet transform is designed to have excellent localisation and uncorrelation properties, and has been successfully adopted for various applications e.g. scattering transforms on the sphere McEwen et al 2022. The wavelet dictionary is constructed by tiling the harmonic line with infinitely differentiable Cauchy-Schwartz functions, which can straightforwardly be performed in an efficient multiresolution manner, as in the Euclidean case. This is what the directional wavelet filters look like in pixel space.

Installation ๐Ÿ’ป

The Python dependencies for the S2WAV package are listed in the file requirements/requirements-core.txt and will be automatically installed into the active python environment by pip when running

pip install s2wav     

This will install the core functionality which includes JAX support (including PyTorch support).

Alternatively, the S2WAV package may be installed directly from GitHub by cloning this repository and then running

pip install .

from the root directory.

Unit tests can then be executed to ensure the installation was successful by first installing the test requirements and then running pytest

pip install -r requirements/requirements-tests.txt
pytest tests/  

Documentation for the released version is available here. To build the documentation locally run

pip install -r requirements/requirements-docs.txt
cd docs 
make html
open _build/html/index.html

Usage ๐Ÿš€

To import and use S2WAV is as simple follows:

# Compute wavelet coefficients
f_wav, f_scal = s2wav.analysis(f, L, N)

# Map back to signal on the sphere 
f = s2wav.synthesis(f_wav, f_scal, L, N)

Note

However we strongly recommend that the multiresolution argument is set to true, as this will accelerate the transform by a factor of the total number of wavelet scales, which can be around an order of magnitude.

C JAX Frontends for SSHT ๐Ÿ’ก

S2WAV also provides JAX support for SSHT, which is a highly optimised C library which implements the underlying spherical harmonic transforms. This works by wrapping python bindings with custom JAX frontends. Note that this C to JAX interoperability is currently limited to CPU.

For example, one may call these alternate backends for the spherical wavelet transform by:

# Compute wavelet coefficients using SSHT C library backend
f_wav, f_scal = s2wav.analysis(f, L, N, use_c_backend=True)

# Map back to signal on the sphere using SSHT C library backend
f = s2wav.synthesis(f_wav, f_scal, L, N, use_c_backend=True)

These JAX frontends supports out of the box reverse mode automatic differentiation, and under the hood is simply linking to the C packages you are familiar with. In this way S2fft enhances existing packages with gradient functionality for modern scientific computing or machine learning applications!

For further details on usage see the associated notebooks.

Contributors โœจ

We strongly encourage contributions from any interested developers; a simple example would be adding support for new wavelet filters e.g. spherical needlets Chan et al 2016 or spherical ridgelets McEwen & Price 2020! Thanks goes to these wonderful people (emoji key):

Matt Price
Matt Price

๐Ÿ’ป ๐Ÿ‘€ ๐Ÿ“– ๐ŸŽจ
Jason McEwen
Jason McEwen

๐Ÿ‘€ ๐ŸŽจ
Alicja Polanska
Alicja Polanska

๐Ÿ’ป ๐Ÿ‘€
Jessica Whitney
Jessica Whitney

๐Ÿ’ป ๐Ÿ‘€

Attribution

A BibTeX entry for S2WAV is:

@article{price:s2wav, 
   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"},
   eprint = {arXiv:2402.01282},
     year = {2024}
}

we also request that you cite the following paper

@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"        
}

in which the core underlying algorithms for the spherical harmonic and Wigner transforms are developed.

License ๐Ÿ“

Copyright 2024 Matthew Price, Jessica Whtiney, Alicja Polanska, Jason McEwen and contributors.

S2WAV is free software made available under the MIT License. For details see the LICENSE file.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.