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

AquaCrop: remove height field, and some cosmetics

parent b7a40304
No related branches found
No related tags found
No related merge requests found
......@@ -11,29 +11,29 @@ cropname(ct::AquaCropType) = ct.name
mutable struct AquaCropState
croptype::AquaCropType
height::Length{Float64} # TODO: remove height field, supply from cropstate
cropstate::AquaCrop.AquaCropField
acfield::AquaCrop.AquaCropField
function AquaCropState(croptype::AquaCropType, height::Length{Float64}=0.0cm)
function AquaCropState(croptype::AquaCropType)
# TODO: allow setting height on initialisation?
runtype = AquaCrop.TomlFileRun()
parentdir = AquaCrop.test_toml_dir # TODO: hardcoded croptype
ac_cropfield, all_ok = AquaCrop.start_cropfield(; parentdir, runtype)
acfield, all_ok = AquaCrop.start_cropfield(; parentdir, runtype)
if ! all_ok.logi
error("AquaCrop.start_cropfield() failed, status = $all_ok")
end
AquaCrop.setup_cropfield!(ac_cropfield, all_ok; runtype=runtype)
AquaCrop.setup_cropfield!(acfield, all_ok; runtype=runtype)
if ! all_ok.logi
error("AquaCrop.setup_cropfield!() failed, status = $all_ok")
end
return new(croptype, height, ac_cropfield)
return new(croptype, acfield)
end
end
croptype(cs::AquaCropState) = cs.croptype
cropname(cs::AquaCropState) = cropname(croptype(cs))
cropheight(cs::AquaCropState) = cs.height # TODO: use AquaCrop state info
cropcover(cs::AquaCropState) = AquaCrop.canopycover(cs.cropstate)
cropyield(cs::AquaCropState) = AquaCrop.dryyield(cs.cropstate) # TODO: there is also freshyield
cropheight(cs::AquaCropState) = 0.0cm # TODO: use AquaCrop state info
cropcover(cs::AquaCropState) = AquaCrop.canopycover(cs.acfield)
cropyield(cs::AquaCropState) = AquaCrop.dryyield(cs.acfield) # TODO: there is also freshyield
isharvestable(cs::AquaCropState) = true # TODO: implement this correctly
"""
......@@ -42,7 +42,7 @@ isharvestable(cs::AquaCropState) = true # TODO: implement this correctly
Update a crop state by one day.
"""
function stepagent!(cs::AquaCropState, model::SimulationModel)
AquaCrop.dailyupdate!(cs.cropstate)
AquaCrop.dailyupdate!(cs.acfield)
end
"""
......@@ -52,7 +52,6 @@ Change the cropstate to sow the specified crop.
"""
function sow!(cs::AquaCropState, model::SimulationModel, cropname::String)
cs.croptype = model.crops[cropname]
cs.height = 0.0cm
# TODO: other things needed for AquaCrop?
end
......
......@@ -82,7 +82,7 @@ function makecropstate(model::SimulationModel)
0.0m
)
elseif @param(crop.cropmodel) == "aquacrop"
cs = AquaCropState(model.crops["natural grass"], 0.0cm)
cs = AquaCropState(model.crops["natural grass"])
else
Base.error("Unhandled crop model '$(@param(crop.cropmodel))' in makecropstate().")
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment