s2fft is currently in an open beta, please provide feedback on GitHub

Spherical Harmonic Transform#

s2fft.precompute_transforms.spherical.forward(f: ndarray, L: int, spin: int = 0, kernel: ndarray | None = None, sampling: str = 'mw', reality: bool = False, method: str = 'jax', nside: int | None = None) ndarray#

Compute the forward spherical harmonic transform via precompute.

Parameters:
  • f (np.ndarray) – Signal on the sphere.

  • L (int) – Harmonic band-limit.

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

  • kernel (np.ndarray, optional) – Wigner-d kernel. Defaults to None.

  • sampling (str, optional) – Sampling scheme. Supported sampling schemes include {“mw”, “mwss”, “dh”, “gl”, “healpix”}. Defaults to “mw”.

  • reality (bool, optional) – Whether the signal on the sphere is real. If so, conjugate symmetry is exploited to reduce computational costs. Defaults to False.

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

  • nside (int) – HEALPix Nside resolution parameter. Only required if sampling=”healpix”.

Raises:
  • ValueError – Transform method not recognised.

  • Warning – Reality set but field is != spin 0 = complex.

Returns:

Spherical harmonic coefficients.

Return type:

np.ndarray

s2fft.precompute_transforms.spherical.forward_transform(f: ndarray, kernel: ndarray, L: int, sampling: str, reality: bool, spin: int, nside: int) ndarray#

Compute the forward spherical harmonic transform via precompute (vectorized implementation).

Parameters:
  • f (np.ndarray) – Signal on the sphere.

  • kernel (np.ndarray) – Wigner-d kernel.

  • L (int) – Harmonic band-limit.

  • sampling (str) – Sampling scheme. Supported sampling schemes include {“mw”, “mwss”, “dh”, “gl”, “healpix”}.

  • reality (bool, optional) – Whether the signal on the sphere is real. If so, conjugate symmetry is exploited to reduce computational costs.

  • spin (int) – Harmonic spin.

  • nside (int) – HEALPix Nside resolution parameter. Only required if sampling=”healpix”.

Returns:

Pixel-space coefficients.

Return type:

np.ndarray

s2fft.precompute_transforms.spherical.forward_transform_jax(f: Array, kernel: Array, L: int, sampling: str, reality: bool, spin: int, nside: int) Array#

Compute the forward spherical harmonic tranclearsform via precompute (vectorized implementation).

Parameters:
  • f (jnp.ndarray) – Signal on the sphere.

  • kernel (jnp.ndarray) – Wigner-d kernel.

  • L (int) – Harmonic band-limit.

  • sampling (str) – Sampling scheme. Supported sampling schemes include {“mw”, “mwss”, “dh”, “gl”, “healpix”}.

  • reality (bool, optional) – Whether the signal on the sphere is real. If so, conjugate symmetry is exploited to reduce computational costs.

  • spin (int) – Harmonic spin.

  • nside (int) – HEALPix Nside resolution parameter. Only required if sampling=”healpix”.

Returns:

Pixel-space coefficients.

Return type:

jnp.ndarray

s2fft.precompute_transforms.spherical.forward_transform_torch(f: tensor, kernel: tensor, L: int, sampling: str, reality: bool, spin: int, nside: int) tensor#

Compute the forward spherical harmonic tranclearsform via precompute (vectorized implementation).

Parameters:
  • f (torch.tensor) – Signal on the sphere.

  • kernel (torch.tensor) – Wigner-d kernel.

  • L (int) – Harmonic band-limit.

  • sampling (str) – Sampling scheme. Supported sampling schemes include {“mw”, “mwss”, “dh”, “healpix”}.

  • reality (bool, optional) – Whether the signal on the sphere is real. If so, conjugate symmetry is exploited to reduce computational costs.

  • spin (int) – Harmonic spin.

  • nside (int) – HEALPix Nside resolution parameter. Only required if sampling=”healpix”.

Returns:

Pixel-space coefficients.

Return type:

