From 5c43480aafdbf5c29c10b935e6000dcbc2443a83 Mon Sep 17 00:00:00 2001 From: ftomei Date: Fri, 27 Oct 2023 17:32:57 +0200 Subject: [PATCH] add daily update crop --- crop/crop.cpp | 10 ++++++++-- crop/crop.h | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/crop/crop.cpp b/crop/crop.cpp index 5dd70b5bc..6d3b37bc1 100644 --- a/crop/crop.cpp +++ b/crop/crop.cpp @@ -152,11 +152,17 @@ void Crit3DCrop::initialize(double latitude, unsigned int nrLayers, double total } -double Crit3DCrop::getDailyDegreeIncrease(double tmin, double tmax) +double Crit3DCrop::getDailyDegreeIncrease(double tmin, double tmax, int doy) { if (isEqual(tmin, NODATA) || isEqual(tmax, NODATA)) return NODATA; + // check crop cycle + if (isSowingCrop() && ! isInsideTypicalCycle(doy)) + { + return 0; + } + double tmed = (tmin + MINVALUE(tmax, upperThermalThreshold)) * 0.5; return MAXVALUE(tmed - thermalThreshold, 0); } @@ -297,7 +303,7 @@ int Crit3DCrop::getDaysFromCurrentSowing(int myDoy) const bool Crit3DCrop::isInsideTypicalCycle(int myDoy) const { - return (myDoy >= sowingDoy && getDaysFromTypicalSowing(myDoy) < plantCycle); + return (getDaysFromTypicalSowing(myDoy) < plantCycle); } diff --git a/crop/crop.h b/crop/crop.h index 0301d45a1..1d4561e53 100644 --- a/crop/crop.h +++ b/crop/crop.h @@ -81,7 +81,7 @@ bool isSowingCrop() const; bool isRootStatic() const; - double getDailyDegreeIncrease(double tmin, double tmax); + double getDailyDegreeIncrease(double tmin, double tmax, int doy); void initialize(double latitude, unsigned int nrLayers, double totalSoilDepth, int currentDoy); bool needReset(Crit3DDate myDate, double latitude, double waterTableDepth);