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

Array Shape Functions#

s2wav.samples.L0_j(j: int, lam: float = 2.0) int#

Computes the minimum harmonic index supported by the given wavelet scale \(j\).

Parameters:
  • j (int) – Wavelet scale to consider.

  • lam (float, optional) – Wavelet parameter which determines the scale factor between consecutive wavelet scales. Note that \(\lambda = 2\) indicates dyadic wavelets. Defaults to 2.

Raises:

ValueError – Kernel type not supported.

Returns:

The minimum harmonic multipole \(el\) which is supported by a given wavelet scale.

Return type:

int

s2wav.samples.LN_j(L: int, j: int = 0, N: int = 1, lam: float = 2.0, multiresolution: bool = False) Tuple[int, int]#

Computes the harmonic bandlimit and directionality for scale \(j\).

Parameters:
  • L (int) – Harmonic bandlimit.

  • j (int) – Wavelet scale to consider.

  • N (int, optional) – Upper orientational band-limit. Defaults to 1.

  • lam (float, optional) – Wavelet parameter which determines the scale factor between consecutive wavelet scales. Note that \(\lambda = 2\) indicates dyadic wavelets. Defaults to 2.

  • sampling (str, optional) – Spherical sampling scheme from {“mw”, “mwss”, “dh”, “gl”, “healpix”}. Defaults to “mw”.

  • multiresolution (bool, optional) – Whether to store the scales at \(j_{\text{max}}\) resolution or its own resolution. Defaults to False.

Returns:

Total number of wavelet scales \(n_{j}\).

Return type:

int

s2wav.samples.binomial_coefficient(n: int, k: int) int#

Computes the binomial coefficient \(\binom{n}{k}\).

Parameters:
  • n (int) – Number of elements to choose from.

  • k (int) – Number of elements to pick.

Returns:

Number of possible subsets.

Return type:

(int)

s2wav.samples.binomial_coefficient_jax(n: int, k: int) int#

Computes the binomial coefficient \(\binom{n}{k}\).

Parameters:
  • n (int) – Number of elements to choose from.

  • k (int) – Number of elements to pick.

Returns:

Number of possible subsets.

Return type:

(int)

s2wav.samples.construct_f(L: int, N: int = 1, J_min: int = 0, lam: float = 2.0, sampling: str = 'mw', nside: int | None = None, multiresolution: bool = False, scattering: bool = False) ndarray#

Defines a list of arrays corresponding to f_wav.

Parameters:
  • L (int) – Harmonic bandlimit.

  • N (int, optional) – Upper orientational band-limit. Defaults to 1.

  • J_min (int, optional) – Lowest frequency wavelet scale to be used. Defaults to 0.

  • lam (float, optional) – Wavelet parameter which determines the scale factor between consecutive wavelet scales. Note that \(\lambda = 2\) indicates dyadic wavelets. Defaults to 2.

  • sampling (str, optional) – Spherical sampling scheme from {“mw”, “mwss”, “dh”, “gl”, “healpix”}. Defaults to “mw”.

  • nside (int, optional) – HEALPix Nside resolution parameter. Only required if sampling=”healpix”. Defaults to None.

  • multiresolution (bool, optional) – Whether to store the scales at \(j_{ ext{max}}\) resolution or its own resolution. Defaults to False.

  • scattering (bool, optional) – Whether to create minimal arrays for scattering transform to optimise for memory. Defaults to False.

Returns:

Empty array (or list of empty arrays) in which to write data.

Return type:

np.ndarray

s2wav.samples.construct_f_jax(L: int, J_min: int = 0, J_max: int = None, lam: float = 2.0) List#

Defines a list corresponding to f_wav.

Parameters:
  • L (int) – Harmonic bandlimit.

  • J_min (int, optional) – Lowest frequency wavelet scale to be used. Defaults to 0.

  • J_max (int, optional) – Highest frequency wavelet scale to be used. Defaults to None.

  • lam (float, optional) – Wavelet parameter which determines the scale factor between consecutive wavelet scales. Note that \(\lambda = 2\) indicates dyadic wavelets. Defaults to 2.

Returns:

Empty list in which to write data.

Return type:

List

s2wav.samples.construct_f_torch(L: int, J_min: int = 0, J_max: int | None = None, lam: float = 2.0) List#

Defines a list corresponding to f_wav.

