Skip to content

Commit 804c10e

Browse files
author
Fabian Bernhard
committed
fix: Edge cases of LAI=0 and IDEPTH_cm=0
1 parent 273d8f3 commit 804c10e

5 files changed

+11
-13
lines changed

Project.toml

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "LWFBrook90"
22
uuid = "100deb6c-4418-4b77-ad5c-a1fadb580743"
33
authors = ["Fabian Bernhard"]
4-
version = "0.9.1"
4+
version = "0.9.2"
55

66
[deps]
77
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
@@ -11,7 +11,6 @@ DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
1111
DataFramesMeta = "1313f7d8-7da2-5740-9ea0-a2ca25f37964"
1212
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
1313
DiffEqCallbacks = "459566f4-90b8-5000-8ac3-15dfb0a30def"
14-
DifferentialEquations = "0c46a032-eb83-5123-abaf-570d42b7fbaa"
1514
Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
1615
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1716
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
@@ -35,7 +34,6 @@ ComponentArrays = "0.13"
3534
DataFrames = "0.22, 1.1"
3635
DataFramesMeta = "0.6, 0.7, 0.8, 0.9, 0.10, 0.11, 0.12, 0.13"
3736
DiffEqCallbacks = "2"
38-
DifferentialEquations = "7"
3937
Interpolations = "0.13, 0.14"
4038
Literate = "2"
4139
Measures = "0.3"

src/LWFBrook90.jl

+1
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ include("../examples/func_run_example.jl") # defines RelativeDaysFloat2DateTime
181181
soil_output_depths_m::Vector = zeros(Float64, 0),
182182
kwargs...)
183183
or
184+
184185
remakeSPAC(parametrizedSPAC::SPAC;
185186
requested_tspan = nothing,
186187
soil_output_depths_m::Vector = zeros(Float64, 0),

src/func_discretize_soil_domain.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,8 @@ function refine_soil_discretization(
225225
# Define IDEPTH_idx and QDEPTH_idx (to be used internally instead of IDEPTH_m and QDEPTH_m)
226226
is_infiltration_layer_BOOLEAN = -IDEPTH_m .<= refined_soil_discr[!,"Lower_m"]
227227
is_SRFL_layer_BOOLEAN = -QDEPTH_m .<= refined_soil_discr[!,"Lower_m"]
228-
IDEPTH_idx = sum(is_infiltration_layer_BOOLEAN) # lowest node where Bottom_m is below IDEPTH_m
229-
QDEPTH_idx = sum(is_SRFL_layer_BOOLEAN) # lowest node where Bottom_m is below QDEPTH_m
228+
IDEPTH_idx = sum(is_infiltration_layer_BOOLEAN) # lowest node where Lower_m is below IDEPTH_m
229+
QDEPTH_idx = sum(is_SRFL_layer_BOOLEAN) # lowest node where Lower_m is below QDEPTH_m
230230

231231
if (-IDEPTH_m < refined_soil_discr[end,"Lower_m"]) ||
232232
(-QDEPTH_m < refined_soil_discr[end,"Lower_m"])
@@ -607,7 +607,7 @@ function HammelKennel_transient_root_density(;
607607
end
608608
end
609609

610-
# 2) In all cases provide relative density as interpolated funciton in depth and time (even when constant through time)
610+
# 2) In all cases provide relative density as interpolated function in depth and time (even when constant through time)
611611
p_fT_RELDEN = extrapolate(interpolate((timepoints, 1:NLAYER), p_RELDEN_2Darray,
612612
(Gridded(Constant{Next}()), NoInterp()), # 1st dimension: ..., 2nd dimension NoInterp()
613613
), Flat()) # extrapolate flat, alternative: Throw()

src/func_read_inputData.jl

+5-6
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ function loadSPAC(folder::String, prefix::String;
123123
"LAI" in names(input_meteoveg) && "SAI" in names(input_meteoveg))
124124
_to_use_canopy_evolution = input_meteoveg[:, [:days, :DENSEF, :HEIGHT, :LAI, :SAI]] # store DataFrame in SPAC
125125
# Assert validity of vegetation values
126-
@assert all(_to_use_canopy_evolution.LAI .> 0) "Error in vegetation parameters: LAI must be above 0%."
126+
@assert all(_to_use_canopy_evolution.LAI .>= 0) "Error in vegetation parameters: LAI must be above 0%."
127127
else
128128
error("""
129129
Input_meteoveg is expected to contain one or multiple of the columns: :DENSEF, :HEIGHT, :LAI, or :SAI.
@@ -145,8 +145,8 @@ function loadSPAC(folder::String, prefix::String;
145145

146146
_to_use_canopy_evolution = canopy_evolution # store parameter arguments in SPAC
147147
# Assert validity of vegetation values
148-
@assert all(_to_use_canopy_evolution.LAI.LAI_perc_BtoC > 0) "Error in vegetation parameters: LAI must be above 0%."
149-
@assert all(_to_use_canopy_evolution.LAI.LAI_perc_CtoB > 0) "Error in vegetation parameters: LAI must be above 0%."
148+
@assert all(_to_use_canopy_evolution.LAI.LAI_perc_BtoC >= 0) "Error in vegetation parameters: LAI must be above 0%."
149+
@assert all(_to_use_canopy_evolution.LAI.LAI_perc_CtoB >= 0) "Error in vegetation parameters: LAI must be above 0%."
150150
end
151151

152152
# Assert validity of vegetation values
@@ -850,10 +850,9 @@ function read_path_soil_horizons(path_soil_horizons)
850850
ClappHornberger_expected_column_names =
851851
["HorizonNr","Upper_m","Lower_m","thsat_volFrac","thetaf_volFrac","psif_kPa","bexp_","kf_mmDay","wtinf_","gravel_volFrac"]
852852

853-
854-
if String.(propertynames(File(path_soil_horizons))) == MualVanGen_expected_column_names
853+
if strip.(String.(propertynames(File(path_soil_horizons)))) == MualVanGen_expected_column_names
855854
FLAG_MualVanGen = 1
856-
elseif String.(propertynames(File(path_soil_horizons))) == ClappHornberger_expected_column_names
855+
elseif strip.(String.(propertynames(File(path_soil_horizons)))) == ClappHornberger_expected_column_names
857856
FLAG_MualVanGen = 0
858857
else
859858
error("""

src/module_WAT.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Compute fraction of infiltration to each soil layer.
5858
"""
5959
function INFPAR(p_INFEXP, p_ILAYER, p_soil)
6060
p_INFRAC = fill(NaN, p_soil.NLAYER) # fraction of infiltration to each layer
61-
if p_INFEXP <= 0
61+
if (p_INFEXP <= 0 || p_ILAYER <= 0)
6262
p_INFRAC[1] = 1
6363
p_INFRAC[2:p_soil.NLAYER] .= 0
6464
else

0 commit comments

Comments
 (0)