Extracting bow shock location

Author Author Update time

This demo shows how to extract the bow shock location from a 2D equatorial run and plot.

using Vlasiator, PyPlot

# Upstream solar wind temperature
const Tsw = 0.5e6 #[K]

const file = "bulk.0001347.vlsv"
meta = load(file)
# NonAMR
const x = LinRange{Float32}(meta.coordmin[1], meta.coordmax[1], meta.ncells[1])
const y = LinRange{Float32}(meta.coordmin[2], meta.coordmax[2], meta.ncells[2])

# Obtain thermal temperature
T = meta["T"]
T = reshape(T, meta.ncells[1], meta.ncells[2])

const x_crossing = zeros(Float32, meta.ncells[2])
const y_crossing = y

# Extract bow shock location from the 1st point which fulfills the threshold: T > 4 * Tsw
# Note: this won't work if the bow shock does not cover the whole domain y extension!
for j in 1:meta.ncells[2] # scan in y direction
   ind_ = findlast(>(4*Tsw), @view T[:,j]) # count from upstream
   x_crossing[j] = x[ind_]
end

# Julia is column-major, while Python is row-major
imshow(T', extent=(x[1], x[end], y[1], y[end]), origin="lower", cmap=plt.get_cmap("ocean"))
plot(x_crossing, y_crossing, "r")
axis("scaled")
savefig("bs_temp_test.png")

This page was generated using DemoCards.jl.