Skip to content

Instantly share code, notes, and snippets.

@ali-ramadhan
Created October 22, 2020 18:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ali-ramadhan/2e91bea54608a14769b8717efdb88bfa to your computer and use it in GitHub Desktop.
Save ali-ramadhan/2e91bea54608a14769b8717efdb88bfa to your computer and use it in GitHub Desktop.
Serial plotting
using Printf
using PyCall
using PyPlot
using NCDatasets
cmocean = pyimport("cmocean")
ioff() # Turn off interactive plotting
ds = NCDataset("dry_convection.nc")
frames = length(ds["time"])
x, y, z = ds["xC"], ds["yC"], ds["zC"]
Nx, Ny, Nz = length(ds["xC"]), length(ds["yC"]), length(ds["zC"])
for frame in 1:frames
@info "Frame $frame/$frames..."
ρe = ds["ρe"][:, Int(Ny/2), :, frame] |> Array
ρe₀ = ds["ρe₀"][:, Int(Ny/2), :] |> Array
ρe′ = transpose(ρe .- ρe₀)
PyPlot.contourf(x, z, ρe′, vmin=0, vmax=400, cmap=cmocean.cm.ice, levels=20)
PyPlot.savefig(@sprintf("dry_convection_%04d.png", frame), dpi=200)
PyPlot.close("all")
end
close(ds)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment