Interpolation of PlaneWaveExpansions and SphericalFieldSamplings

A very useful operation on a spherically sampled data structure (i.e., a PlaneWaveExpansion or a SphericalFieldSampling) is interpolation (have a look at the theory section for background information on how the interpolation works internally). For any function $\bm{f}(\vartheta, \varphi)$ on the sphere[1], sampled at finitely many sampling points $(\vartheta_i, \varphi_i)$, we want to be able to find the function value at any point $(\vartheta, \varphi)$ which does not necessarily coincide with a point from the set of previously sampled points.

In particular, if the function $\bm{f}(\vartheta, \varphi)$ is sampled according to a certain SphereSamplingStrategy, we want to be able to resample the function according to a different SphereSamplingStrategy. This resampling step is often referred to as interpolation in other works, but in the context of AntennaFieldRepresentations.jl, we are a bit more careful with our wording. In AntennafieldRepresentations.jl

  • the term interpolation means to evaluate a function $\bm{f}(\vartheta, \varphi)$ on the sphere, sampled according to some SphereSamplingStrategy, at arbitrary other sampling points $(\vartheta, \varphi)$
  • the term resampling means to find the values $\bm{f}(\vartheta_i, \varphi_i)$ of a function on the sphere, sampled according to a certain SphereSamplingStrategy B, from the values $\bm{f}(\vartheta_k, \varphi_k)$ of the same function, sampled according to another SphereSamplingStrategy A - i.e., after the resampling process, the spherical function $\bm{f}(\vartheta, \varphi)$ which was sampled according to SphereSamplingStrategy A, is now sampled according to SphereSamplingStrategy B.

Interpolating Spherically Sampled Data at Arbitrary Sampling Points

We can interpolate spherically sampled data at arbitrary sampling points by using the interpolate method or an InterpolateMap.

The basic usage of the interpolate method is simple (expand "Setup Code" to see how the input data is generated):

Setup Code
#########################################
#                   Setup
#                     |
#                     V
#########################################
using AntennaFieldRepresentations
Z₀=376.730313669;                       # free-space wave impedance
f= 1.5e9;                               # frequency
λ = AntennaFieldRepresentations.c₀ / f; # wavelength
k0 = 2 * pi / λ;                        # wavenumber

# setup arbitrary AUT field
coeffs = zeros(ComplexF64, 30) # coefficients up to order ℓ=3
coeffs[1:16] = ComplexF64.(collect(1:16)) # populate coefficients up to order ℓ=2
sph_coefficients= SphericalCoefficients(coeffs)
swe= SphericalWaveExpansion(Radiated(),sph_coefficients, k0)

# Convert to PlaneWaveExpansion, by default sampled according to GaussLegendreθRegularϕSampling
pwe = changerepresentation(PlaneWaveExpansion, swe)


# Define spherical sampling strategy
_, Lmax, __ =j_to_sℓm(length(swe)); # maximum mode order
αinc=AntennaFieldRepresentations.αinc_dipole(1.0, Lmax, k0) # spherical coefficients of incident field Hertzian dipole at 1.0m distance
Jθ= 2*Lmax + 1;
Jϕ= 2*Lmax + 1;
samplingstrategy= RegularθRegularϕSampling(Jθ, Jϕ) 

# initialize empty spherical field sampling
fieldsampling = SphericalFieldSampling(samplingstrategy, αinc);
# fill fieldsampling with values
fieldsampling .= transmit(swe, fieldsampling)
###########################################
#                     ^
#                     |
#                    Setup
###########################################
# pwe is a PlaneWaveExpansion{Radiated}

# Arbitrary position
θ=pi/10
ϕ= pi/7.8

# interpolate pwe at new position
newEθ, newEϕ = interpolate((θ,ϕ), pwe)

# Actual values at this position
Eθ, Eϕ = -59.44801130097685 + 58.38482519439182im, 68.0278816964276 + 75.60985071712197im

# Evaluate interpolation error
abs(Eθ - newEθ) / abs(Eθ) < 0.0055 # true
abs(Eϕ - newEϕ) / abs(Eϕ) < 0.0044  # true

The default interpolation method uses (approximate) local interpolation with an interpolation order of orderθ = 12 along θ and orderϕ = 12 along ϕ. For better interpolation accuracy, we can specify the keyword arguments orderθ and orderϕ

# interpolate pwe at new position with better accuracy
newEθ, newEϕ = interpolate((θ,ϕ), pwe, orderθ = 18, orderϕ = 18)

# Evaluate interpolation error
abs(Eθ - newEθ) / abs(Eθ) < 0.00055 # true
abs(Eϕ - newEϕ) / abs(Eϕ) < 0.00044  # true
Tip

The most effective way to reduce the interpolation error is to start with oversampled data. Having larger oversampling in the original data is more effectively impacting the interpolation accuracy than the interpolation order.


Resampling Spherically Sampled Data According to a New SphereSamplingStrategy

We can resample spherically sampled data to a new SphereSamplingStrategy using the resample method or a ResampleMap.

# define the target samplingstrategy
targetsamplingstrategy= RegularθRegularϕSampling(20, 20) 

pwe2= resample(targetsamplingstrategy, pwe)
  • 1The function $\bm{f}(\vartheta, \varphi)$ is displayed with a bold $\bm{f}$ to indicate its vector character. All spherically sampled data structures to be interpolated in AntennaFieldRepresentations.jl have two components representing two independent polarizations of the electromagnetic field.