From 2ee7e39f1581cf8bd8787a684d80de8e6def2c79 Mon Sep 17 00:00:00 2001
From: Marco Matthies <71844+marcom@users.noreply.github.com>
Date: Fri, 14 Mar 2025 10:53:06 +0100
Subject: [PATCH] Remove old height var

---
 src/crop/aquacrop.jl | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/src/crop/aquacrop.jl b/src/crop/aquacrop.jl
index 54d12a9..9a6dc72 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
-- 
GitLab