resampling#

s2fft.utils.resampling.downsample_by_two_mwss(f_ext: ndarray, L: int) ndarray#

Downsample an MWSS sampled signal on the sphere.

Can be applied to either MWSS signal sampled on original domain \([0,\pi]\) or extended domain \([0,2\pi]\).

Note

Harmonic band-limit of input sampled signal must be even.

Parameters:
  • f_ext (np.ndarray) – Signal on the sphere sampled with MWSS sampling at resolution L.

  • L (int) – Harmonic band-limit.

Raises:

ValueError – Harmonic band-limit of input signal must be even.

Returns:

Signal on the sphere sampled with MWSS sampling scheme at resolution L/2. L must be even so that L/2 is an integer.

Return type:

np.ndarray

s2fft.utils.resampling.mw_to_mwss(f_mw: ndarray, L: int, spin: int = 0) ndarray#

Convert signal on the sphere from MW sampling to MWSS sampling.

Conversion is performed by first performing a period extension in \(\theta\) to \(2\pi\), followed by zero padding in harmonic space. The resulting signal is then unextend back to the \(\theta\) domain of \([0,\pi]\). Second, zero padding in harmonic space corresponding to \(\phi\) is performed.

Parameters:
  • f_mw (np.ndarray) – Signal on the sphere sampled with MW sampling.

  • L (int) – Harmonic band-limit.

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

Returns:

Signal on the sphere sampled with MWSS sampling.

Return type:

np.ndarray

s2fft.utils.resampling.mw_to_mwss_phi(f_mw: ndarray, L: int) ndarray#

Convert \(\phi\) component of signal on the sphere from MW sampling to MWSS sampling.

Conversion is performed by zero padding in harmonic space.

Note

Can work with arbitrary number of \(\theta\) samples. Hence, to convert both \((\theta,\phi)\) sampling to MWSS, can use mw_to_mwss_theta() to first convert \(\theta\) sampling before using this function to convert the \(\phi\) sampling.

Parameters:
  • f_mw (np.ndarray) – Signal on the sphere sampled with MW sampling in \(\phi\) and arbitrary number of samples in

  • L (int) – Harmonic band-limit.

Raises:

ValueError – Input spherical signal must have number of samples in \(\phi\) matching MW sampling.

Returns:

Signal on the sphere with MWSS sampling in \(\phi\) and sampling in \(\theta\) of the input signal.

Return type:

np.ndarray

s2fft.utils.resampling.mw_to_mwss_theta(f_mw: ndarray, L: int, spin: int = 0) ndarray#

Convert \(\theta\) component of signal on the sphere from MW sampling to MWSS sampling.

Conversion is performed by first performing a period extension in \(\theta\) to \(2\pi\), followed by zero padding in harmonic space. The resulting signal is then unextend back to the \(\theta\) domain of \([0,\pi]\).

Parameters:
  • f_mw (np.ndarray) – Signal on the sphere sampled with MW sampling.

  • L (int) – Harmonic band-limit.

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

Raises:

ValueError – Input spherical signal must have shape matching MW sampling.

Returns:

Signal on the sphere with MWSS sampling in \(\theta\) and MW sampling in \(\phi\).

Return type:

np.ndarray

s2fft.utils.resampling.periodic_extension(f: ndarray, L: int, spin: int = 0, sampling: str = 'mw') ndarray#

Perform period extension of MW/MWSS signal on the sphere in harmonic domain, extending \(\theta\) domain from \([0,\pi]\) to \([0,2\pi]\).

Parameters:
  • f (np.ndarray) – Signal on the sphere sampled with MW/MWSS sampling scheme.

  • L (int) – Harmonic band-limit.

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

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

Raises:

ValueError – Only MW/MWW sampling schemes supported.

Returns:

Signal on the sphere extended to \(\theta\) domain \([0,2\pi]\), in same scheme (MW/MWSS) as input.

Return type:

np.ndarray

s2fft.utils.resampling.periodic_extension_spatial_mwss(f: ndarray, L: int, spin: int = 0) ndarray#

Perform period extension of MWSS signal on the sphere in spatial domain, extending \(\theta\) domain from \([0,\pi]\) to \([0,2\pi]\).

For the MWSS sampling scheme, it is possible to do the period extension in \(\theta\) in the spatial domain. This is not possible for the MW sampling scheme.

Parameters:
  • f (np.ndarray) – Signal on the sphere sampled with MWSS sampling scheme.

  • L (int) – Harmonic band-limit.

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

Returns:

Signal on the sphere extended to \(\theta\) domain \([0,2\pi]\), in MWSS sampling scheme.

Return type:

np.ndarray

s2fft.utils.resampling.unextend(f_ext: ndarray, L: int, sampling: str = 'mw') ndarray#

Unextend MW/MWSS sampled signal from \(\theta\) domain \([0,2\pi]\) to \([0,\pi]\).

Parameters:
  • f_ext (np.ndarray) – Signal on the sphere sampled on extended \(\theta\) domain \([0,2\pi]\).

  • L (int) – Harmonic band-limit.

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

Raises:
  • ValueError – Only MW/MWW sampling schemes supported.

  • ValueError – Period extension must have correct shape.

Returns:

Signal on the sphere sampled on \(\theta\) domain \([0,\pi]\).

Return type:

np.ndarray

s2fft.utils.resampling.upsample_by_two_mwss(f: ndarray, L: int, spin: int = 0) ndarray#

Upsample MWSS sampled signal on the sphere defined on domain \([0,\pi]\) by a factor of two.

Upsampling is performed by a periodic extension in \(\theta\) to \([0,2\pi]\), followed by zero-padding in harmonic space, followed by unextending \(\theta\) domain back to \([0,\pi]\).

Parameters:
  • f (np.ndarray) – Signal on the sphere sampled with MWSS sampling scheme, sampled at resolution L.

  • L (int) – Harmonic band-limit.

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

Returns:

Signal on the sphere sampled with MWSS sampling scheme, sampling at resolution 2*L.

Return type:

np.ndarray

s2fft.utils.resampling.upsample_by_two_mwss_ext(f_ext: ndarray, L: int) ndarray#

Upsample an extended MWSS sampled signal on the sphere defined on domain \([0,2\pi]\) by a factor of two.

Upsampling is performed by zero-padding in harmonic space.

Parameters:
  • f_ext (np.ndarray) – Signal on the sphere sampled on extended MWSS sampling scheme on domain \([0,2\pi]\), sampled at resolution L.

  • L (int) – Harmonic band-limit.

Returns:

Signal on the sphere sampled on extended MWSS sampling scheme on domain \([0,2\pi]\), sampling at resolution 2*L.

Return type:

np.ndarray