resampling_torch#
- s2fft.utils.resampling_torch.mw_to_mwss(f_mw: tensor, L: int, spin: int = 0) tensor #
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.
Torch implementation of
mw_to_mwss()
.- Parameters:
f_mw (torch.tensor) – 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:
torch.tensor
- s2fft.utils.resampling_torch.mw_to_mwss_phi(f_mw: tensor, L: int) tensor #
Convert \(\phi\) component of signal on the sphere from MW sampling to MWSS sampling.
Conversion is performed by zero padding in harmonic space.
Torch implementation of
mw_to_mwss_phi()
.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 (torch.tensor) – 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:
torch.tensor
- s2fft.utils.resampling_torch.mw_to_mwss_theta(f_mw: tensor, L: int, spin: int = 0) tensor #
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]\).
Torch implementation of
mw_to_mwss_theta()
.- Parameters:
f_mw (torch.tensor) – 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:
torch.tensor
- s2fft.utils.resampling_torch.periodic_extension(f: tensor, L: int, spin: int = 0, sampling: str = 'mw') tensor #
Perform period extension of MW/MWSS signal on the sphere in harmonic domain, extending \(\theta\) domain from \([0,\pi]\) to \([0,2\pi]\). Torch implementation of
periodic_extension()
.- Parameters:
f (torch.tensor) – 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:
torch.tensor
- s2fft.utils.resampling_torch.periodic_extension_spatial_mwss(f: tensor, L: int, spin: int = 0) tensor #
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.
Torch implementation of
periodic_extension_spatial_mwss()
.- Parameters:
f (torch.tensor) – 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:
torch.tensor
- s2fft.utils.resampling_torch.unextend(f_ext: tensor, L: int, sampling: str = 'mw') tensor #
Unextend MW/MWSS sampled signal from \(\theta\) domain \([0,2\pi]\) to \([0,\pi]\).
- Parameters:
f_ext (torch.tensor) – 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:
torch.tensor
- s2fft.utils.resampling_torch.upsample_by_two_mwss(f: tensor, L: int, spin: int = 0) tensor #
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]\).
Torch implementation of
upsample_by_two_mwss()
.- Parameters:
f (torch.tensor) – 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:
torch.tensor
- s2fft.utils.resampling_torch.upsample_by_two_mwss_ext(f_ext: tensor, L: int) tensor #
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. Torch implementation of
upsample_by_two_mwss_ext()
.- Parameters:
f_ext (torch.tensor) – 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:
torch.tensor