diff --git a/src/crop/aquacrop.jl b/src/crop/aquacrop.jl index 54d12a99d91ac339ac0f3fb025b4fb677dbfc9ae..9a6dc7233b46af0ed0cbf22c8e21ab62300bbed0 100644 --- a/src/crop/aquacrop.jl +++ b/src/crop/aquacrop.jl @@ -35,9 +35,6 @@ import Persefone: using Unitful: @u_str -# We can't use Length{Float64} as that is a Union type -const Tlength = typeof(1.0cm) - # TODO: read crop names directly from AquaCrop.jl # names extracted by running this command in the AquaCrop.jl src dir: # grep -nir 'crop_type ==' src/ | cut -d '=' -f 3 | sed 's/$/,/' | sort | uniq @@ -172,20 +169,18 @@ end mutable struct CropState <: AbstractCropState croptype::CropType - height::Tlength # TODO: remove height field, supply from cropstate soiltype::SoilType cropstate::AquaCrop.AquaCropField - function CropState(croptype::CropType, model::SimulationModel, - soiltype::SoilType, height::Tlength=0.0cm) - aquacrop_cropfield = make_aquacrop_cropfield(croptype, model, soiltype) - return new(croptype, height, soiltype, aquacrop_cropfield) - end + CropState(croptype::CropType, model::SimulationModel, soiltype::SoilType) = + new(croptype, soiltype, make_aquacrop_cropfield(croptype, model, soiltype)) end croptype(cs::CropState) = cs.croptype cropname(cs::CropState) = cropname(croptype(cs)) function cropheight(cs::CropState) + # AquaCrop does not explicitly model crop height, so we have to + # estimate crop height from biomass biomass = get_aquacrop_biomass(cs) # TODO: linear model, fixed params a = 2cm @@ -241,7 +236,6 @@ function sow!(cs::CropState, model::SimulationModel, cropname::String) end cs.croptype = new_croptype - cs.height = 0.0cm # cs.soiltype stays the way it is cs.cropstate = make_aquacrop_cropfield(cs.croptype, model, soiltype) end