torch.tensor

s2fft.precompute_transforms.spherical.inverse(flm: ndarray, L: int, spin: int = 0, kernel: ndarray | None = None, sampling: str = 'mw', reality: bool = False, method: str = 'jax', nside: int | None = None) ndarray#

Compute the inverse spherical harmonic transform via precompute.

Parameters:
  • flm (np.ndarray) – Spherical harmonic coefficients.

  • L (int) – Harmonic band-limit.

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

  • kernel (np.ndarray, optional) – Wigner-d kernel. Defaults to None.

  • sampling (str, optional) – Sampling scheme. Supported sampling schemes include {“mw”, “mwss”, “dh”, “gl”, “healpix”}. Defaults to “mw”.

  • reality (bool, optional) – Whether the signal on the sphere is real. If so, conjugate symmetry is exploited to reduce computational costs. Defaults to False.

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

  • nside (int) – HEALPix Nside resolution parameter. Only required if sampling=”healpix”.

Raises:
  • ValueError – Transform method not recognised.

  • Warning – Reality set but field is != spin 0 = complex.

Returns:

Pixel-space coefficients with shape.

Return type:

np.ndarray

s2fft.precompute_transforms.spherical.inverse_transform(flm: ndarray, kernel: ndarray, L: int, sampling: str, reality: bool, spin: int, nside: int) ndarray#

Compute the forward spherical harmonic transform via precompute (vectorized implementation).

Parameters:
  • flm (np.ndarray) – Spherical harmonic coefficients.

  • kernel (np.ndarray) – Wigner-d kernel.

  • L (int) – Harmonic band-limit.

  • sampling (str) – Sampling scheme. Supported sampling schemes include {“mw”, “mwss”, “dh”, “gl”, “healpix”}.

  • reality (bool, optional) – Whether the signal on the sphere is real. If so, conjugate symmetry is exploited to reduce computational costs.

  • spin (int) – Harmonic spin.

  • nside (int) – HEALPix Nside resolution parameter. Only required if sampling=”healpix”.

Returns:

Pixel-space coefficients.

Return type:

np.ndarray

s2fft.precompute_transforms.spherical.inverse_transform_jax(flm: Array, kernel: Array, L: int, sampling: str, reality: bool, spin: int, nside: int) Array#

Compute the inverse spherical harmonic transform via precompute (JAX implementation).

Parameters:
  • flm (jnp.ndarray) – Spherical harmonic coefficients.

  • kernel (jnp.ndarray) – Wigner-d kernel.

  • L (int) – Harmonic band-limit.

  • sampling (str) – Sampling scheme. Supported sampling schemes include {“mw”, “mwss”, “dh”, “gl”, “healpix”}.

  • reality (bool, optional) – Whether the signal on the sphere is real. If so, conjugate symmetry is exploited to reduce computational costs.

  • spin (int) – Harmonic spin.

  • nside (int) – HEALPix Nside resolution parameter. Only required if sampling=”healpix”.

Returns:

Pixel-space coefficients with shape.

Return type:

jnp.ndarray

s2fft.precompute_transforms.spherical.inverse_transform_torch(flm: tensor, kernel: tensor, L: int, sampling: str, reality: bool, spin: int, nside: int) tensor#

Compute the inverse spherical harmonic transform via precompute (Torch implementation).

Parameters:
  • flm (torch.tensor) – Spherical harmonic coefficients.

  • kernel (torch.tensor) – Wigner-d kernel.

  • L (int) – Harmonic band-limit.

  • sampling (str) – Sampling scheme. Supported sampling schemes include {“mw”, “mwss”, “dh”, “healpix”}.

  • reality (bool, optional) – Whether the signal on the sphere is real. If so, conjugate symmetry is exploited to reduce computational costs.

  • spin (int) – Harmonic spin.

  • nside (int) – HEALPix Nside resolution parameter. Only required if sampling=”healpix”.

Returns:

Pixel-space coefficients with shape.

Return type:

torch.tensor