In Julia i am using Meshes.jl and GLMakie.jl .
I am using x , z, alfsurf and psi variables of size (109,50) each.
I input them to StructuredGrid() function which creates a structured grid of size (108,49).
using Meshes, GLMakie
x = include("x.jl")
z = include("z.jl")
psi = include("psi.jl")
alfsurf = include("alfsurf.jl")
grd = StructuredGrid(x, z)
function safe_log(x)
x == 0 ? 1 : log(x)
end
z_log = safe_log.(vec(alfsurf))
fig, ax, plt = Meshes.viz(grd, color=z_log, colorscheme=:jet)
contour!(plt,grd, psi, levels =15,color=:red)
How can i plot contours of psi although my code plots heatmap of alfsurf correctly ? Data of variables x, z, psi and alfsurf is in attached files.
alfsurf.jl (27.2 KB)
psi.jl (103.5 KB)
x.jl (98.8 KB)
z.jl (97.5 KB)
I got error message shown below:
ERROR: BoundsError: attempt to access 2-element Vector{Observable} at index [1:3]
Stacktrace:
[1] throw_boundserror(A::Vector{Observable}, I::Tuple{UnitRange{Int64}})
@ Base ./essentials.jl:14
[2] checkbounds
@ ./abstractarray.jl:699 [inlined]
[3] getindex
@ ./array.jl:936 [inlined]
[4] getindex
@ ~/.julia/packages/MakieCore/05FeT/src/attributes.jl:184 [inlined]
[5] plot!(plot::Plot{contour, Tuple{StructuredGrid{𝔼{…}, CoordRefSystems.Cartesian2D{…}, 2, Tuple{…}}, Matrix{Float64}}})
@ Makie ~/.julia/packages/Makie/tjqse/src/basic_recipes/contours.jl:212
[6] connect_plot!(parent::Plot{viz, Tuple{StructuredGrid{…}}}, plot::Plot{contour, Tuple{StructuredGrid{…}, Matrix{…}}})
@ Makie ~/.julia/packages/Makie/tjqse/src/interfaces.jl:395
[7] plot!(scene::Plot{viz, Tuple{StructuredGrid{…}}}, plot::Plot{contour, Tuple{StructuredGrid{…}, Matrix{…}}})
@ Makie ~/.julia/packages/Makie/tjqse/src/interfaces.jl:412
[8] _create_plot!(::Function, ::Dict{…}, ::Plot{…}, ::StructuredGrid{…}, ::Vararg{…})
@ Makie ~/.julia/packages/Makie/tjqse/src/figureplotting.jl:391
[9] contour!(::Plot{viz, Tuple{StructuredGrid{…}}}, ::Vararg{Any}; kw::@Kwargs{levels::Int64, color::Symbol})
@ Makie ~/.julia/packages/MakieCore/05FeT/src/recipes.jl:505
[10] top-level scope
@ REPL[22]:1
Some type information was truncated. Useshow(err)
to see complete types.