Skip to content

Commit

Permalink
Merge pull request #1053 from CliMA/js/cleanup
Browse files Browse the repository at this point in the history
clean up viz_explorer.jl
  • Loading branch information
juliasloan25 authored Nov 5, 2024
2 parents d71eb7d + a401769 commit 91878a6
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 46 deletions.
9 changes: 0 additions & 9 deletions experiments/ClimaEarth/components/land/climaland_bucket.jl
Original file line number Diff line number Diff line change
Expand Up @@ -345,15 +345,6 @@ function make_land_domain(
return CL.Domains.SphericalShell{FT}(radius, depth, nothing, nelements, npolynomial, space, fields)
end

"""
get_land_temp_from_state(land_sim, u)
Returns the surface temperature of the earth, computed from the state u.
"""
function get_land_temp_from_state(land_sim, u)
# required by viz_explorer.jl
return CL.surface_temperature(land_sim.model, u, land_sim.integrator.p, land_sim.integrator.t)
end

"""
dss_state!(sim::BucketSimulation)
Expand Down
75 changes: 38 additions & 37 deletions experiments/ClimaEarth/user_io/viz_explorer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ import ClimaCoupler: Regridder
function plot_anim(cs, out_dir = ".")

atmos_sim = cs.model_sims.atmos_sim
slab_land_sim = cs.model_sims.land_sim
slab_ocean_sim = cs.model_sims.ocean_sim
slab_ice_sim = cs.model_sims.ice_sim
land_sim = cs.model_sims.land_sim
ocean_sim = cs.model_sims.ocean_sim
ice_sim = cs.model_sims.ice_sim
mode_name = cs.mode.name
SST = cs.fields.T_S

# plot the lowest atmos (center) levels of key variables
sol_atm = atmos_sim.integrator.sol
Expand Down Expand Up @@ -38,12 +37,16 @@ function plot_anim(cs, out_dir = ".")

# plot combined surfaces
combined_field = zeros(boundary_space)
sol_slab = slab_land_sim.integrator.sol
FT = CC.Spaces.undertype(boundary_space)

land_T_sfc = Interfacer.get_field(cs.model_sims.land_sim, Val(:surface_temperature))
SST = cs.fields.T_S

# Surface temperature plots
if mode_name == "slabplanet"
sol_slab_ocean = slab_ocean_sim.integrator.sol
anim = Plots.@animate for (bucketu, oceanu) in zip(sol_slab.u, sol_slab_ocean.u)
land_T_sfc = get_land_temp_from_state(cs.model_sims.land_sim, bucketu)
# Ocean surface temperature
sol_ocean = ocean_sim.integrator.sol
anim_T = Plots.@animate for oceanu in sol_ocean.u
Regridder.combine_surfaces_from_sol!(
combined_field,
surface_fractions,
Expand All @@ -52,9 +55,9 @@ function plot_anim(cs, out_dir = ".")
Plots.plot(combined_field)
end
elseif mode_name == "slabplanet_eisenman"
slab_ice_sim = slab_ice_sim.integrator.sol
anim = Plots.@animate for (bucketu, iceu) in zip(sol_slab.u, slab_ice_sim.u)
land_T_sfc = get_land_temp_from_state(cs.model_sims.land_sim, bucketu)
# Ice surface temperature
sol_ice = ice_sim.integrator.sol
anim_T = Plots.@animate for iceu in sol_ice.u
Regridder.combine_surfaces_from_sol!(
combined_field,
surface_fractions,
Expand All @@ -63,10 +66,21 @@ function plot_anim(cs, out_dir = ".")
Plots.plot(combined_field)
end

# Ice height
sol_ice = ice_sim.integrator.sol
anim = Plots.@animate for sol_iceu in sol_ice.u
Regridder.combine_surfaces_from_sol!(
combined_field,
surface_fractions,
(; land = FT(0), ocean = FT(0), ice = sol_iceu.h_ice),
)
Plots.plot(combined_field)
end
Plots.mp4(anim, joinpath(out_dir, "eisenman_seaice.mp4"), fps = 10)
elseif mode_name == "amip"
sol_slab_ice = slab_ice_sim.integrator.sol
anim = Plots.@animate for (bucketu, iceu) in zip(sol_slab.u, sol_slab_ice.u)
land_T_sfc = get_land_temp_from_state(cs.model_sims.land_sim, bucketu)
# Ice surface temperature
sol_ice = ice_sim.integrator.sol
anim_T = Plots.@animate for iceu in sol_ice.u
Regridder.combine_surfaces_from_sol!(
combined_field,
surface_fractions,
Expand All @@ -75,43 +89,30 @@ function plot_anim(cs, out_dir = ".")
Plots.plot(combined_field)
end
end
Plots.mp4(anim, joinpath(out_dir, "earth_T.mp4"), fps = 10)
Plots.mp4(anim_T, joinpath(out_dir, "earth_T.mp4"), fps = 10)

combined_field = zeros(boundary_space)
anim = Plots.@animate for bucketu in sol_slab.u
# Land surface plots
sol_land = land_sim.integrator.sol

# Water content
anim = Plots.@animate for bucketu in sol_land.u
Regridder.combine_surfaces_from_sol!(
combined_field,
surface_fractions,
(; land = bucketu.bucket.W, ocean = 0.0, ice = 0.0),
(; land = bucketu.bucket.W, ocean = FT(0), ice = FT(0)),
)
Plots.plot(combined_field)
end
Plots.mp4(anim, joinpath(out_dir, "bucket_W.mp4"), fps = 10)

combined_field = zeros(boundary_space)
anim = Plots.@animate for bucketu in sol_slab.u
# Snow cover fraction
anim = Plots.@animate for bucketu in sol_land.u
Regridder.combine_surfaces_from_sol!(
combined_field,
surface_fractions,
(; land = bucketu.bucket.σS, ocean = 0.0, ice = 0.0),
(; land = bucketu.bucket.σS, ocean = FT(0), ice = FT(0)),
)
Plots.plot(combined_field)
end
Plots.mp4(anim, joinpath(out_dir, "bucket_snow.mp4"), fps = 10)

if mode_name == "slabplanet_eisenman"
sol_ice = cs.model_sims.ice_sim.integrator.sol
combined_field = zeros(boundary_space)
anim = Plots.@animate for sol_iceu in sol_ice.u
Regridder.combine_surfaces_from_sol!(
combined_field,
surface_fractions,
(; land = 0.0, ocean = 0.0, ice = sol_iceu.h_ice),
)
Plots.plot(combined_field)
end
Plots.mp4(anim, joinpath(out_dir, "eisenman_seaice.mp4"), fps = 10)
end
# plot surface fluxes
# TODO as part of the flux accumulation PR
end

0 comments on commit 91878a6

Please sign in to comment.