Skip to content

Commit

Permalink
Merge pull request #60 from gaelforget/v0p2p22
Browse files Browse the repository at this point in the history
V0p2p22
  • Loading branch information
gaelforget authored Aug 27, 2021
2 parents 322ef2c + 1e94fb9 commit 977a515
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "MeshArrays"
uuid = "cb8c808f-1acf-59a3-9d2b-6e38d009f683"
authors = ["gaelforget <[email protected]>"]
version = "0.2.21"
version = "0.2.22"

[deps]
CatViews = "81a5f4ea-a946-549a-aa7e-2a7f63a27d31"
Expand Down
68 changes: 68 additions & 0 deletions examples/Makie.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@

#possible issues
#1. intermediate yy needed; MeshArrays errors otherwise
#2. lack of exch_z, which would allow using corner points
#4. Float32 / Float64 dispatch may be an issue in e.g.
# `pi/2 .-Γ.YC*pi/180`

# XC=γ.read(γ.write(Γ.XC),MeshArray(γ,Float64))
# YC=γ.read(γ.write(Γ.YC),MeshArray(γ,Float64))

using GLMakie

"""
plot_as_sphere(Γ)
Plot mesh (Γ.XC,Γ.YC) and depth (Γ.Depth) on the surface of the sphere in 3D.
"""
function plot_as_sphere(Γ)
yy=pi/2 .-Γ.YC*pi/180
x=sin.(yy)*cos.(Γ.XC*pi/180)
y=sin.(yy)*sin.(Γ.XC*pi/180)
z=cos.(yy)
d=Γ.Depth
crng=(minimum(d),maximum(d))
minimum(d)==maximum(d) ? crng=(0.9*crng[1],1.1*crng[1]) : nothing

c=[:gold,:magenta,:DeepSkyBlue,:cyan,:red,:black]
az=Node(0.4π)
el=Node(0.2π)
fig = Figure(resolution = (900,900), backgroundcolor = :grey90)
ax = Axis3(fig, aspect = :data, viewmode = :fitzoom, #perspectiveness = 0.5,
azimuth = az, elevation = el,)
for i=1:length(z.fSize)
surface!(ax, x[i], y[i], z[i], color = d[i], colorrange = crng, colormap = :grays)
wireframe!(x[i],y[i],z[i], overdraw = false, linewidth = 0.25,color=c[i])
end
#hidedecorations!(ax)
#hidespines!(ax)
fig[1,1] = ax
fig
end

"""
plot_as_plane(Γ)
Plot mesh (Γ.XC,Γ.YC) and depth (Γ.Depth) pn a 2D plane.
"""
function plot_as_plane(Γ)
x=Float64.(Γ.XC)
y=Float64.(Γ.YC)
z=0*y
d=Float64.(Γ.Depth)
crng=(minimum(d),maximum(d))
minimum(d)==maximum(d) ? crng=(0.9*crng[1],1.1*crng[1]) : nothing

c=[:magenta,:gold,:blue,:cyan,:red,:black]
fig = Figure(resolution = (900,900), backgroundcolor = :grey90)
ax = Axis3(fig[1,1])
for i=1:length(x.fSize)
surface!(ax, x[i], y[i], z[i], color = d[i], colorrange = crng, colormap = :grays)
#contourf!(x[i], y[i], d[i], colorrange = (0.0, 5e3), colormap = :grays)
wireframe!(x[i],y[i], z[i], overdraw = false, linewidth = 0.25,color=c[i])
end
#hidedecorations!(ax)
#hidespines!(ax)
fig[1,1] = ax
fig
end

0 comments on commit 977a515

Please sign in to comment.