Skip to content
Snippets Groups Projects
Commit 892abe23 authored by Marco Matthies's avatar Marco Matthies
Browse files

Try to better set maturity for maize (and other late crops)

parent ffe37c33
No related branches found
No related tags found
No related merge requests found
......@@ -67,7 +67,6 @@ function Base.show(io::IO, ::MIME"text/plain", curve::CropCurveParams)
(curve.GDD, "GDD"),
(curve.LAItotal, "LAItotal"),
(curve.LAIgreen, "LAIgreen"),
# (curve.height, "height"),
]
println(" $name:")
for (phase, arr) in dict
......@@ -333,8 +332,9 @@ function growcrop!(cs::CropState, delta_gdd::Real, model::SimulationModel)
error("Missing curve")
end
points = curve.GDD[cs.phase]
if length(points) == 1 && points[1] == 99999.0
!(cs.phase in (janfirst, sow)) && (cs.mature = true) #FIXME only in the last phase?
!(cs.phase in (janfirst, sow)) && (cs.mature = true) # FIXME only in the last phase?
return # the marker that there is no further growth this phase
end
......@@ -344,14 +344,25 @@ function growcrop!(cs::CropState, delta_gdd::Real, model::SimulationModel)
idx = findfirst(x -> x > total_gdd, points)
if isnothing(idx)
idx = lastindex(points)
# elseif idx != firstindex(points)
# idx -= 1 # we need the last index that is not > total_gdd
elseif idx != firstindex(points)
idx -= 1 # we need the last index that is smaller than total_gdd
end
cs.height += curve.height[cs.phase][idx] * delta_gdd
cs.LAItotal += curve.LAItotal[cs.phase][idx] * delta_gdd
cs.LAIgreen += curve.LAIgreen[cs.phase][idx] * delta_gdd
#if cs.phase == janfirst && length(points
function lastphase(cs::CropState)
if cs.croptype.name == "maize"
return sow
else
return marchfirst
end
end
# set mature if it's the last growth point of the last phase
if idx == lastindex(points) && cs.phase == lastphase(cs)
cs.mature = true
end
end
end # module ALMaSS
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment