This code gives correct scatter plot but i want 3D volume plot. My grid is non-uniform so i have trouble getting volume plot. Please guide me how to get volume plot?
using HDF5, GLMakie, Colors, LinearAlgebra
GLMakie.activate!(ssao=true)
GLMakie.closeall() # close any open screen
function plothdf(h5file::String)
h5 = h5open(h5file, "r")
num_blocks = read(HDF5.attributes(h5), "NumMeshBlocks")
Ď = read(h5["prim"])[:,:,:,:,1] # shape: (Nx, Ny, Nz, Nvars, Nblocks)
x_all = read(h5["x1v"]) # shape: (Nx, Nblocks)
y_all = read(h5["x2v"])
z_all = read(h5["x3v"])
close(h5)
all_xs, all_ys, all_zs, all_density = Float32[], Float32[], Float32[], Float32[]
for b in 1:num_blocks
x = x_all[:, b]
y = y_all[:, b]
z = z_all[:, b]
density = Ď[:,:,:,b] # 3D array
for i in 1:length(x), j in 1:length(y), k in 1:length(z)
r, θ, Ď = x[i], y[j], z[k]
X = r * sin(θ) * cos(Ď)
Y = r * sin(θ) * sin(Ď)
Z = r * cos(θ)
push!(all_xs, X)
push!(all_ys, Y)
push!(all_zs, Z)
push!(all_density, density[i, j, k])
end
end
# Normalize density
norm_density = log10.(abs.(normalize!(all_density)))
cmap = cgrad(:plasma)
colors = get.(Ref(cmap), norm_density)
fig = Figure(size = (1000, 800))
ssao = Makie.SSAO(radius = 5.0, blur = 3)
ax = LScene(fig[1, 1], scenekw = (ssao=ssao,))
ax.scene.ssao.bias[] = 1.95
plt = scatter!(ax, all_xs, all_ys, all_zs, color = norm_density, markersize = 5)
Colorbar(fig[1, 2], plt, label = "logââ(norm(Ď))")
display(fig)
end
plothdf("sane00.prim.01800.athdf")