Skip to content

Commit

Permalink
remove previously added jld2 files
Browse files Browse the repository at this point in the history
  • Loading branch information
albangossard committed Feb 25, 2025
1 parent b56816d commit 3cac015
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 12 deletions.
17 changes: 9 additions & 8 deletions src/simulations/results/results_plotting_video_utils.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
export plot_glacier_vid

function make_thickness_video(res::Results, glacier::Glacier2D, simuparams::SimulationParameters, pathVideo::String; framerate::Int=24, baseTitle::String="")
function make_thickness_video(H::Vector{Matrix{Float64}}, glacier::Glacier2D, simuparams::SimulationParameters, pathVideo::String; framerate::Int=24, baseTitle::String="")
lat = glacier.Coords["lat"]
lon = glacier.Coords["lon"]
H = res.H
mask = glacier.H₀ .!= 0
X, Y = GR.meshgrid(lon,lat)

Expand Down Expand Up @@ -41,20 +40,22 @@ end
"""
plot_glacier_vid(
plot_type::String,
results::T,
H::Vector{Matrix{Float64}},
glacier::Glacier2D,
simuparams::SimulationParameters,
pathVideo::String;
framerate::Int=24,
baseTitle::String=""
) where T
)
Generate various types of videos for glacier data.
# Arguments
- `plot_type`: Type of plot to generate. Options are:
* "thickness": Heatmap of the glacier thickness.
- `results`: A custom type containing the results of a glacier simulation.
- `H`: A vector of matrices containing the ice thickness over time. This should be
replaced by a Results instance in the future once Results no longer depends on
an iceflow model.
- `glacier`: A glacier instance.
- `simuparams`: The simulation parameters.
- `pathVideo`: Path of the mp4 file to generate.
Expand All @@ -66,16 +67,16 @@ Generate various types of videos for glacier data.
"""
function plot_glacier_vid(
plot_type::String,
results::T,
H::Vector{Matrix{Float64}},
glacier::Glacier2D,
simuparams::SimulationParameters,
pathVideo::String;
framerate::Int=24,
baseTitle::String=""
) where T
)

if plot_type == "thickness"
make_thickness_video(results, glacier, simuparams, pathVideo; framerate=framerate, baseTitle=baseTitle)
make_thickness_video(H, glacier, simuparams, pathVideo; framerate=framerate, baseTitle=baseTitle)
else
error("Invalid plot_type: $plot_type")
end
Expand Down
Binary file removed test/data/prediction/glaciers2D_test.jld2
Binary file not shown.
Binary file removed test/data/prediction/results2D_test.jld2
Binary file not shown.
Binary file removed test/data/prediction/simuparams2D_test.jld2
Binary file not shown.
29 changes: 25 additions & 4 deletions test/plot_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,32 @@ 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
rgi_ids = ["RGI60-11.03646"]
rgi_paths = get_rgi_paths()
working_dir = joinpath(Sleipnir.root_dir, "test/data")

params = Parameters(
simulation = SimulationParameters(
use_MB = true,
use_iceflow = true,
velocities = true,
use_glathida_data = false,
tspan = (2014.0, 2015.0),
working_dir = working_dir,
multiprocessing = true,
workers = 1,
rgi_paths = rgi_paths,
ice_thickness_source = "Farinotti19",
),
)

glaciers = initialize_glaciers(rgi_ids, params)

nSteps = (params.simulation.tspan[2]-params.simulation.tspan[1])/params.simulation.step
timeSteps = params.simulation.tspan[1].+collect(0:nSteps).*params.simulation.step
H = [rand(glaciers[1].nx, glaciers[1].ny) for t in timeSteps]

tempPath = mktempdir()*".mp4"

plot_glacier_vid("thickness", results[1], glaciers[1], simulation, tempPath; baseTitle="Bossons glacier")
plot_glacier_vid("thickness", H, glaciers[1], params.simulation, tempPath; baseTitle="Bossons glacier")
end

0 comments on commit 3cac015

Please sign in to comment.