fgasdia / LongwaveModePropagator.jl

Model the propagation of VLF radio waves in the Earth-ionosphere waveguide.
https://fgasdia.github.io/LongwaveModePropagator.jl/dev
MIT License
12 stars 5 forks source link

Under-sampled GroundSampler leads to phase ambiguity #66

Open JamesMCannon opened 5 months ago

JamesMCannon commented 5 months ago

When setting up a GroundSampler, if a single (or set of few) distance(s) is provided (at range for a rx for instance), the phase returned by "propagate()" may be ambiguous by multiples of 2pi radians. PhaseTestPlot

Code used to generate this figure:

using LongwaveModePropagator
using LongwaveModePropagator: QE, ME
using Plots
using LaTeXStrings

# "standard" vertical dipole transmitter at 24 kHz 1MW
txpower = 1e6
tx = Transmitter(VerticalDipole(),24e3,txpower)

# sample vertical electric field every 1 km, 250km, and 500km, out to 1500 km from tx
rx_z = GroundSampler(0:1e3:1500e3, Fields.Ez)
rx_250 = GroundSampler([250e3,500e3,750e3, 1000e3,1250e3,1500e3],Fields.Ez)
rx_500 = GroundSampler([500e3,1000e3,1500e3],Fields.Ez)

# vertical magnetic field
bfield = BField(50e-6, π/2, 0)

# "typical" seawater ground
ground = Ground(81, 4)

electrons = Species(QE, ME, z->waitprofile(z, 67, 0.4,threshold=1e15), electroncollisionfrequency)

waveguide = HomogeneousWaveguide(bfield, electrons, ground)

# return the complex electric field, amplitude (dB uV/m), and phase (radians)
Ez, az, pz = propagate(waveguide, tx, rx_z);
E, a, p_250 = propagate(waveguide, tx, rx_250);
E, a, p_500 = propagate(waveguide, tx, rx_500);

#----------------------------------------------------------------------------

plt=plot(rx_z.distance/1000,pz.*(180/pi), ylims=(-90,450),label="1km Sampler",dpi=400)
scatter!(rx_250.distance/1000,p_250.*(180/pi),label="250km Sampler")
scatter!(rx_500.distance/1000,p_500.*(180/pi),label="500km Sampler")
plot!(xlabel="Distance (km)",ylabel="Phase(\$ \\degree \$)")

savefig(plt,"PhaseTestPlot.png")
fgasdia commented 5 months ago

This would be tricky to make consistent. The fields are only calculated at the distances defined by the GroundSampler. The phase of each field component is then calculated and for convenience unwrapped along the distance trace. The unwrapping algorithm uses the previous phase to determine the current phase - the specific value depends upon the previous values. In order to guarantee consistent results when there are only a few phases calculated, I would need to calculate the fields and phases at higher resolution, unwrap, and then only return the phases at distances defined by the GroundSampler. If it's necessary to compare phases calculated from different distance traces, I'd recommend either mod2pi of the results or calculating phase directly from the fields.

You may have also noticed the mod2pi phases are not exactly equal at the same distances (different in the hundreths of a degree). This is actually due to the fields themselves being slightly different, which is a known issue that I think is traced to the mode solver and more specifically the Delaunay triangulation. I have been working on an update to the mode solver that uses a newer triangulation package that I'm hoping is more efficient and consistent.

JamesMCannon commented 5 months ago

Yeah on a bigger picture, this is one I've gone back and forth on whether this is an enhancement that would be useful or whether this is actually fine behavior that could maybe be documented and left to users to work with. From the perspective of someone working with data from receivers, certainly a lot of the time I have the same ambiguity, having a single measurement along the waveguide ground track. However, looking at the way phase changes over the course of a day, where I can directly track the previous phase measurement, I regularly see situations where phase climbs greater than pi or sometimes even greater than 2 or 3pi. In those cases, it's useful to have the 'true' phase from the LMP to compare to.

Regardless, an easy work-around that I've been using is to just define the GroundSampler more finely (I'm using every 50km) and then only saving the data for the fields at the final point in the sampler.

On my side of things I've been comparing data to simulations for NLK to determine the transmit power of NLK, so I haven't looked at specifically comparing phase data to LMP simulations just yet. When I do (hopefully in the next week), I may form a different opinion about this (non)issue.