Parameters:
  • L (int) – Harmonic bandlimit.

  • J_min (int, optional) – Lowest frequency wavelet scale to be used. Defaults to 0.

  • J_max (int, optional) – Highest frequency wavelet scale to be used. Defaults to None.

  • lam (float, optional) – Wavelet parameter which determines the scale factor between consecutive wavelet scales. Note that \(\lambda = 2\) indicates dyadic wavelets. Defaults to 2.

Returns:

Empty list in which to write data.

Return type:

List

s2wav.samples.construct_flm(L: int, J_min: int = 0, lam: float = 2.0, multiresolution: bool = False) Tuple[int, int]#

Returns the shape of scaling coefficients in harmonic space.

Parameters:
  • L (int) – Harmonic bandlimit.

  • J_min (int, optional) – Lowest frequency wavelet scale to be used. Defaults to 0.

  • lam (float, optional) – Wavelet parameter which determines the scale factor between consecutive wavelet scales. Note that \(\lambda = 2\) indicates dyadic wavelets. Defaults to 2.

  • multiresolution (bool, optional) – Whether to store the scales at \(j_{\text{max}}\) resolution or its own resolution. Defaults to False.

Returns:

Scaling coefficients shape \([L, 2L-1]\).

Return type:

Tuple[int, int]

s2wav.samples.construct_flm_jax(L: int, J_min: int = 0, lam: float = 2.0, multiresolution: bool = False) Tuple[int, int]#

Returns the shape of scaling coefficients in harmonic space.

Parameters:
  • L (int) – Harmonic bandlimit.

  • J_min (int, optional) – Lowest frequency wavelet scale to be used. Defaults to 0.

  • lam (float, optional) – Wavelet parameter which determines the scale factor between consecutive wavelet scales. Note that \(\lambda = 2\) indicates dyadic wavelets. Defaults to 2.

  • multiresolution (bool, optional) – Whether to store the scales at \(j_{\text{max}}\) resolution or its own resolution. Defaults to False.

Returns:

Scaling coefficients shape \([L, 2L-1]\).

Return type:

Tuple[int, int]

s2wav.samples.construct_flmn(L: int, N: int = 1, J_min: int = 0, lam: float = 2.0, multiresolution: bool = False, scattering: bool = False) ndarray#

Defines a list of arrays corresponding to flmn.

Parameters:
  • L (int) – Harmonic bandlimit.

  • N (int, optional) – Upper orientational band-limit. Defaults to 1.

  • J_min (int, optional) – Lowest frequency wavelet scale to be used. Defaults to 0.

  • lam (float, optional) – Wavelet parameter which determines the scale factor between consecutive wavelet scales. Note that \(\lambda = 2\) indicates dyadic wavelets. Defaults to 2.

  • multiresolution (bool, optional) – Whether to store the scales at \(j_{ ext{max}}\) resolution or its own resolution. Defaults to False.

  • scattering (bool, optional) – Whether to create minimal arrays for scattering transform to optimise for memory. Defaults to False.

Returns:

Empty array (or list of empty arrays) in which to write data.

Return type:

np.ndarray

s2wav.samples.construct_flmn_jax(L: int, N: int = 1, J_min: int = 0, J_max: int = None, lam: float = 2.0, multiresolution: bool = False) Array#

Defines a list of arrays corresponding to flmn.

Parameters:
  • L (int) – Harmonic bandlimit.

  • N (int, optional) – Upper orientational band-limit. Defaults to 1.

  • J_min (int, optional) – Lowest frequency wavelet scale to be used. Defaults to 0.

  • J_max (int, optional) – Highest frequency wavelet scale to be used. Defaults to None.c

  • lam (float, optional) – Wavelet parameter which determines the scale factor between consecutive wavelet scales. Note that \(\lambda = 2\) indicates dyadic wavelets. Defaults to 2.

  • multiresolution (bool, optional) – Whether to store the scales at \(j_{ ext{max}}\) resolution or its own resolution. Defaults to False.

Returns:

Empty array (or list of empty arrays) in which to write data.

Return type:

jnp.ndarray

s2wav.samples.construct_flmn_torch(L: int, N: int = 1, J_min: int = 0, J_max: int | None = None, lam: float = 2.0, multiresolution: bool = False) tensor#

Defines a list of tensors corresponding to flmn.

