Skip to content

Commit

Permalink
Merge pull request #770 from CliMA/kd/investigate_NaNs_sahara
Browse files Browse the repository at this point in the history
LAI lower threshold for nonzero LAI
  • Loading branch information
kmdeck authored Sep 17, 2024
2 parents b47ef0f + ffc37e2 commit 632d83d
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 35 deletions.
9 changes: 0 additions & 9 deletions experiments/benchmarks/land.jl
Original file line number Diff line number Diff line change
Expand Up @@ -473,21 +473,12 @@ function setup_prob(t0, tf, Δt; nelements = (101, 15))
)
)
# Set up plant hydraulics
# Note that we clip all values of LAI below 0.05 to zero.
# This is because we currently run into issues when LAI is
# of order eps(FT) in the SW radiation code.
# Please see Issue #644
# or PR #645 for details.
# For now, this clipping is similar to what CLM does.
LAIfunction = TimeVaryingInput(
joinpath(era5_artifact_path, "era5_lai_2021_0.9x1.25_clima.nc"),
"lai",
surface_space;
reference_date = start_date,
regridder_type,
file_reader_kwargs = (;
preprocess_func = (data) -> data > 0.05 ? data : 0.0,
),
)
ai_parameterization =
Canopy.PrescribedSiteAreaIndex{FT}(LAIfunction, SAI, RAI)
Expand Down
4 changes: 0 additions & 4 deletions experiments/integrated/global/global_soil_canopy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -226,16 +226,12 @@ photosynthesis_args = (;
parameters = Canopy.FarquharParameters(FT, Canopy.C3(); Vcmax25 = Vcmax25)
)
# Set up plant hydraulics
# Not ideal
LAIfunction = TimeVaryingInput(
joinpath(era5_artifact_path, "era5_lai_2021_0.9x1.25_clima.nc"),
"lai",
surface_space;
reference_date = start_date,
regridder_type,
file_reader_kwargs = (;
preprocess_func = (data) -> data > 0.05 ? data : 0.0,
),
)
ai_parameterization = Canopy.PrescribedSiteAreaIndex{FT}(LAIfunction, SAI, RAI)

Expand Down
11 changes: 1 addition & 10 deletions experiments/long_runs/land.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function setup_prob(t0, tf, Δt; outdir = outdir, nelements = (101, 15))
depth = depth,
nelements = nelements,
npolynomial = 1,
dz_tuple = FT.((10.0, 0.05)),# top layer should ideally be only a few cm!
dz_tuple = FT.((10.0, 0.05)),
)
surface_space = domain.space.surface
subsurface_space = domain.space.subsurface
Expand Down Expand Up @@ -483,21 +483,12 @@ function setup_prob(t0, tf, Δt; outdir = outdir, nelements = (101, 15))
)
# Set up plant hydraulics

# Note that we clip all values of LAI below 0.05 to zero.
# This is because we currently run into issues when LAI is
# of order eps(FT) in the SW radiation code.
# Please see Issue #644
# or PR #645 for details.
# For now, this clipping is similar to what CLM does.
LAIfunction = TimeVaryingInput(
joinpath(era5_artifact_path, "era5_lai_2021_0.9x1.25_clima.nc"),
"lai",
surface_space;
reference_date = start_date,
regridder_type,
file_reader_kwargs = (;
preprocess_func = (data) -> data > 0.05 ? data : 0.0,
),
method = time_interpolation_method,
)
ai_parameterization =
Expand Down
9 changes: 0 additions & 9 deletions experiments/long_runs/land_region.jl
Original file line number Diff line number Diff line change
Expand Up @@ -483,21 +483,12 @@ function setup_prob(t0, tf, Δt; outdir = outdir, nelements = (10, 10, 15))
)
# Set up plant hydraulics

# Note that we clip all values of LAI below 0.05 to zero.
# This is because we currently run into issues when LAI is
# of order eps(FT) in the SW radiation code.
# Please see Issue #644
# or PR #645 for details.
# For now, this clipping is similar to what CLM does.
LAIfunction = TimeVaryingInput(
joinpath(era5_artifact_path, "era5_lai_2021_0.9x1.25_clima.nc"),
"lai",
surface_space;
reference_date = start_date,
regridder_type,
file_reader_kwargs = (;
preprocess_func = (data) -> data > 0.05 ? data : 0.0,
),
method = time_interpolation_method,
)
ai_parameterization =
Expand Down
13 changes: 12 additions & 1 deletion src/standalone/Vegetation/PlantHydraulics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,9 @@ ClimaLand.auxiliary_types(model::PlantHydraulicsModel{FT}) where {FT} = (
ClimaLand.auxiliary_domain_names(::PlantHydraulicsModel) =
(:surface, :surface, :surface, :surface, :surface)


function clip(x::FT, threshold::FT) where {FT}
x > threshold ? x : FT(0)
end
"""
set_canopy_prescribed_field!(component::PlantHydraulics{FT},
p,
Expand All @@ -314,6 +316,13 @@ ClimaLand.auxiliary_domain_names(::PlantHydraulicsModel) =
Sets the canopy prescribed fields pertaining to the PlantHydraulics
component (the area indices) with their values at time t.
Note that we clip all values of LAI below 0.05 to zero.
This is because we currently run into issues when LAI is
of order eps(FT) in the SW radiation code.
Please see Issue #644
or PR #645 for details.
For now, this clipping is similar to what CLM and NOAH MP do.
"""
function ClimaLand.Canopy.set_canopy_prescribed_field!(
component::PlantHydraulicsModel{FT},
Expand All @@ -322,6 +331,8 @@ function ClimaLand.Canopy.set_canopy_prescribed_field!(
) where {FT}
(; LAIfunction, SAI, RAI) = component.parameters.ai_parameterization
evaluate!(p.canopy.hydraulics.area_index.leaf, LAIfunction, floor(t))
p.canopy.hydraulics.area_index.leaf .=
clip.(p.canopy.hydraulics.area_index.leaf, FT(0.05))
@. p.canopy.hydraulics.area_index.stem = SAI
@. p.canopy.hydraulics.area_index.root = RAI
end
Expand Down
10 changes: 8 additions & 2 deletions test/standalone/Vegetation/canopy_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -498,15 +498,21 @@ end
set_canopy_prescribed_field!(plant_hydraulics, p, FT(200))
@test all(
Array(parent(p.canopy.hydraulics.area_index.leaf)) .==
FT(LAI * sin(200 * 2π / 365)),
ClimaLand.Canopy.PlantHydraulics.clip(
FT(LAI * sin(200 * 2π / 365)),
FT(0.05),
),
)

set_canopy_prescribed_field!(Default{FT}(), p, t0)
set_canopy_prescribed_field!(Default{FT}(), p, t0)
# Test that they are unchanged
@test all(
parent(p.canopy.hydraulics.area_index.leaf) .==
FT(LAI * sin(200 * 2π / 365)),
ClimaLand.Canopy.PlantHydraulics.clip(
FT(LAI * sin(200 * 2π / 365)),
FT(0.05),
),
)
@test all(
Array(parent(p.canopy.hydraulics.area_index.stem)) .== FT(1.0),
Expand Down

0 comments on commit 632d83d

Please sign in to comment.