SpeedyWeather / StochasticStir.jl

Twist it, spin it, but randomly.
GNU General Public License v3.0
4 stars 0 forks source link

Add code to reproduce animation in README #7

Open navidcy opened 6 months ago

navidcy commented 6 months ago

That will be helpful.

navidcy commented 6 months ago

E.g., given you have GLMakie and GeoMakie in your environment,

using SpeedyWeather
using StochasticStir

# model components
spectral_grid = SpectralGrid(trunc=63, nlev=1)   
forcing = StochasticStirring(spectral_grid, latitude=35, strength=7e-11)
drag = JetDrag(spectral_grid, time_scale=Day(6))
initial_conditions = StartFromRest()

# construct the model and initialize
model = BarotropicModel(; spectral_grid, initial_conditions, forcing,drag)
simulation = initialize!(model)

# now run and store output
run!(simulation,period=Day(100), output=true)

# load saved output
id = model.output.id
ds = NCDataset("run_$id/output.nc")

times = ds["time"][:]
lat, lon = ds["lat"][:], ds["lon"][:]
lon .-= 180 # convert lon to [-180, 180]

# animate
using GLMakie, GeoMakie

n = Observable(1)

fig = Figure()
ax = GeoAxis(fig[1, 1]; dest = "+proj=ortho +lon_0=0 +lat_0=40")
ax.xticklabelsvisible[] = false
ax.yticklabelsvisible[] = false

vorticity = @lift ds["vor"][:, :, 1, $n]

surface!(ax, lon, lat, vorticity;
         colormap = :balance,
         colorrange = (-1e-4, 1e-4))

title = @lift string(times[$n])

Label(fig[0, :], title, fontsize=24, tellwidth=false)

record(fig, "eddydrivenjet.mp4", 1:length(times), framerate=16) do i
    n[] = i
end

produces

https://github.com/SpeedyWeather/StochasticStir.jl/assets/7112768/1221a45c-9434-4a1b-9bc6-8125ab74b8c7

milankl commented 6 months ago

Awesome, I'll add that. Why is it so dark? It looks like there's a grey shade on top of it?

navidcy commented 6 months ago

I was annoyed with that also... I try to fix it but couldn't. I'm not sure if it's the surface or something else...

milankl commented 6 months ago

@SimonDanisch what are we doing wrong?