s2fft
s2fft copied to clipboard
Disagreement Between Input and Recovered Output Coefficients
When performing a simple inverse to forward transform (i.e. taking an array of Spherical Harmonic(SH) coefficients, applying inverse function for surface values, and then forward function on the same surface values to recover original SH coefficients), the output SH values differ from the original input.
Specifically it appears to recover, within machine precision, the correct values for all 'm=0' modes, but for 'm≠0', it recovers the correct coefficient value magnitude, but also recovers the same value with a negative sign for respective '-m' modes. For example, if the original SH array included a (l=1,m=1) mode with an amplitude coefficient of '0.5', after performing the inverse and forward functions, the (l=1,m=1) will be recovered with the correct value of '0.5', but the (l=1,m=-1) also gets recovered with a value of '-0.5'.
This is the case despite which method of transform used (Jax, numpy, regular) or which sampling scheme used (mw, dh, gl). Below is a code snippet exhibiting the issue as well as an image displaying outputs:
# Imports
import numpy as np
import s2fft
# SH array initialization {(0,0) = 1.0, (1,1) = 0.5}
SHarray = np.array([[0.0, 1.0, 0.0],[0.0, 0.0, 0.5]])
print(SHarray)
# Inverse transform for surface values on sphere
flux = s2fft.inverse_numpy(SHarray, L=2, sampling="mw", reality=True)
print(flux)
#Forward transform for SH-mode recovery
SHrecovered = s2fft.forward_numpy(flux,L=2, sampling="mw", reality=True)
print(SHrecovered)