Parameters:
  • L (int) – Harmonic bandlimit.

  • N (int, optional) – Upper orientational band-limit. Defaults to 1.

  • J_min (int, optional) – Lowest frequency wavelet scale to be used. Defaults to 0.

  • J_max (int, optional) – Highest frequency wavelet scale to be used. Defaults to None.c

  • lam (float, optional) – Wavelet parameter which determines the scale factor between consecutive wavelet scales. Note that \(\lambda = 2\) indicates dyadic wavelets. Defaults to 2.

  • multiresolution (bool, optional) – Whether to store the scales at \(j_{ ext{max}}\) resolution or its own resolution. Defaults to False.

Returns:

Empty tensor (or list of empty tensors) in which to write data.

Return type:

torch.tensor

s2wav.samples.f_scal(L: int, J_min: int = 0, lam: float = 2.0, sampling: str = 'mw', nside: int | None = None, multiresolution: bool = False) Tuple[int, int]#

Computes the shape of scaling coefficients in pixel-space.

Parameters:
  • L (int) – Harmonic bandlimit.

  • J_min (int, optional) – Lowest frequency wavelet scale to be used. Defaults to 0.

  • lam (float, optional) – Wavelet parameter which determines the scale factor between consecutive wavelet scales. Note that \(\lambda = 2\) indicates dyadic wavelets. Defaults to 2.

  • sampling (str, optional) – Spherical sampling scheme from {“mw”,”mwss”, “dh”, “gl”, “healpix”}. Defaults to “mw”.

  • nside (int, optional) – HEALPix Nside resolution parameter. Only required if sampling=”healpix”. Defaults to None.

  • multiresolution (bool, optional) – Whether to store the scales at \(j_{\text{max}}\) resolution or its own resolution. Defaults to False.

Returns:

Scaling coefficients shape \([n_{\theta}, n_{\phi}]\).

Return type:

Tuple[int, int]

s2wav.samples.f_wav_j(L: int, j: int = 0, N: int = 1, lam: float = 2.0, sampling: str = 'mw', nside: int | None = None, multiresolution: bool = False) Tuple[int, int, int]#

Computes the shape of wavelet coefficients \(f^j\) in pixel-space.

Parameters:
  • L (int) – Harmonic bandlimit.

  • j (int) – Wavelet scale to consider.

  • N (int, optional) – Upper orientational band-limit. Defaults to 1.

  • lam (float, optional) – Wavelet parameter which determines the scale factor between consecutive wavelet scales. Note that \(\lambda = 2\) indicates dyadic wavelets. Defaults to 2.

  • sampling (str, optional) – Spherical sampling scheme from {“mw”, “mwss”, “dh”, “gl”, “healpix”}. Defaults to “mw”.

  • nside (int, optional) – HEALPix Nside resolution parameter. Only required if sampling=”healpix”. Defaults to None.

  • multiresolution (bool, optional) – Whether to store the scales at \(j_{\text{max}}\) resolution or its own resolution. Defaults to False.

Returns:

Wavelet coefficients shape \([n_{N}, n_{\theta}, n_{\phi}]\).

Return type:

Tuple[int, int, int]

Note

Each wavelet filter has compact support between a lower and upper harmonic degree. Therefore it is possible to conserve information with only a fraction of the data per scale \(j\). As each scale \(j\) has a different shape the overall wavelet coefficients are stored as a list of arrays, this being the shape of one array within such a list.

s2wav.samples.flmn_wav_j(L: int, j: int, N: int = 1, lam: float = 2.0, multiresolution: bool = False) Tuple[int, int, int]#

Returns the shape of wavelet coefficients \(f^j_{\ell m n}\) in Wigner space.

Parameters:
  • L (int) – Harmonic bandlimit.

  • j (int) – Wavelet scale to consider.

  • N (int, optional) – Upper orientational band-limit. Defaults to 1.

  • lam (float, optional) – Wavelet parameter which determines the scale factor between consecutive wavelet scales. Note that \(\lambda = 2\) indicates dyadic wavelets. Defaults to 2.

  • multiresolution (bool, optional) – Whether to store the scales at \(j_{\text{max}}\) resolution or its own resolution. Defaults to False.

Returns:

Wavelet coefficients shape \([n_{N}, L, 2L-1]\).

Return type:

Tuple[int, int, int]

Note

Each wavelet filter has compact support between a lower and upper harmonic degree. Therefore it is possible to conserve information with only a fraction of the data per scale \(j\). As each scale \(j\) has a different shape the overall wavelet coefficients are stored as a list of arrays, this being the shape of one array within such a list.

