From 88d703c81387e74e4164481453ac28f3f25091cb Mon Sep 17 00:00:00 2001 From: Tor-Einar Skog <tor-einar.skog@bioforsk.no> Date: Thu, 2 Jan 2014 15:26:06 +0100 Subject: [PATCH] Setting ASCMAT value only once per day --- .../vips/model/applescabmodel/AppleScabModel.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/no/bioforsk/vips/model/applescabmodel/AppleScabModel.java b/src/main/java/no/bioforsk/vips/model/applescabmodel/AppleScabModel.java index 415f05a..f244862 100644 --- a/src/main/java/no/bioforsk/vips/model/applescabmodel/AppleScabModel.java +++ b/src/main/java/no/bioforsk/vips/model/applescabmodel/AppleScabModel.java @@ -100,7 +100,7 @@ public class AppleScabModel extends I18nImpl implements Model{ { Result result = new ResultImpl(); result.setResultValidTime(timeStamp); - result.setValue(AppleScabCalculations.ASCOSPORE_MATURITY, String.valueOf(this.calculations.getParamDoubleValueForDate(timeStamp, AppleScabCalculations.ASCOSPORE_MATURITY))); + result.setValue(AppleScabCalculations.ASCOSPORE_MATURITY, this.calculations.getParamDoubleValueForDate(timeStamp, AppleScabCalculations.ASCOSPORE_MATURITY) != null ? String.valueOf(this.calculations.getParamDoubleValueForDate(timeStamp, AppleScabCalculations.ASCOSPORE_MATURITY)) : ""); result.setValue(AppleScabCalculations.ACCUMULATED_MILLS, String.valueOf(this.calculations.getParamDoubleValueForDate(timeStamp, AppleScabCalculations.ACCUMULATED_MILLS))); result.setValue(AppleScabCalculations.TM, String.valueOf(this.calculations.getParamDoubleValueForDate(timeStamp, AppleScabCalculations.TM))); result.setValue(AppleScabCalculations.BT, String.valueOf(this.calculations.getParamDoubleValueForDate(timeStamp, AppleScabCalculations.BT))); @@ -134,7 +134,7 @@ public class AppleScabModel extends I18nImpl implements Model{ { return Result.WARNING_STATUS_NO_WARNING; } - else if(this.calculations.getParamDoubleValueForDate(timeStamp, AppleScabCalculations.ASCOSPORE_MATURITY) == 100d) + else if(this.calculations.getParamDoubleValueForDate(this.weatherUtil.normalizeToExactDate(timeStamp, this.timeZone), AppleScabCalculations.ASCOSPORE_MATURITY) == 100d) { return Result.WARNING_STATUS_NO_WARNING; } @@ -347,8 +347,12 @@ public class AppleScabModel extends I18nImpl implements Model{ { currentAppleScabStadium = APPLE_SCAB_STADIUM_CONIDIA; } - ascosporeMaturity = ascosporeMaturityTable.getAscosporeMaturity(this.getAccumulatedTemperature(currentTimeStamp)); - this.calculations.setParamDoubleValueForDate(currentTimeStamp, AppleScabCalculations.ASCOSPORE_MATURITY, ascosporeMaturity); + // We update and store the ascospore maturity only at midnight, when we have an updated accumulated temperature + if(currentTimeStamp.equals(this.weatherUtil.normalizeToExactDate(currentTimeStamp, this.timeZone))) + { + ascosporeMaturity = ascosporeMaturityTable.getAscosporeMaturity(this.getAccumulatedTemperature(currentTimeStamp)); + this.calculations.setParamDoubleValueForDate(currentTimeStamp, AppleScabCalculations.ASCOSPORE_MATURITY, ascosporeMaturity); + } // We accumulate Mills only when there are humid conditions if(this.getLeafWetness(currentTimeStamp) < LEAF_WETNESS_THRESHOLD) -- GitLab