FastSphericalHarmonics.jl
The FastSphericalHarmonics.jl
package wraps the FastTransforms.jl
Julia package to calculate Spherical Harmonics.
FastSphericalHarmonics.jl
is a powerful, efficient, and well thought out package. Unfortunately, its user interface is difficult to use for beginners, and its documentation is very technical. FastSphericalHarmonics.jl
provides functions and documentation that are easier to use. It would be worthwhile to fold FastSphericalHarmonics.jl
into FastTransforms.jl
at some point.
Most functions come in two versions, one that mutates its arguments and one that allocates its output.
Helper functions and types
FastSphericalHarmonics.SpHTypes
— Typeconst SpHTypes = Union{Float64,Complex{Float64}}
The types supported by FastSphericalHarmonics (the same types as for FastTransforms).
FastSphericalHarmonics.sph_points
— FunctionΘ, Φ = sph_points(N::Integer)
Θ::Vector{Float64}
Φ::Vector{Float64}
Calculate the locations of points on the sphere when using N
points in the θ (latitudinal) direction.
It is length(Θ) = N
and length(Φ) = M
where M = 2N-1
.
FastSphericalHarmonics.sph_lmax
— Functionlmax = sph_lmax(N::Integer)
lmax::Int
Calculate the maximum l
mode that can be represented with N
points. It is lmax = N - 1
.
Scalar Spherical Harmonics
FastSphericalHarmonics.sph_mode
— Functionidx = sph_mode(l::Integer, m::Integer)
idx::CartesianIndex{2}
Calculate the Cartesian index idx
for the l
,m
mode. This index can be used to access the coefficients, i.e. the result of sph_transform
or the input to sph_evaluate
.
Coefficients are stored in a two-dimensional array. Not all array elements are used. See this page, section "sph2fourier", for details.
See also: sph_transform!
, sph_transform
, sph_evaluate!
, sph_evaluate
FastSphericalHarmonics.sph_transform!
— Functionsph_transform!(F::Array{T,2}) where {T<:SpHTypes}
Transform an array of points F
into spherical harmonics. This is an in-place transform, i.e. the array F
will be overwritten by the coefficients. Use sph_transform
for a non-mutating function.
Use sph_points
to caluclate the location of the points on the sphere for the input array F
.
Use sph_mode
to calculate the location in the output coefficient array for a particular l
,m
mode.
See also: sph_transform
, sph_evaluate!
, sph_points
, sph_mode
FastSphericalHarmonics.sph_transform
— FunctionC = sph_transform(F::AbstractArray{T,2}) where {T<:SpHTypes}
C::Array{T,2}
Transform an array of points F
into spherical harmonics. You can use sph_transform!
for more efficient a mutating function that overwrites its argument F
.
Use sph_points
to caluclate the location of the points on the sphere for the input array F
.
Use sph_mode
to calculate the location in the output coefficient array for a particular l
,m
mode.
See also: sph_transform!
, sph_evaluate
, sph_points
, sph_mode
FastSphericalHarmonics.sph_evaluate!
— Functionsph_evaluate!(C::Array{T,2}) where {T<:SpHTypes}
Evaluate an array of coefficients C
on the grid points on a sphere. This is an in-place transform, i.e. the array C
will be overwritten by the point values. Use sph_evaluate
for a non-mutating function.
Use sph_mode
to calculate the location in the input coefficient array for a particular l
,m
mode.
Use sph_points
to caluclate the location of the points on the sphere in the output array F
.
See also: sph_evaluate
, sph_transform!
, sph_mode
, sph_points
FastSphericalHarmonics.sph_evaluate
— FunctionF = sph_evaluate(C::AbstractArray{T,2}) where {T<:SpHTypes}
F::Array{T,2}
Evaluate an array of coefficients C
on the grid points on a sphere. You can use sph_evaluate!
for more efficient a mutating function that overwrites its argument C
.
Use sph_mode
to calculate the location in the input coefficient array for a particular l
,m
mode.
Use sph_points
to caluclate the location of the points on the sphere in the output array F
.
See also: sph_evaluate!
, sph_transform
, sph_mode
, sph_points
FastSphericalHarmonics.sph_laplace!
— Functionsph_laplace!(C::Array{T,2}) where {T<:SpHTypes}
Calculate the Laplacian of a set of coefficients C
. This is an in-place transform, i.e. the array C
will be overwritten by the result. Use sph_laplace
for a non-mutating function.
See also: sph_transform!
, sph_evaluate!
, sph_laplace
FastSphericalHarmonics.sph_laplace
— FunctionΔC = sph_laplace(C::AbstractArray{T,2}) where {T<:SpHTypes}
ΔC::Array{T,2}
Calculate the Laplacian of a set of coefficients C
. You can use sph_laplace!
for more efficient a mutating function that overwrites its argument C
.
See also: sph_transform
, sph_evaluate
, sph_laplace!
Spin Spherical Harmonics
FastSphericalHarmonics.spinsph_mode
— Functionidx = spinsph_mode(l::Integer, m::Integer, s::Integer)
idx::CartesianIndex{2}
Calculate the Cartesian index idx
for the l
,m
mode for spin weight s
. This index can be used to access the coefficients, i.e. the result of spinsph_transform
or the input to spinsph_evaluate
.
Coefficients are stored in a two-dimensional array. Not all array elements are used. See this page, section "spinsph2fourier", for details.
See also: spinsph_transform!
, spinsph_transform
, spinsph_evaluate!
, spinsph_evaluate
FastSphericalHarmonics.spinsph_transform!
— Functionspinsph_transform!(F::Array{Complex{Float64},2}, s::Int)
Calculate the spin spherical harmonic transformation with spin weight s
. This is an in-place transform, i.e. the array F
will be overwritten by the coefficients. Use spinsph_transform
for a non-mutating function.
Use sph_points
to caluclate the location of the points on the sphere for the input array F
.
Use spinsph_mode
to calculate the location in the output coefficient array for a particular l
,m
mode with spin weight s
.
See also: spinsph_transform
, spinsph_evaluate!
, sph_points
, spinsph_mode
FastSphericalHarmonics.spinsph_transform
— FunctionC = spinsph_transform(F::AbstractArray{Complex{Float64},2}, s::Int)
C::Array{Complex{Float64},2}
Calculate the spin spherical harmonic transformation with spin weight s
. You can use spinsph_transform!
for more efficient a mutating function that overwrites its argument F
.
Use sph_points
to caluclate the location of the points on the sphere for the input array F
.
Use spinsph_mode
to calculate the location in the output coefficient array for a particular l
,m
mode with spin weight s
.
See also: spinsph_transform!
, spinsph_evaluate
, sph_points
, spinsph_mode
FastSphericalHarmonics.spinsph_evaluate!
— Functionspinsph_evaluate!(C::Array{Complex{Float64},2}, s::Int)
Evaluate the spin spherical harmonic transformation with spin weight s
on points on the sphere. This is an in-place transform, i.e. the array C
will be overwritten by the point values. Use spinsph_evaluate
for a non-mutating function.
Use spinsph_mode
to calculate the location in the input coefficient array for a particular l
,m
mode with spin weight s
.
Use sph_points
to caluclate the location of the points on the sphere in the output array F
.
See also: spinsph_evaluate
, spinsph_transform!
, spinsph_mode
, sph_points
FastSphericalHarmonics.spinsph_evaluate
— FunctionF = spinsph_evaluate(C::AbstractArray{Complex{Float64},2}, s::Int)
F::Array{Complex{Float64},2}
Evaluate the spin spherical harmonic transformation with spin weight s
on points on the sphere. You can use spinsph_evaluate!
for more efficient a mutating function that overwrites its argument C
.
Use spinsph_mode
to calculate the location in the input coefficient array for a particular l
,m
mode with spin weight s
.
Use sph_points
to caluclate the location of the points on the sphere in the output array F
.
See also: spinsph_evaluate!
, spinsph_transform
, spinsph_mode
, sph_points
FastSphericalHarmonics.spinsph_eth
— FunctionðC = spinsph_eth(C::AbstractArray{Complex{Float64},2}, s::Int)
ðC::Array{Complex{Float64},2}
Apply the differential operator ð ("eth") to the coefficients C
. This raises the spin weight s
by 1. For a real function of spin weight 0, this is equivalent to calculating the gradient.
This function is the converse of spinsph_ethbar
, which is a derivative operator lowering the spin weight.
Use spinsph_mode
to calculate the location in the output coefficient array for a particular l
,m
mode with spin weight s
.
See also: spinsph_ethbar
, spinsph_mode
FastSphericalHarmonics.spinsph_ethbar
— FunctionðC = spinsph_ethbar(C::AbstractArray{Complex{Float64},2}, s::Int)
ðC::Array{Complex{Float64},2}
Apply the differential operator ð̄ ("eth-bar") to the coefficients C
. This lowers the spin weight s
by 1. For a function of spin weight 1, this is equivalent to calculating the divergence.
This function is the converse of spinsph_eth
, which is a derivative operator raising the spin weight.
Use spinsph_mode
to calculate the location in the output coefficient array for a particular l
,m
mode with spin weight s
.
See also: spinsph_eth
, spinsph_mode