Skip to content

Commit

Permalink
snowy land
Browse files Browse the repository at this point in the history
  • Loading branch information
kmdeck committed Oct 25, 2024
1 parent 87879a4 commit 100c81a
Show file tree
Hide file tree
Showing 23 changed files with 1,986 additions and 404 deletions.
10 changes: 10 additions & 0 deletions .buildkite/longruns_gpu/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ steps:
- group: "Global Land Models"
steps:

- label: "Snowy Land"
command:
- julia --color=yes --project=.buildkite experiments/long_runs/snowy_land.jl
artifact_paths: "snowy_land_longrun_gpu/*png"
agents:
slurm_gpus: 1
slurm_time: 03:30:00
env:
CLIMACOMMS_DEVICE: "CUDA"

- label: ":seedling: Soil-Canopy"
command:
- julia --color=yes --project=.buildkite experiments/long_runs/land.jl
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
experiments/integrated/fluxnet/out/*
experiments/integrated/fluxnet/US-*/out/*
*.nc
experiments/integrated/fluxnet/out/*
*.png
*.mp4
*.hdf5
Expand Down
2 changes: 1 addition & 1 deletion experiments/integrated/fluxnet/US-Ha1/US-Ha1_simulation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ h_stem = FT(14) # m
# TIME STEPPING:

# Starting time:
t0 = Float64(120 * 3600 * 24)# start mid year to avoid snow
t0 = Float64(0 * 3600 * 24)

# Time step size:
dt = Float64(450)
4 changes: 2 additions & 2 deletions experiments/integrated/fluxnet/US-MOz/US-MOz_simulation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ h_leaf = FT(9.5) # m
# TIME STEPPING:

# Starting time:
t0 = Float64(120 * 3600 * 24)# start mid year to avoid snow
t0 = Float64(0 * 3600 * 24)

# Time step size:
dt = Float64(900)
dt = Float64(450)
4 changes: 2 additions & 2 deletions experiments/integrated/fluxnet/US-NR1/US-NR1_simulation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ h_stem = FT(7.5) # m
# TIME STEPPING:

# Starting time:
t0 = Float64(120 * 3600 * 24)# start mid year to avoid snow
t0 = Float64(0 * 3600 * 24)

# Time step size:
dt = Float64(450)
dt = Float64(225)
2 changes: 1 addition & 1 deletion experiments/integrated/fluxnet/US-Var/US-Var_simulation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ h_stem = FT(0) # m
# TIME STEPPING:

# Starting time:
t0 = Float64(21 * 3600 * 24)# start day 21 of the year
t0 = Float64(0 * 3600 * 24)

# Time step size:
dt = Float64(900)
5 changes: 3 additions & 2 deletions experiments/integrated/fluxnet/fluxnet_simulation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
fluxtower sites. These work in tandem with the site-specific timing parameters
found in the {site-ID}_simulation.jl files in each site directory."""

N_spinup_days = 30
N_days = N_spinup_days + 30
N_spinup_days = 15
N_days = N_spinup_days + 340

tf = Float64(t0 + 3600 * 24 * N_days)
t_spinup = Float64(t0 + N_spinup_days * 3600 * 24)

Expand Down
1 change: 0 additions & 1 deletion experiments/integrated/fluxnet/ozark_pft.jl
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,6 @@ data_times = Array(0:DATA_DT:(num_days * S_PER_DAY)) .+ t_spinup
# Plotting
savedir =
generate_output_path("experiments/integrated/fluxnet/$site_ID/out/pft/")

if !isdir(savedir)
mkdir(savedir)
end
Expand Down
56 changes: 46 additions & 10 deletions experiments/integrated/fluxnet/run_fluxnet.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ using StatsBase

using ClimaLand
using ClimaLand.Domains: Column
using ClimaLand.Snow
using ClimaLand.Soil
using ClimaLand.Soil.Biogeochemistry
using ClimaLand.Canopy
Expand Down Expand Up @@ -186,14 +187,26 @@ shared_params = SharedCanopyParameters{FT, typeof(earth_param_set)}(
)

canopy_model_args = (; parameters = shared_params, domain = canopy_domain)

# Snow model
ρ_snow = FT(300.0)
α_snow = FT(0.8)
snow_parameters = SnowParameters{FT}(
dt;
α_snow = α_snow,
ρ_snow = ρ_snow,
earth_param_set = earth_param_set,
);
snow_args = (; parameters = snow_parameters, domain = canopy_domain);
snow_model_type = Snow.SnowModel
# Integrated plant hydraulics and soil model
land_input = (
atmos = atmos,
radiation = radiation,
soil_organic_carbon = Csom,
runoff = ClimaLand.Soil.Runoff.SurfaceRunoff(),
)
land = SoilCanopyModel{FT}(;
land = LandModel{FT}(;
soilco2_type = soilco2_type,
soilco2_args = soilco2_args,
land_args = land_input,
Expand All @@ -202,6 +215,8 @@ land = SoilCanopyModel{FT}(;
canopy_component_types = canopy_component_types,
canopy_component_args = canopy_component_args,
canopy_model_args = canopy_model_args,
snow_args = snow_args,
snow_model_type = snow_model_type,
)

Y, p, cds = initialize(land)
Expand Down Expand Up @@ -240,6 +255,10 @@ for i in 1:(n_stem + n_leaf)
end

Y.canopy.energy.T = drivers.TA.values[1 + Int(round(t0 / DATA_DT))] # Get atmos temperature at t0

Y.snow.S .= 0.0
Y.snow.U .= 0.0

set_initial_cache! = make_set_initial_cache(land)
set_initial_cache!(p, Y, t0);

Expand Down Expand Up @@ -309,6 +328,7 @@ short_names_1D = [
"lhf", # LHF
"ghf", # G
"rn", # Rn
"swe",
]
short_names_2D = [
"swc", # swc_sfc or swc_5 or swc_10
Expand All @@ -323,11 +343,11 @@ hourly_diag_name_2D = short_names_2D .* "_1h_average"
# diagnostic_as_vectors()[2] is a vector of a variable,
# whereas diagnostic_as_vectors()[1] is a vector or time associated with that variable.
# We index to only extract the period post-spinup.
SIF, AR, g_stomata, GPP, canopy_T, SW_u, LW_u, ER, ET, β, SHF, LHF, G, Rn = [
ClimaLand.Diagnostics.diagnostic_as_vectors(d_writer, diag_name)[2][(N_spinup_days * 24):end]
for diag_name in hourly_diag_name
]

SIF, AR, g_stomata, GPP, canopy_T, SW_u, LW_u, ER, ET, β, SHF, LHF, G, Rn, SWE =
[
ClimaLand.Diagnostics.diagnostic_as_vectors(d_writer, diag_name)[2][(N_spinup_days * 24):end]
for diag_name in hourly_diag_name
]

swc, soil_T, si = [
ClimaLand.Diagnostics.diagnostic_as_vectors(
Expand Down Expand Up @@ -510,7 +530,7 @@ if isfile(
)
end

# Water content in soil
# Water content in soil and snow
# Soil water content
# Current resolution has the first layer at 0.1 cm, the second at 5cm.
plt1 = Plots.plot(size = (1500, 800))
Expand Down Expand Up @@ -546,7 +566,23 @@ if drivers.SWC.status != absent
label = "Data",
)
end
plt2 = Plots.plot(
plt2 = Plots.plot(size = (1500, 800))
Plots.plot!(
plt2,
model_times ./ 3600 ./ 24,
SWE,
label = "Model",
xlim = [
minimum(model_times ./ 3600 ./ 24),
maximum(model_times ./ 3600 ./ 24),
],
ylim = [0.0, 0.15],
xlabel = "Days",
ylabel = "SWE [m]",
color = "blue",
margin = 10Plots.mm,
)
plt3 = Plots.plot(
data_times ./ 3600 ./ 24,
(drivers.P.values .* (-1e3 * 24 * 3600) .* (1 .- snow_frac))[data_id_post_spinup],
label = "Rain (data)",
Expand All @@ -560,13 +596,13 @@ plt2 = Plots.plot(
size = (1500, 400),
)
Plots.plot!(
plt2,
plt3,
data_times ./ 3600 ./ 24,
(drivers.P.values .* (-1e3 * 24 * 3600) .* snow_frac)[data_id_post_spinup],
label = "Snow (data)",
ylabel = "Precipitation [mm/day]",
)
Plots.plot(plt2, plt1, layout = grid(2, 1, heights = [0.3, 0.7]))
Plots.plot(plt3, plt2, plt1, layout = grid(3, 1, heights = [0.2, 0.4, 0.4]))
Plots.savefig(joinpath(savedir, "ground_water_content.png"))

plt1 = Plots.plot(size = (1500, 800))
Expand Down
Loading

0 comments on commit 100c81a

Please sign in to comment.