Skip to content

Commit

Permalink
add make video test in Sleipnir
Browse files Browse the repository at this point in the history
  • Loading branch information
albangossard committed Feb 25, 2025
1 parent 471215e commit 9a76079
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/simulations/results/results_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ Store the results of a simulation of a single glacier into a `Results`.
function create_results(simulation::SIM, glacier_idx::I, solution, loss=nothing; light=false, batch_id::Union{Nothing, I}=nothing) where {SIM <: Simulation, I <: Integer}
# The solution contains all the steps including the intermediate ones
# This results in solution having multiple values for a given time step, we select the last one of each time step
solStepIndices = [findlast(==(val), solution.t) for val in unique(solution.t)]
nSteps = (simulation.parameters.simulation.tspan[2]-simulation.parameters.simulation.tspan[1])/simulation.parameters.simulation.step
timeSteps = simulation.parameters.simulation.tspan[1].+collect(0:nSteps).*simulation.parameters.simulation.step
solStepIndices = [findlast(==(val), solution.t) for val in timeSteps]

H = light ? [solution.u[begin],solution.u[end]] : solution.u[solStepIndices]
# Simulations using Reverse Diff require an iceflow model per glacier
Expand Down
Binary file added test/data/prediction/glaciers2D_test.jld2
Binary file not shown.
Binary file added test/data/prediction/results2D_test.jld2
Binary file not shown.
Binary file added test/data/prediction/simuparams2D_test.jld2
Binary file not shown.
9 changes: 7 additions & 2 deletions test/plot_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,12 @@ function glaciers2D_plots()
end


function make_thickness_video_test()
@load (joinpath(@__DIR__,"data/prediction/results2D_test.jld2")) results
@load (joinpath(@__DIR__,"data/prediction/glaciers2D_test.jld2")) glaciers
@load (joinpath(@__DIR__,"data/prediction/simuparams2D_test.jld2")) simulation

tempPath = mktempdir()*".mp4"



plot_glacier_vid("thickness", results[1], glaciers[1], simulation, tempPath; baseTitle="Bossons glacier")
end
4 changes: 3 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@ ENV["GKSwstype"]="nul"

#@testset "Glaciers 2D plots" glaciers2D_plots()

end
@testset "Video plot test" make_thickness_video_test()

end

0 comments on commit 9a76079

Please sign in to comment.