Skip to content

Convert all animations in Docs from mp4 to gifs #157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 2, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions docs/src/index.md
Original file line number Diff line number Diff line change
@@ -4,20 +4,15 @@

`GeophysicalFlows.jl` is a collection of modules which leverage the
[FourierFlows.jl](https://github.com/FourierFlows/FourierFlows.jl) framework to provide
solvers for problems in Geophysical Fluid Dynamics, on periodic domains and using Fourier-based pseudospectral methods.
solvers for problems in Geophysical Fluid Dynamics, on periodic domains using Fourier-based pseudospectral methods.

## Examples

Examples aim to demonstrate the main functionalities of each module. Have a look at our Examples collection!

!!! warning "Animations and Mac OS X Safari"
Often animations included the documentation, e.g., those in the [2D Navier-Stokes decaying turbulence example](generated/twodnavierstokes_decaying/)
don't show up in Safari. Until this issue is fixed we suggest using alternative browsers
to view the documentation.

## Developers

GeophysicalFlows is currently being developed by [Navid C. Constantinou](http://www.navidconstantinou.com) and [Gregory L. Wagner](https://glwagner.github.io).
GeophysicalFlows.jl is currently being developed by [Navid C. Constantinou](http://www.navidconstantinou.com) and [Gregory L. Wagner](https://glwagner.github.io).

## Cite

4 changes: 2 additions & 2 deletions examples/barotropicqg_betadecay.jl
Original file line number Diff line number Diff line change
@@ -71,7 +71,7 @@ qih *= sqrt(E₀ / Ein) # normalize qi to have energy E₀
qi = irfft(qih, grid.nx)

BarotropicQG.set_zeta!(prob, qi)
nothing #hide
nothing # hide

# Let's plot the initial vorticity field:

@@ -234,7 +234,7 @@ anim = @animate for j = 0:round(Int, nsteps/nsubs)

end

mp4(anim, "barotropicqg_betadecay.mp4", fps=12)
gif(anim, "barotropicqg_betadecay.gif", fps=12)

# ## Save

4 changes: 2 additions & 2 deletions examples/barotropicqg_betaforced.jl
Original file line number Diff line number Diff line change
@@ -227,7 +227,7 @@ function plot_output(prob)
xlabel = "μt")

l = @layout Plots.grid(2, 3)
p = plot(pζ, pζm, pE, pψ, pum, pZ, layout=l, size = (1000, 600), dpi=150)
p = plot(pζ, pζm, pE, pψ, pum, pZ, layout=l, size = (1000, 600))

return p
end
@@ -265,7 +265,7 @@ anim = @animate for j = 0:Int(nsteps / nsubs)
BarotropicQG.updatevars!(prob)
end

mp4(anim, "barotropicqg_betaforced.mp4", fps=18)
gif(anim, "barotropicqg_betaforced.gif", fps=18)


# ## Save
4 changes: 2 additions & 2 deletions examples/barotropicqg_decay_topography.jl
Original file line number Diff line number Diff line change
@@ -88,7 +88,7 @@ qih *= sqrt(E₀ / energy(qih, grid)) # normalize qi to have energy
qi = irfft(qih, grid.nx)

BarotropicQG.set_zeta!(prob, qi)
nothing #hide
nothing # hide

# Let's plot the initial vorticity field:

@@ -231,4 +231,4 @@ anim = @animate for j = 0:round(Int, nsteps/nsubs)
BarotropicQG.updatevars!(prob)
end

mp4(anim, "barotropicqg_decay_topography.mp4", fps=12)
gif(anim, "barotropicqg_decay_topography.gif", fps=12)
4 changes: 2 additions & 2 deletions examples/barotropicqgql_betaforced.jl
Original file line number Diff line number Diff line change
@@ -243,7 +243,7 @@ function plot_output(prob)
xlabel = "μt")

l = @layout Plots.grid(2, 3)
p = plot(pζ, pζm, pE, pψ, pum, pZ, layout=l, size = (1000, 600), dpi=150)
p = plot(pζ, pζm, pE, pψ, pum, pZ, layout=l, size = (1000, 600))

return p
end
@@ -280,7 +280,7 @@ anim = @animate for j = 0:round(Int, nsteps / nsubs)
BarotropicQGQL.updatevars!(prob)
end

mp4(anim, "barotropicqgql_betaforced.mp4", fps=18)
gif(anim, "barotropicqgql_betaforced.gif", fps=18)


# ## Save
38 changes: 19 additions & 19 deletions examples/multilayerqg_2layer.jl
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@
using FourierFlows, Plots, Printf

using FFTW: rfft, irfft
using Random: seed!
import GeophysicalFlows.MultilayerQG
import GeophysicalFlows.MultilayerQG: energies

@@ -22,9 +23,7 @@ nothing # hide

# ## Numerical parameters and time-stepping parameters

nx = 128 # 2D resolution = nx^2
ny = nx

n = 128 # 2D resolution = n²
stepper = "FilteredRK4" # timestepper
dt = 6e-3 # timestep
nsteps = 7000 # total number of time-steps
@@ -33,14 +32,14 @@ nothing # hide


# ## Physical parameters
Lx = 2π # domain size
μ = 5e-2 # bottom drag
β = 5 # the y-gradient of planetary PV
L = 2π # domain size
μ = 5e-2 # bottom drag
β = 5 # the y-gradient of planetary PV

nlayers = 2 # number of layers
f₀, g = 1, 1 # Coriolis parameter and gravitational constant
H = [0.2, 0.8] # the rest depths of each layer
ρ = [4.0, 5.0] # the density of each layer
nlayers = 2 # number of layers
f₀, g = 1, 1 # Coriolis parameter and gravitational constant
H = [0.2, 0.8] # the rest depths of each layer
ρ = [4.0, 5.0] # the density of each layer

U = zeros(nlayers) # the imposed mean zonal flow in each layer
U[1] = 1.0
@@ -50,7 +49,7 @@ nothing # hide

# ## Problem setup
# We initialize a `Problem` by providing a set of keyword arguments,
prob = MultilayerQG.Problem(nlayers, dev; nx=nx, Lx=Lx, f₀=f₀, g=g, H=H, ρ=ρ, U=U, dt=dt, stepper=stepper, μ=μ, β=β)
prob = MultilayerQG.Problem(nlayers, dev; nx=n, Lx=L, f₀=f₀, g=g, H=H, ρ=ρ, U=U, dt=dt, stepper=stepper, μ=μ, β=β)
nothing # hide

# and define some shortcuts.
@@ -64,7 +63,8 @@ nothing # hide
# Our initial condition is some small amplitude random noise. We smooth our initial
# condidtion using the `timestepper`'s high-wavenumber `filter`.

q_i = 4e-3randn((nx, ny, nlayers))
seed!(1234) # reset of the random number generator for reproducibility
q_i = 4e-3randn((grid.nx, grid.ny, nlayers))
qh_i = prob.timestepper.filter .* rfft(q_i, (1, 2)) # only apply rfft in dims=1, 2
q_i = irfft(qh_i, grid.nx, (1, 2)) # only apply irfft in dims=1, 2

@@ -108,7 +108,7 @@ function get_u(prob)
end

out = Output(prob, filename, (:sol, get_sol), (:u, get_u))
nothing #hide
nothing # hide


# ## Visualizing the simulation
@@ -122,15 +122,15 @@ function plot_output(prob)
Lx, Ly = prob.grid.Lx, prob.grid.Ly

l = @layout Plots.grid(2, 3)
p = plot(layout=l, size = (1000, 600), dpi=150)
p = plot(layout=l, size = (1000, 600))

for m in 1:nlayers
heatmap!(p[(m-1) * 3 + 1], x, y, vars.q[:, :, m]',
aspectratio = 1,
legend = false,
c = :balance,
xlims = (-Lx / 2, Lx / 2),
ylims = (-Ly / 2, Ly / 2),
xlims = (-Lx/2, Lx/2),
ylims = (-Ly/2, Ly/2),
clims = symlims,
xticks = -3:3,
yticks = -3:3,
@@ -144,8 +144,8 @@ function plot_output(prob)
aspectratio = 1,
legend = false,
c = :viridis,
xlims = (-Lx / 2, Lx / 2),
ylims = (-Ly / 2, Ly / 2),
xlims = (-Lx/2, Lx/2),
ylims = (-Ly/2, Ly/2),
clims = symlims,
xticks = -3:3,
yticks = -3:3,
@@ -212,7 +212,7 @@ anim = @animate for j = 0:round(Int, nsteps / nsubs)
MultilayerQG.updatevars!(prob)
end

mp4(anim, "multilayerqg_2layer.mp4", fps=18)
gif(anim, "multilayerqg_2layer.gif", fps=18)


# ## Save
5 changes: 2 additions & 3 deletions examples/surfaceqg_decaying.jl
Original file line number Diff line number Diff line change
@@ -158,7 +158,7 @@ function plot_output(prob)
xlabel = "t")

layout = @layout [a{0.5w} Plots.grid(2, 1)]
p = plot(pbₛ, pKE, pb², layout=layout, size = (900, 500), dpi=150)
p = plot(pbₛ, pKE, pb², layout=layout, size = (900, 500))

return p
end
@@ -195,7 +195,7 @@ anim = @animate for j = 0:round(Int, nsteps/nsubs)
SurfaceQG.updatevars!(prob)
end

mp4(anim, "sqg_ellipticalvortex.mp4", fps=14)
gif(anim, "sqg_ellipticalvortex.gif", fps=14)

# Let's see how all flow fields look like at the end of the simulation.

@@ -243,4 +243,3 @@ layout = @layout [a{0.5h}; b{0.5w} c{0.5w}]
plot_final = plot(pb, pu, pv, layout=layout, size = (800, 800))

# Last we can save the output by calling `saveoutput(out)`.

4 changes: 2 additions & 2 deletions examples/twodnavierstokes_decaying.jl
Original file line number Diff line number Diff line change
@@ -159,7 +159,7 @@ anim = @animate for j = 0:Int(nsteps/nsubs)
TwoDNavierStokes.updatevars!(prob)
end

mp4(anim, "twodturb.mp4", fps=18)
gif(anim, "twodturb.gif", fps=18)


# Last we save the output.
@@ -168,7 +168,7 @@ saveoutput(out)

# ## Radial energy spectrum

# After the simulation is done we plot the radial energy spectrum to illustrate
# After the simulation is done we plot the instantaneous radial energy spectrum to illustrate
# how `FourierFlows.radialspectrum` can be used,

E = @. 0.5 * (vars.u^2 + vars.v^2) # energy density
2 changes: 1 addition & 1 deletion examples/twodnavierstokes_stochasticforcing.jl
Original file line number Diff line number Diff line change
@@ -175,4 +175,4 @@ anim = @animate for j = 0:round(Int, nsteps / nsubs)
TwoDNavierStokes.updatevars!(prob)
end

mp4(anim, "twodturb_forced.mp4", fps=18)
gif(anim, "twodturb_forced.gif", fps=18)