From fc6b78c3375bfe1df02114401cc601ddf2bfb751 Mon Sep 17 00:00:00 2001 From: Marco Matthies <71844+marcom@users.noreply.github.com> Date: Thu, 7 Nov 2024 00:06:10 +0100 Subject: [PATCH] ALMaSS: avoid missing growth curves for low/high nutrients --- src/crop/almass.jl | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/crop/almass.jl b/src/crop/almass.jl index eff3ad0..c41353b 100644 --- a/src/crop/almass.jl +++ b/src/crop/almass.jl @@ -600,13 +600,21 @@ get_dddegs(model::SimulationModel) = bounds(supply_temperature(model)) # TODO efficiency: the fertiliser check is done in many places function growthcurve(cs::CropState) - curve = if fertiliser in cs.events - cs.croptype.highnutrientgrowth - else - cs.croptype.lownutrientgrowth + if ismissing(cs.croptype.lownutrientgrowth) && ismissing(cs.croptype.highnutrientgrowth) + error("No growth curves available for cropstate:\n $cs") end - if ismissing(curve) - error("Growth curve is missing for cropstate:\n $cs") + if fertiliser in cs.events + curve = cs.croptype.highnutrientgrowth + if ismissing(curve) + @warn "fertiliser used, but highnutrient growth curve is missing. Using lownutrient growth curve." + curve = cs.croptype.lownutrientgrowth + end + else + curve = cs.croptype.lownutrientgrowth + if ismissing(curve) + # @warn "fertiliser not used, but lownutrient growth curve is missing. Using highnutrient growth curve." + curve = cs.croptype.highnutrientgrowth + end end return curve end -- GitLab