Skip to content

Commit

Permalink
Update to Latest CairoMakie (#198)
Browse files Browse the repository at this point in the history
* Fix AxisAspect deprecation

* Update to latest CairoMakie

* Fix lighting, resolution deprecation

* Specify 2D Axes and no lighting

* Namespace CairoMakie.Axis

* mesh -> mesh!
  • Loading branch information
lukem12345 authored Feb 6, 2024
1 parent f60c360 commit a67a7e4
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 45 deletions.
3 changes: 0 additions & 3 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,3 @@ MLStyle = "d8e11817-5142-5d16-987a-aa16d5891078"
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
PrettyTables = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"

[compat]
CairoMakie = "0.10"
19 changes: 11 additions & 8 deletions docs/src/bc_debug.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ plot_mesh_dual = EmbeddedDeltaDualComplex2D{Bool, Float64, Point3{Float64}}(plot
# Calculate distances and subdivisions for the dual mesh
subdivide_duals!(plot_mesh_dual, Circumcenter())
fig, ax, ob = wireframe(plot_mesh)
ax.aspect = AxisAspect(3.0)
fig = Figure()
ax = CairoMakie.Axis(fig[1,1], aspect = AxisAspect(3.0))
wireframe!(ax, plot_mesh)
fig
```

Expand Down Expand Up @@ -153,8 +154,9 @@ using Distributions
c_dist = MvNormal([1, 5], [1.5, 1.5])
c = [pdf(c_dist, [p[1], p[2]]) for p in plot_mesh_dual[:point]]
fig, ax, ob = mesh(plot_mesh; color=c[1:nv(plot_mesh)])
ax.aspect = AxisAspect(3.0)
fig = Figure()
ax = CairoMakie.Axis(fig[1,1], aspect = AxisAspect(3.0))
mesh!(ax, plot_mesh; color=c[1:nv(plot_mesh)])
fig
```

Expand All @@ -180,14 +182,15 @@ times = range(0.0, 100.0, length=150)
colors = [sol(t).C for t in times]
extrema
# Initial frame
fig, ax, ob = mesh(plot_mesh, color=colors[1], colorrange = extrema(vcat(colors...)))
ax.aspect = AxisAspect(3.0)
Colorbar(fig[1,2], ob)
fig = Figure()
ax = CairoMakie.Axis(fig[1,1], aspect = AxisAspect(3.0))
pmsh = mesh!(ax, plot_mesh; color=colors[1], colorrange = extrema(vcat(colors...)))
Colorbar(fig[1,2], pmsh)
framerate = 30
# Animation
record(fig, "diff_adv_right.gif", range(0.0, 100.0; length=150); framerate = 30) do t
ob.color = sol(t).C
pmsh.color = sol(t).C
end
```

Expand Down
4 changes: 2 additions & 2 deletions docs/src/budyko_sellers_halfar.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ Create animated GIFs of the temperature and ice height dynamics.
begin
# Initial frame
frames = 100
fig = Figure(resolution = (800, 800))
fig = Figure(; size = (800, 800))
ax1 = CairoMakie.Axis(fig[1,1])
xlims!(ax1, extrema(map(x -> x[1], point(s′))))
ylims!(ax1, extrema(soln(tₑ).Tₛ))
Expand All @@ -304,7 +304,7 @@ end
begin
# Initial frame
frames = 100
fig = Figure(resolution = (800, 800))
fig = Figure(; size = (800, 800))
ax1 = CairoMakie.Axis(fig[1,1])
xlims!(ax1, extrema(map(x -> x[1], point(s′))))
ylims!(ax1, extrema(soln(tₑ).halfar_h))
Expand Down
18 changes: 12 additions & 6 deletions docs/src/cism.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,10 @@ subdivide_duals!(s, Barycenter())
x̄ = mean(p -> p[1], point(s))
ȳ = mean(p -> p[2], point(s))
wf = wireframe(s)
save("ice_mesh.png", wf)
fig = Figure()
ax = CairoMakie.Axis(fig[1,1])
wf = wireframe!(ax, s)
save("ice_mesh.png", fig)
```

!["Wireframe of the Domain"](ice_mesh.png)
Expand Down Expand Up @@ -167,7 +169,9 @@ end
# Set the initial conditions for ice sheet height:
# Ice height is a primal 0-form. i.e. valued at vertices.
h₀ = map(x -> height_at_p(x[1], x[2], 0), point(s′))
fig = mesh(s′, color=h₀, colormap=:jet)
fig = Figure()
ax = CairoMakie.Axis(fig[1,1])
msh = mesh!(ax, s′, color=h₀, colormap=:jet)
save("ice_initial_conditions.png", fig)
```

Expand Down Expand Up @@ -350,10 +354,12 @@ rmse = sqrt(sum(map(x -> x*x, h_diff)) / length(h_diff))
# Create a gif
begin
frames = 100
fig, ax, ob = mesh(s′, color=soln(0).dynamics_h, colormap=:jet, colorrange=extrema(soln(tₑ).dynamics_h))
Colorbar(fig[1,2], ob)
fig = Figure()
ax = CairoMakie.Axis(fig[1,1])
msh = mesh!(ax, s′, color=soln(0).dynamics_h, colormap=:jet, colorrange=extrema(soln(tₑ).dynamics_h))
Colorbar(fig[1,2], msh)
record(fig, "ice_dynamics_cism.gif", range(0.0, tₑ; length=frames); framerate = 30) do t
ob.color = soln(t).dynamics_h
msh.color = soln(t).dynamics_h
end
end
```
Expand Down
16 changes: 11 additions & 5 deletions docs/src/grigoriev.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ s′ = triangulated_grid(
s′[:point] = map(x -> x + Point3D(MIN_X, MIN_Y, 0), s′[:point])
s = EmbeddedDeltaDualComplex2D{Bool, Float64, Point3D}(s′)
subdivide_duals!(s, Barycenter())
wireframe(s)
fig = Figure()
ax = CairoMakie.Axis(fig[1,1])
wf = wireframe!(ax, s)
display(fig)
```

The coordinates of a vertex are stored in `s[:point]`. Let's use our interpolator to assign ice thickness values to each vertex in the mesh:
Expand Down Expand Up @@ -224,10 +228,12 @@ save("grigoriev_fc.png", f)
function save_dynamics(save_file_name)
time = Observable(0.0)
h = @lift(soln($time).h)
f,a,o = mesh(s′, color=h, colormap=:jet,
colorrange=extrema(soln(tₑ).h);
axis = (; title = @lift("Grigoriev Ice Cap Dynamic Thickness [m] at time $($time))")))
Colorbar(f[1,2], limits=extrema(soln(0.0).h), colormap=:jet)
f = Figure()
ax = CairoMakie.Axis(f[1,1], title = @lift("Grigoriev Ice Cap Dynamic Thickness [m] at time $($time)"))
gmsh = mesh!(ax, s′, color=h, colormap=:jet,
colorrange=extrema(soln(tₑ).h))
#Colorbar(f[1,2], gmsh, limits=extrema(soln(tₑ).h))
Colorbar(f[1,2], gmsh)
timestamps = range(0, tₑ, step=1e-1)
record(f, save_file_name, timestamps; framerate = 15) do t
time[] = t
Expand Down
31 changes: 22 additions & 9 deletions docs/src/ice_dynamics.md
Original file line number Diff line number Diff line change
Expand Up @@ -408,16 +408,21 @@ soln = solve(prob, Tsit5())

``` @example DEC
# Final conditions:
mesh(s′, color=soln(tₑ).dynamics_h, colormap=:jet, colorrange=extrema(soln(0).dynamics_h))
fig = Figure()
ax = CairoMakie.Axis(fig[1,1])
msh = mesh!(ax, s′, color=soln(tₑ).dynamics_h, colormap=:jet, colorrange=extrema(soln(0).dynamics_h))
display(fig)
```

``` @example DEC
begin
frames = 100
fig, ax, ob = CairoMakie.mesh(s′, color=soln(0).dynamics_h, colormap=:jet, colorrange=extrema(soln(0).dynamics_h))
Colorbar(fig[1,2], ob)
fig = Figure()
ax = CairoMakie.Axis(fig[1,1])
msh = CairoMakie.mesh!(ax, s′, color=soln(0).dynamics_h, colormap=:jet, colorrange=extrema(soln(0).dynamics_h))
Colorbar(fig[1,2], msh)
record(fig, "ice_dynamics2D.gif", range(0.0, tₑ; length=frames); framerate = 15) do t
ob.color = soln(t).dynamics_h
msh.color = soln(t).dynamics_h
end
end
```
Expand Down Expand Up @@ -449,7 +454,10 @@ end
# Visualize initial condition for ice sheet height.
# There is lots of ice at the poles, and no ice at the equator.
mesh(s′, color=h₀, colormap=:jet)
fig = Figure()
ax = LScene(fig[1,1], scenekw=(lights=[],))
msh = CairoMakie.mesh!(ax, s′, color=h₀, colormap=:jet)
display(fig)
```

``` @example DEC
Expand Down Expand Up @@ -483,19 +491,24 @@ extrema(soln(0).dynamics_h), extrema(soln(tₑ).dynamics_h)
```

``` @example DEC
mesh(s′, color=soln(tₑ).dynamics_h, colormap=:jet, colorrange=extrema(soln(0).dynamics_h))
fig = Figure()
ax = LScene(fig[1,1], scenekw=(lights=[],))
msh = CairoMakie.mesh!(ax, s′, color=soln(tₑ).dynamics_h, colormap=:jet, colorrange=extrema(soln(0).dynamics_h))
display(fig)
```

``` @example DEC
begin
frames = 200
fig, ax, ob = CairoMakie.mesh(s′, color=soln(0).dynamics_h, colormap=:jet, colorrange=extrema(soln(0).dynamics_h))
fig = Figure()
ax = LScene(fig[1,1], scenekw=(lights=[],))
msh = CairoMakie.mesh!(ax, s′, color=soln(0).dynamics_h, colormap=:jet, colorrange=extrema(soln(0).dynamics_h))
Colorbar(fig[1,2], ob)
Colorbar(fig[1,2], msh)
# These particular initial conditions diffuse quite quickly, so let's just look at
# the first moments of those dynamics.
record(fig, "ice_dynamics2D_sphere.gif", range(0.0, tₑ/64; length=frames); framerate = 20) do t
ob.color = soln(t).dynamics_h
msh.color = soln(t).dynamics_h
end
end
```
Expand Down
28 changes: 16 additions & 12 deletions docs/src/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,9 @@ plot_mesh = loadmesh(Rectangle_30x10())
periodic_mesh = loadmesh(Torus_30x10())
point_map = loadmesh(Point_Map())
fig, ax, ob = wireframe(plot_mesh)
ax.aspect = AxisAspect(3.0)
fig = Figure()
ax = CairoMakie.Axis(fig[1,1], aspect = AxisAspect(3.0))
wireframe!(ax, plot_mesh)
fig
```

Expand Down Expand Up @@ -153,8 +154,9 @@ using Distributions
c_dist = MvNormal([7, 5], [1.5, 1.5])
c = [pdf(c_dist, [p[1], p[2]]) for p in periodic_mesh[:point]]
fig, ax, ob = mesh(plot_mesh; color=c[point_map])
ax.aspect = AxisAspect(3.0)
fig = Figure()
ax = CairoMakie.Axis(fig[1,1], aspect = AxisAspect(3.0))
mesh!(ax, plot_mesh; color=c[point_map])
fig
```

Expand All @@ -175,14 +177,15 @@ times = range(0.0, 100.0, length=150)
colors = [sol(t).C[point_map] for t in times]
# Initial frame
fig, ax, ob = mesh(plot_mesh, color=colors[1], colorrange = extrema(vcat(colors...)))
ax.aspect = AxisAspect(3.0)
Colorbar(fig[1,2], ob)
fig = Figure()
ax = CairoMakie.Axis(fig[1,1], aspect = AxisAspect(3.0))
pmsh = mesh!(ax, plot_mesh; color=colors[1], colorrange = extrema(vcat(colors...)))
Colorbar(fig[1,2], pmsh)
framerate = 30
# Animation
record(fig, "diffusion.gif", range(0.0, 100.0; length=150); framerate = 30) do t
ob.color = sol(t).C[point_map]
pmsh.color = sol(t).C[point_map]
end
```

Expand Down Expand Up @@ -337,14 +340,15 @@ times = range(0.0, 100.0, length=150)
colors = [sol(t).C[point_map] for t in times]
# Initial frame
fig, ax, ob = mesh(plot_mesh, color=colors[1], colorrange = extrema(vcat(colors...)))
ax.aspect = AxisAspect(3.0)
Colorbar(fig[1,2], ob)
fig = Figure()
ax = CairoMakie.Axis(fig[1,1], aspect = AxisAspect(3.0))
pmsh = mesh!(ax, plot_mesh; color=colors[1], colorrange = extrema(vcat(colors...)))
Colorbar(fig[1,2], pmsh)
framerate = 30
# Animation
record(fig, "diff_adv.gif", range(0.0, 100.0; length=150); framerate = 30) do t
ob.color = sol(t).C[point_map]
pmsh.color = sol(t).C[point_map]
end
```

Expand Down

0 comments on commit a67a7e4

Please sign in to comment.