s2wav.samples.j_max(L: int, lam: float = 2.0) int#

Computes needlet maximum level required to ensure exact reconstruction.

Parameters:
  • L (int) – Harmonic band-limit.

  • lam (float, optional) – Wavelet parameter which determines the scale factor between consecutive wavelet scales. Note that \(\lambda = 2\) indicates dyadic wavelets. Defaults to 2.

Returns:

The maximum wavelet scale used.

Return type:

int

s2wav.samples.n_wav_scales(L: int, N: int = 1, J_min: int = 0, lam: float = 2.0) int#

Evalutes the total number of wavelet scales.

Parameters:
  • L (int) – Harmonic bandlimit.

  • N (int, optional) – Upper orientational band-limit. Defaults to 1.

  • J_min (int, optional) – Lowest frequency wavelet scale to be used. Defaults to 0.

  • lam (float, optional) – Wavelet parameter which determines the scale factor between consecutive wavelet scales. Note that \(\lambda = 2\) indicates dyadic wavelets. Defaults to 2.

  • sampling (str, optional) – Spherical sampling scheme from {“mw”, “mwss”, “dh”, “gl”, “healpix”}. Defaults to “mw”.

Returns:

Total number of wavelet scales \(n_{j}\).

Return type:

int

s2wav.samples.scal_bandlimit(L: int, J_min: int = 0, lam: float = 2.0, multiresolution: bool = False) int#

Returns the harmominc bandlimit of the scaling coefficients.

Parameters:
  • L (int) – Harmonic bandlimit.

  • J_min (int, optional) – Lowest frequency wavelet scale to be used. Defaults to 0.

  • lam (float, optional) – Wavelet parameter which determines the scale factor between consecutive wavelet scales. Note that \(\lambda = 2\) indicates dyadic wavelets. Defaults to 2.

  • multiresolution (bool, optional) – Whether to store the scales at \(j_{\text{max}}\) resolution or its own resolution. Defaults to False.

Returns:

Harmonic bandlimit of scaling coefficients.

Return type:

int

s2wav.samples.wav_j_bandlimit(L: int, j: int, lam: float = 2.0, multiresolution: bool = False) int#

Returns the harmominc bandlimit of the scaling coefficients.

Parameters:
  • L (int) – Harmonic bandlimit.

  • j (int) – Wavelet scale to consider.

  • lam (float, optional) – Wavelet parameter which determines the scale factor between consecutive wavelet scales. Note that \(\lambda = 2\) indicates dyadic wavelets. Defaults to 2.

  • multiresolution (bool, optional) – Whether to store the scales at \(j_{\text{max}}\) resolution or its own resolution. Defaults to False.

Returns:

Harmonic bandlimit of scaling coefficients.

Return type:

int

s2wav.samples.wavelet_shape_check(f_w: ndarray, f_s: ndarray, L: int, N: int = 1, J_min: int = 0, lam: float = 2.0, sampling: str = 'mw', nside: int | None = None, multiresolution: bool = False)#

Checks the shape of wavelet coefficients are correct.

If multiresolution is true, this check will iterate over each scale ensuring that each scale \(j\) is correctly bandlimited at \(\lambda^j\).

Parameters:
  • f_w (np.ndarray) – Array of wavelet pixel-space coefficients with shape \([n_{J}, 2N-1, n_{\theta}, n_{\phi}]\).

  • f_s (np.ndarray) – Array of scaling pixel-space coefficients with shape \([n_{\theta}, n_{\phi}]\).

  • L (int) – Harmonic bandlimit.

  • j (int) – Wavelet scale to consider.

  • N (int, optional) – Upper orientational band-limit. Defaults to 1.

  • lam (float, optional) – Wavelet parameter which determines the scale factor between consecutive wavelet scales. Note that \(\lambda = 2\) indicates dyadic wavelets. Defaults to 2.

  • sampling (str, optional) – Spherical sampling scheme from {“mw”, “mwss”, “dh”, “gl”, “healpix”}. Defaults to “mw”.

  • nside (int, optional) – HEALPix Nside resolution parameter. Only required if sampling=”healpix”. Defaults to None.

  • multiresolution (bool, optional) – Whether to store the scales at \(j_{\text{max}}\) resolution or its own resolution. Defaults to False.