Skip to content

Commit

Permalink
add lwp data
Browse files Browse the repository at this point in the history
  • Loading branch information
kmdeck committed May 31, 2023
1 parent 2c42185 commit 3ae34b7
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 29 deletions.
79 changes: 54 additions & 25 deletions experiments/LSM/ozark/ozark.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ end

plant_hydraulics_ps = PlantHydraulics.PlantHydraulicsParameters(;
area_index = area_index,
plant_ν = plant_ν,
plant_S_s = plant_S_s,
ν = plant_ν,
S_s = plant_S_s,
root_distribution = root_distribution,
conductivity_model = conductivity_model,
retention_model = retention_model,
Expand Down Expand Up @@ -336,6 +336,46 @@ plt2 = Plots.plot(
Plots.plot(plt2, plt1, layout = (2, 1))
Plots.savefig(joinpath(savedir, "soil_water_content.png"))

dt_model = sol.t[2] - sol.t[1]
dt_data = seconds[2] - seconds[1]
Plots.plot(daily, cumsum(T) * dt_model, label = "Model T")
Plots.plot!(
seconds ./ 24 ./ 3600,
cumsum(measured_T[:]) * dt_data,
label = "Data ET",
)
Plots.plot!(
seconds ./ 24 ./ 3600,
cumsum(P[:]) * dt_data * (1e3 * 24 * 3600),
label = "Data P",
)
Plots.plot!(ylabel = "∫ Water fluxes dt", xlabel = "Days", margins = 10Plots.mm)
Plots.savefig(joinpath(savedir, "cumul_p_et.png"))

# Leaf water potential data from Pallardy et al (2018)
# Predawn Leaf Water Potential of Oak-Hickory Forest at Missouri Ozark (MOFLUX) Site: 2004-2020
# https://doi.org/10.3334/CDIAC/ORNLSFA.004
lwp_filename = "MOFLUX_PredawnLeafWaterPotential_2020_20210125.csv"
lwp_artifact = ArtifactFile(
url = "https://caltech.box.com/shared/static/d2nbhezw1q99vslnh5qfwnqrnp3p4edo.csv",
filename = lwp_filename,
)
lwp_dataset = ArtifactWrapper(
@__DIR__,
"lwp_pallardy_etal2018",
ArtifactFile[lwp_artifact],
);

lwp_path = joinpath(get_data_folder(lwp_dataset), lwp_filename)
lwp_data = readdlm(lwp_path, ',', skipstart = 1)
# We are using 2005 data in this test, so restrict to this year
YEAR = lwp_data[:, 1]
DOY = lwp_data[YEAR .== 2005, 2]
# Our t0 = Dec 31, midnight, 2004. Predawn = guess of 0600 hours
seconds_since_t0 = FT.(DOY) * 24 .* 3600 .+ (6 * 3600)
lwp_measured = lwp_data[YEAR .== 2005, 7] .* 1e6 # MPa to Pa


root_stem_flux = [
sum(sv.saveval[k].root_extraction) .* (1e3 * 3600 * 24) for
k in 1:length(sol.t)
Expand All @@ -353,15 +393,15 @@ leaf_air_flux = [

plt1 = Plots.plot(
daily,
root_stem_flux,
label = "Soil-root-stem flux",
leaf_air_flux,
label = "Leaf-air flux",
ylabel = "Within plant fluxes[mm/day]",
xlim = [minimum(daily), maximum(daily)],
size = (500, 700),
margins = 10Plots.mm,
)
Plots.plot!(plt1, daily, stem_leaf_flux, label = "Stem-leaf flux")
Plots.plot!(plt1, daily, leaf_air_flux, label = "Leaf-air flux")
Plots.plot!(plt1, daily, root_stem_flux, label = "Soil-root-stem flux")

lwp = [
parent(sv.saveval[k].canopy.hydraulics.ψ)[2] * 9800 for k in 1:length(sol.t)
Expand All @@ -373,35 +413,24 @@ swp = [
plt2 = Plots.plot(
daily,
lwp,
label = "Leaf",
label = "Model, Leaf",
xlim = [minimum(daily), maximum(daily)],
xlabel = "days",
ylabel = "Water potential (Pa)",
size = (500, 700),
left_margin = 10Plots.mm,
)
Plots.plot!(plt2, daily, swp, label = "Model, Stem")

Plots.plot!(plt2, daily, swp, label = "Stem")

Plots.plot(plt2, plt1, layout = (2, 1))
Plots.savefig(joinpath(savedir, "plant_hydraulics.png"))


dt_model = sol.t[2] - sol.t[1]
dt_data = seconds[2] - seconds[1]
Plots.plot(daily, cumsum(T) * dt_model, label = "Model T")
Plots.plot!(
seconds ./ 24 ./ 3600,
cumsum(measured_T[:]) * dt_data,
label = "Data ET",
)
Plots.plot!(
seconds ./ 24 ./ 3600,
cumsum(P[:]) * dt_data * (1e3 * 24 * 3600),
label = "Data P",
plt2,
seconds_since_t0 ./ 24 ./ 3600,
lwp_measured,
label = "Data; all species",
)
Plots.plot!(ylabel = "∫ Water fluxes dt", xlabel = "Days", margins = 10Plots.mm)
Plots.savefig(joinpath(savedir, "cumul_p_et.png"))


Plots.plot(plt2, plt1, layout = (2, 1))
Plots.savefig(joinpath(savedir, "plant_hydraulics.png"))

rm(joinpath(savedir, "Artifacts.toml"))
4 changes: 2 additions & 2 deletions test/Vegetation/canopy_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ include(joinpath(pkgdir(ClimaLSM), "parameters", "create_parameters.jl"))
end
plant_hydraulics_ps = PlantHydraulics.PlantHydraulicsParameters(;
area_index = area_index,
plant_ν = plant_ν,
plant_S_s = plant_S_s,
ν = plant_ν,
S_s = plant_S_s,
root_distribution = root_distribution,
conductivity_model = conductivity_model,
retention_model = retention_model,
Expand Down
4 changes: 2 additions & 2 deletions test/Vegetation/plant_hydraulics_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ include(joinpath(pkgdir(ClimaLSM), "parameters", "create_parameters.jl"))

param_set = PlantHydraulics.PlantHydraulicsParameters(;
area_index = area_index,
plant_ν = plant_ν,
plant_S_s = plant_S_s,
ν = plant_ν,
S_s = plant_S_s,
root_distribution = root_distribution,
conductivity_model = conductivity_model,
retention_model = retention_model,
Expand Down

0 comments on commit 3ae34b7

Please sign in to comment.