s2ball is currently in an open alpha, please provide feedback on GitHub

Spherical harmonic#

s2ball.transform.harmonic.forward(f: ndarray, L: int, legendre_matrices: ndarray | None = None, method: str = 'jax', spin: int = 0, save_dir: str = '.matrices', adjoint: bool = False) ndarray#

Compute forward spherical harmonic transform.

This transform trivially supports batching.

Parameters:
  • f (np.ndarray) – Signal on sphere, with shape: [L, 2L-1].

  • L (int) – Harmonic band-limit.

  • legendre_matrices (np.ndarray, optional) – List of Legendre transform matrices. Defaults to None.

  • method (str, optional) – Evaluation method in {“numpy”, “jax”}. Defaults to “jax”.

  • spin (int, optional) – Harmonic spin. Defaults to 0.

  • save_dir (str, optional) – Directory in which to save precomputed matrices. Defaults to “.matrices”.

  • adjoint (bool, optional) – Whether to return adjoint transformation. Defaults to False.

Returns:

Spherical harmonic coefficients with shape [L, 2L-1].

Return type:

np.ndarray

Raises:

ValueError – Deployment method not in {“numpy”, “jax”}.

Note

Currently only McEwen-Wauix sampling on the sphere is supported, though this approach can be extended to alternate sampling schemes, e.g. HEALPix.

s2ball.transform.harmonic.forward_transform(f: ndarray, legendre_matrices: ndarray, shift: int = 0) ndarray#

Compute the forward spherical harmonic transform with Numpy.

This transform trivially supports batching.

Parameters:
  • f (np.ndarray) – Signal on sphere, with shape: [L, 2L-1].

  • legendre_matrices (np.ndarray) – List of Legendre transform matrices.

  • shift (int, optional) – Used internally to handle adjoint transforms.

Returns:

Spherical harmonic coefficients with shape [L, 2L-1].

Return type:

np.ndarray

Note

Currently only McEwen-Wauix sampling on the sphere is supported, though this approach can be extended to alternate sampling schemes, e.g. HEALPix.

s2ball.transform.harmonic.forward_transform_jax(f: Array, legendre_matrices: Array, shift: int = 0) Array#

Compute the forward spherical harmonic transform with JAX and JIT.

This transform trivially supports batching.

Parameters:
  • f (jnp.ndarray) – Signal on sphere, with shape: [L, 2L-1].

  • legendre_matrices (jnp.ndarray) – Legendre transform kernel.

  • shift (int, optional) – Used internally to handle adjoint transforms.

Returns:

Spherical harmonic coefficients with shape [L, 2L-1].

Return type:

jnp.ndarray

Note

Currently only McEwen-Wauix sampling on the sphere is supported, though this approach can be extended to alternate sampling schemes, e.g. HEALPix.

s2ball.transform.harmonic.inverse(flm: ndarray, L: int, legendre_matrices: ndarray | None = None, method: str = 'jax', spin: int = 0, save_dir: str = '.matrices', adjoint: bool = False) ndarray#

Compute the inverse spherical harmonic transform.

This transform trivially supports batching.

Parameters:
  • flm (np.ndarray) – Harmonic coefficients, with shape: [L, 2L-1].

  • L (int) – Harmonic band-limit.

  • legendre_matrices (np.ndarray, optional) – List of Legendre transform matrices. Defaults to None.

  • method (str, optional) – Evaluation method in {“numpy”, “jax”}. Defaults to “jax”.

  • spin (int, optional) – Harmonic spin. Defaults to 0.

  • save_dir (str, optional) – Directory in which to save precomputed matrices. Defaults to “.matrices”.

  • adjoint (bool, optional) – Whether to return adjoint transformation. Defaults to False.

Returns:

Pixel-space coefficients with shape [L, 2L-1].

Return type:

np.ndarray

Note

Currently only McEwen-Wauix sampling on the sphere is supported, though this approach can be extended to alternate sampling schemes, e.g. HEALPix.

s2ball.transform.harmonic.inverse_transform(flm: ndarray, legendre_matrices: ndarray, shift: int = 0)#

Compute the inverse spherical harmonic transform with Numpy.

This transform trivially supports batching.

Parameters:
  • flm (np.ndarray) – Harmonic coefficients, with shape: [L, 2L-1].

  • legendre_matrices (np.ndarray) – List of Legendre transform matrices.

  • shift (int, optional) – Used internally to handle adjoint transforms.

Returns:

Pixel-space coefficients with shape [L, 2L-1].

Return type:

np.ndarray

Note

Currently only McEwen-Wauix sampling on the sphere is supported, though this approach can be extended to alternate sampling schemes, e.g. HEALPix.

s2ball.transform.harmonic.inverse_transform_jax(flm: Array, legendre_matrices: Array, shift: int = 0) Array#

Compute the inverse spherical harmonic transform via with JAX and JIT.

This transform trivially supports batching.

Parameters:
  • flm (jnp.ndarray) – Harmonic coefficients, with shape: [L, 2L-1].

  • legendre_matrices (jnp.ndarray) – List of Legendre transform matrices.

  • shift (int, optional) – Used internally to handle adjoint transforms.

Returns:

Pixel-space coefficients with shape [L, 2L-1].

Return type:

jnp.ndarray

Note

Currently only McEwen-Wauix sampling on the sphere is supported, though this approach can be extended to alternate sampling schemes, e.g. HEALPix.