Skip to content

Possibly incorrect spherical harmonic transform #120

@jishnub

Description

@jishnub

Please see this discourse thread. I'm not entirely sure if this is a bug or if I'm doing something wrong. The dircourse thread did not generate a lot of discussion so I'm posting it here. I'm trying to compute the spherical harmonic transform of r.x, that is the x-component of the radial unit vector, but limited to only one face of the sphere, the other being set to zero. I'm following the example presented in sphere.jl.

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

There are two things that stick out here -- firstly there's no conjugate symmetry despite the function being real. Secondly the last column has a non-zero entry in the third row, which is not what I would have expected given the storage pattern. It's possible that I'm not doing something correctly here, so I'll be glad if someone could point me in the right direction.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions