Skip to content
Snippets Groups Projects
Commit e9875472 authored by Tor-Einar Skog's avatar Tor-Einar Skog
Browse files

Added support for the EOL (dead) phase

parent eb333537
No related branches found
No related tags found
No related merge requests found
...@@ -6,11 +6,6 @@ ...@@ -6,11 +6,6 @@
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<dependencies> <dependencies>
<dependency>
<groupId>no.nibio.vips.common</groupId>
<artifactId>VIPSCommon</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
...@@ -23,6 +18,11 @@ ...@@ -23,6 +18,11 @@
<version>1.3</version> <version>1.3</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>no.nibio.vips.common</groupId>
<artifactId>VIPSCommon</artifactId>
<version>2022.1</version>
</dependency>
</dependencies> </dependencies>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
......
...@@ -35,4 +35,5 @@ public class DataMatrix extends DateMap{ ...@@ -35,4 +35,5 @@ public class DataMatrix extends DateMap{
public final static String PHASE_LARVAE ="LARVAE"; public final static String PHASE_LARVAE ="LARVAE";
public final static String PHASE_PUPA ="PUPA"; public final static String PHASE_PUPA ="PUPA";
public final static String PHASE_ADULT ="ADULT"; public final static String PHASE_ADULT ="ADULT";
public final static String PHASE_EOL ="EOL";
} }
...@@ -61,12 +61,13 @@ public class YellowStemborerTempModel extends I18nImpl implements Model { ...@@ -61,12 +61,13 @@ public class YellowStemborerTempModel extends I18nImpl implements Model {
DataMatrix.PHASE_EGG, DataMatrix.PHASE_EGG,
DataMatrix.PHASE_LARVAE, DataMatrix.PHASE_LARVAE,
DataMatrix.PHASE_PUPA, DataMatrix.PHASE_PUPA,
DataMatrix.PHASE_ADULT DataMatrix.PHASE_ADULT,
DataMatrix.PHASE_EOL
}; };
// DD aggregation cutoff values for each phase // DD aggregation cutoff values for each phase
private Double[] ddLower = {13.0,12.0,15.0,13.0}; private Double[] ddLower = {13.0, 12.0, 15.0, 13.0};
private Double[] ddUpper = {36.0, 34.0,36.0,36.0}; private Double[] ddUpper = {36.0, 34.0, 36.0, 36.0};
// Heat sum thresholds for each phase // Heat sum thresholds for each phase
private Double[] heatRequirements = {113.0, 370.0, 188.0, 25.0}; private Double[] heatRequirements = {113.0, 370.0, 188.0, 25.0};
...@@ -127,6 +128,10 @@ public class YellowStemborerTempModel extends I18nImpl implements Model { ...@@ -127,6 +128,10 @@ public class YellowStemborerTempModel extends I18nImpl implements Model {
{ {
warningStatus = Result.WARNING_STATUS_HIGH_RISK; warningStatus = Result.WARNING_STATUS_HIGH_RISK;
} }
if(PHASE.equals(DataMatrix.PHASE_EOL))
{
warningStatus = Result.WARNING_STATUS_NO_RISK;
}
result.setWarningStatus(warningStatus); result.setWarningStatus(warningStatus);
retVal.add(result); retVal.add(result);
// Moving on... // Moving on...
...@@ -347,27 +352,39 @@ public class YellowStemborerTempModel extends I18nImpl implements Model { ...@@ -347,27 +352,39 @@ public class YellowStemborerTempModel extends I18nImpl implements Model {
Double sum = currentPhase.equals(DataMatrix.PHASE_EGG) ? 0.0 Double sum = currentPhase.equals(DataMatrix.PHASE_EGG) ? 0.0
: currentPhase.equals(DataMatrix.PHASE_LARVAE) ? this.heatRequirements[0] : currentPhase.equals(DataMatrix.PHASE_LARVAE) ? this.heatRequirements[0]
: currentPhase.equals(DataMatrix.PHASE_PUPA) ? this.heatRequirements[0] + this.heatRequirements[1] : currentPhase.equals(DataMatrix.PHASE_PUPA) ? this.heatRequirements[0] + this.heatRequirements[1]
: this.heatRequirements[0] + this.heatRequirements[1] + this.heatRequirements[2]; : currentPhase.equals(DataMatrix.PHASE_ADULT) ? this.heatRequirements[0] + this.heatRequirements[1] + this.heatRequirements[2]
: this.heatRequirements[0] + this.heatRequirements[1] + this.heatRequirements[2] + this.heatRequirements[3];
List<String> phasesList = Arrays.asList(this.phases); List<String> phasesList = Arrays.asList(this.phases);
while(today.compareTo(lastDate) <= 0) while(today.compareTo(lastDate) <= 0)
{ {
WeatherObservation todayMinTemp = (WeatherObservation)this.dataMatrix.getParamValueForDate(today, DataMatrix.TND); if(!currentPhase.equals(DataMatrix.PHASE_EOL))
WeatherObservation todayMaxTemp = (WeatherObservation)this.dataMatrix.getParamValueForDate(today, DataMatrix.TXD); {
if(todayMinTemp == null || todayMaxTemp == null) WeatherObservation todayMinTemp = (WeatherObservation)this.dataMatrix.getParamValueForDate(today, DataMatrix.TND);
WeatherObservation todayMaxTemp = (WeatherObservation)this.dataMatrix.getParamValueForDate(today, DataMatrix.TXD);
if(todayMinTemp == null || todayMaxTemp == null)
{
throw new ModelExcecutionException("Missing weather data at " + today + ": " + (todayMinTemp == null ? "TND ": "") + (todayMaxTemp == null ? "TXD ": ""));
}
//System.out.println("today=" + today + ",todayTemp=" + todayTemp);
Double current_ddLower = this.ddLower[phasesList.indexOf(currentPhase)];
Double current_ddUpper = this.ddUpper[phasesList.indexOf(currentPhase)];
Double dailyContribution = nlc.calculateSingleSineWaveWithCutoff(todayMinTemp.getValue(), todayMaxTemp.getValue(), current_ddLower, current_ddUpper);
this.dataMatrix.setParamDoubleValueForDate(today, DataMatrix.DAILY_CONTRIB, dailyContribution);
sum += dailyContribution;
}
else
{ {
throw new ModelExcecutionException("Missing weather data at " + today + ": " + (todayMinTemp == null ? "TND ": "") + (todayMaxTemp == null ? "TXD ": "")); this.dataMatrix.setParamDoubleValueForDate(today, DataMatrix.DAILY_CONTRIB, 0.0);
} }
//System.out.println("today=" + today + ",todayTemp=" + todayTemp);
Double current_ddLower = this.ddLower[phasesList.indexOf(currentPhase)];
Double current_ddUpper = this.ddUpper[phasesList.indexOf(currentPhase)];
Double dailyContribution = nlc.calculateSingleSineWaveWithCutoff(todayMinTemp.getValue(), todayMaxTemp.getValue(), current_ddLower, current_ddUpper);
this.dataMatrix.setParamDoubleValueForDate(today, DataMatrix.DAILY_CONTRIB, dailyContribution);
sum += dailyContribution;
this.dataMatrix.setParamDoubleValueForDate(today, DataMatrix.HEAT_SUM, sum); this.dataMatrix.setParamDoubleValueForDate(today, DataMatrix.HEAT_SUM, sum);
// Check phase transition // Check phase transition
if(sum >= this.heatRequirements[0] + this.heatRequirements[1] + this.heatRequirements[2]) if(sum >= this.heatRequirements[0] + this.heatRequirements[1] + this.heatRequirements[2] + this.heatRequirements[3])
{
currentPhase = DataMatrix.PHASE_EOL;
}
else if(sum >= this.heatRequirements[0] + this.heatRequirements[1] + this.heatRequirements[2])
{ {
currentPhase = DataMatrix.PHASE_ADULT; currentPhase = DataMatrix.PHASE_ADULT;
} }
......
...@@ -55,11 +55,11 @@ public class YellowStemborerTempModelTest { ...@@ -55,11 +55,11 @@ public class YellowStemborerTempModelTest {
// The timezone is used to set daily temperatures and biofix date correctly // The timezone is used to set daily temperatures and biofix date correctly
config.setConfigParameter("timeZone", "GMT+05:30"); config.setConfigParameter("timeZone", "GMT+05:30");
// The date for when to start calculating heat sums // The date for when to start calculating heat sums
config.setConfigParameter("biofixDate", "2019-01-05"); config.setConfigParameter("biofixDate", "2019-01-02");
// OPTIONAL // OPTIONAL
// The observed phase at biofix date. Default is EGG // The observed phase at biofix date. Default is EGG
config.setConfigParameter("observedPhase", DataMatrix.PHASE_EGG); config.setConfigParameter("observedPhase", DataMatrix.PHASE_ADULT);
// Heat requirement for transitioning out of [EGG,LARVAE,PUPA,ADULT] phases // Heat requirement for transitioning out of [EGG,LARVAE,PUPA,ADULT] phases
Double[] heatRequirements = {113.0, 370.0, 188.0, 25.0}; Double[] heatRequirements = {113.0, 370.0, 188.0, 25.0};
...@@ -90,7 +90,7 @@ public class YellowStemborerTempModelTest { ...@@ -90,7 +90,7 @@ public class YellowStemborerTempModelTest {
//ObjectMapper mapper = new ObjectMapper(); //ObjectMapper mapper = new ObjectMapper();
//System.out.println(mapper.writeValueAsString(result)); //System.out.println(mapper.writeValueAsString(result));
// Line by line // Line by line
//result.forEach(r->System.out.println(r)); result.forEach(r->System.out.println(r));
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment