I am trying to compute the spherical harmonic transform of a function that is given by sin(θ)cos(ϕ)
on the face of the sphere facing us, and zero on the other face that is away from us. I am attempting to use FastTransforms.jl
ans follow this example as
julia> f_test(θ, ϕ) = (π/2 <= ϕ <= 3π/2) ? zero(Float64) : Float64(sin(θ)cos(ϕ))
f_test (generic function with 1 method)
julia> function threshold!(A::AbstractArray, ϵ)
for i in eachindex(A)
if abs(A[i]) < ϵ A[i] = 0 end
end
A
end
threshold! (generic function with 1 method)
julia> lmax = 3
3
julia> N = lmax + 1
4
julia> θ = ((0.5:N-0.5)/N) .* pi
0.39269908169872414:0.7853981633974483:2.748893571891069
julia> M = 2N-1
7
julia> ϕ = ((0:M-1)/M) .* 2pi
0.0:0.8975979010256552:5.385587406153931
julia> F = [f_test(θ,ϕ) for θ in θ, ϕ in ϕ]
4×7 Array{Float64,2}:
0.382683 0.238599 0.0 0.0 0.0 0.0 0.238599
0.92388 0.576029 0.0 0.0 0.0 0.0 0.576029
0.92388 0.576029 0.0 0.0 0.0 0.0 0.576029
0.382683 0.238599 0.0 0.0 0.0 0.0 0.238599
julia> using FastTransforms
julia> P = plan_sph2fourier(F);
julia> PA = plan_sph_analysis(F);
julia> V = PA*F;
julia> threshold!(P\V, 400*eps())
4×7 Array{Float64,2}:
0.888525 0.0 1.0394 0.0 0.417051 0.0 -0.0697631
0.0 0.0 0.0 0.0 0.0 0.0 0.0
-0.259657 0.0 0.0 0.0 0.0571638 0.0 -0.018645
0.0 0.0 0.0 0.0 0.0 0.0 0.0
However I do not understand this result. Going by the storage of the spherical harmonic coefficients, the last column should only have the top row filled. The element at index [3,7]
should be zero (at least within floating-point tolerance). Also, why is there no conjugate symmetry?
Am I misunderstanding something here? Some help would be welcome!