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

Refactoring parameter names

parent 389eab28
Branches
No related tags found
No related merge requests found
...@@ -65,8 +65,8 @@ public class YellowStemborerTempModel extends I18nImpl implements Model { ...@@ -65,8 +65,8 @@ public class YellowStemborerTempModel extends I18nImpl implements Model {
}; };
// DD aggregation cutoff values for each phase // DD aggregation cutoff values for each phase
private Double[] dd_lower = {13.0,12.0,15.0,13.0}; private Double[] ddLower = {13.0,12.0,15.0,13.0};
private Double[] dd_upper = {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};
...@@ -104,9 +104,9 @@ public class YellowStemborerTempModel extends I18nImpl implements Model { ...@@ -104,9 +104,9 @@ public class YellowStemborerTempModel extends I18nImpl implements Model {
result.setValue(YellowStemborerTempModel.MODEL_ID.toString(), DataMatrix.DAILY_CONTRIB, dFormat.format(DAILY_CONTRIB)); result.setValue(YellowStemborerTempModel.MODEL_ID.toString(), DataMatrix.DAILY_CONTRIB, dFormat.format(DAILY_CONTRIB));
result.setValue(YellowStemborerTempModel.MODEL_ID.toString(), DataMatrix.HEAT_SUM, dFormat.format(HEAT_SUM)); result.setValue(YellowStemborerTempModel.MODEL_ID.toString(), DataMatrix.HEAT_SUM, dFormat.format(HEAT_SUM));
result.setValue(YellowStemborerTempModel.MODEL_ID.toString(), DataMatrix.PHASE, PHASE); result.setValue(YellowStemborerTempModel.MODEL_ID.toString(), DataMatrix.PHASE, PHASE);
result.setValue(YellowStemborerTempModel.MODEL_ID.toString(), "thresholdLarvae", dFormat.format(this.heatRequirements[0])); result.setValue(YellowStemborerTempModel.MODEL_ID.toString(), "THRESHOLD_LARVAE", dFormat.format(this.heatRequirements[0]));
result.setValue(YellowStemborerTempModel.MODEL_ID.toString(), "thresholdPupa", dFormat.format(this.heatRequirements[0] + this.heatRequirements[1])); result.setValue(YellowStemborerTempModel.MODEL_ID.toString(), "THRESHOLD_PUPA", dFormat.format(this.heatRequirements[0] + this.heatRequirements[1]));
result.setValue(YellowStemborerTempModel.MODEL_ID.toString(), "thresholdAdult", dFormat.format(this.heatRequirements[0] + this.heatRequirements[1] + this.heatRequirements[2])); result.setValue(YellowStemborerTempModel.MODEL_ID.toString(), "THRESHOLD_ADULT", dFormat.format(this.heatRequirements[0] + this.heatRequirements[1] + this.heatRequirements[2]));
result.setValue(YellowStemborerTempModel.MODEL_ID.toString(), DataMatrix.PHASE, PHASE); result.setValue(YellowStemborerTempModel.MODEL_ID.toString(), DataMatrix.PHASE, PHASE);
Integer warningStatus = Result.WARNING_STATUS_NO_WARNING; Integer warningStatus = Result.WARNING_STATUS_NO_WARNING;
...@@ -230,23 +230,23 @@ public class YellowStemborerTempModel extends I18nImpl implements Model { ...@@ -230,23 +230,23 @@ public class YellowStemborerTempModel extends I18nImpl implements Model {
this.heatRequirements = this.modelUtil.getDoubleArray(config.getConfigParameter("heatRequirements")); this.heatRequirements = this.modelUtil.getDoubleArray(config.getConfigParameter("heatRequirements"));
if(this.heatRequirements.length != 4) if(this.heatRequirements.length != 4)
{ {
throw new ConfigValidationException("ERROR: Array of heat requirements has " + this.dd_lower.length + " elements, should be 4"); throw new ConfigValidationException("ERROR: Array of heat requirements has " + this.heatRequirements.length + " elements, should be 4");
} }
} }
if(config.getConfigParameter("dd_lower") != null) if(config.getConfigParameter("ddLower") != null)
{ {
this.dd_lower = this.modelUtil.getDoubleArray(config.getConfigParameter("dd_lower")); this.ddLower = this.modelUtil.getDoubleArray(config.getConfigParameter("ddLower"));
if(this.dd_lower.length != 4) if(this.ddLower.length != 4)
{ {
throw new ConfigValidationException("ERROR: Array of lower cutoffs has " + this.dd_lower.length + " elements, should be 4"); throw new ConfigValidationException("ERROR: Array of lower cutoffs has " + this.ddLower.length + " elements, should be 4");
} }
} }
if(config.getConfigParameter("dd_upper") != null) if(config.getConfigParameter("ddUpper") != null)
{ {
this.dd_upper = this.modelUtil.getDoubleArray(config.getConfigParameter("dd_upper")); this.ddUpper = this.modelUtil.getDoubleArray(config.getConfigParameter("ddUpper"));
if(this.dd_upper.length != 4) if(this.ddUpper.length != 4)
{ {
throw new ConfigValidationException("ERROR: Array of upper cutoffs has " + this.dd_upper.length + " elements, should be 4"); throw new ConfigValidationException("ERROR: Array of upper cutoffs has " + this.ddUpper.length + " elements, should be 4");
} }
} }
if(config.getConfigParameter("observedPhase") != null) if(config.getConfigParameter("observedPhase") != null)
...@@ -314,6 +314,7 @@ public class YellowStemborerTempModel extends I18nImpl implements Model { ...@@ -314,6 +314,7 @@ public class YellowStemborerTempModel extends I18nImpl implements Model {
break; break;
} }
} }
// TODO: Check validity of weather data
//System.out.println("DataMatrix"); //System.out.println("DataMatrix");
//System.out.println(this.dataMatrix.toCSV()); //System.out.println(this.dataMatrix.toCSV());
...@@ -359,9 +360,9 @@ public class YellowStemborerTempModel extends I18nImpl implements Model { ...@@ -359,9 +360,9 @@ public class YellowStemborerTempModel extends I18nImpl implements Model {
throw new ModelExcecutionException("Missing weather data at " + today + ": " + (todayMinTemp == null ? "TND ": "") + (todayMaxTemp == null ? "TXD ": "")); throw new ModelExcecutionException("Missing weather data at " + today + ": " + (todayMinTemp == null ? "TND ": "") + (todayMaxTemp == null ? "TXD ": ""));
} }
//System.out.println("today=" + today + ",todayTemp=" + todayTemp); //System.out.println("today=" + today + ",todayTemp=" + todayTemp);
Double current_dd_lower = this.dd_lower[phasesList.indexOf(currentPhase)]; Double current_ddLower = this.ddLower[phasesList.indexOf(currentPhase)];
Double current_dd_upper = this.dd_upper[phasesList.indexOf(currentPhase)]; Double current_ddUpper = this.ddUpper[phasesList.indexOf(currentPhase)];
Double dailyContribution = nlc.calculateSingleSineWaveWithCutoff(todayMinTemp.getValue(), todayMaxTemp.getValue(), current_dd_lower, current_dd_upper); Double dailyContribution = nlc.calculateSingleSineWaveWithCutoff(todayMinTemp.getValue(), todayMaxTemp.getValue(), current_ddLower, current_ddUpper);
this.dataMatrix.setParamDoubleValueForDate(today, DataMatrix.DAILY_CONTRIB, dailyContribution); this.dataMatrix.setParamDoubleValueForDate(today, DataMatrix.DAILY_CONTRIB, dailyContribution);
sum += dailyContribution; sum += dailyContribution;
this.dataMatrix.setParamDoubleValueForDate(today, DataMatrix.HEAT_SUM, sum); this.dataMatrix.setParamDoubleValueForDate(today, DataMatrix.HEAT_SUM, sum);
......
...@@ -5,12 +5,9 @@ ...@@ -5,12 +5,9 @@
*/ */
package no.nibio.vips.model.yellowstemborertempmodel; package no.nibio.vips.model.yellowstemborertempmodel;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.List; import java.util.List;
import no.nibio.vips.entity.ModelConfiguration; import no.nibio.vips.entity.ModelConfiguration;
import no.nibio.vips.entity.Result; import no.nibio.vips.entity.Result;
import no.nibio.vips.model.ModelId;
import no.nibio.vips.util.ModelUtil;
import no.nibio.vips.util.test.WeatherDataFileReader; import no.nibio.vips.util.test.WeatherDataFileReader;
import org.junit.After; import org.junit.After;
import org.junit.AfterClass; import org.junit.AfterClass;
...@@ -67,11 +64,11 @@ public class YellowStemborerTempModelTest { ...@@ -67,11 +64,11 @@ public class YellowStemborerTempModelTest {
// 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};
// Lower and upper cutoffs for [EGG,LARVAE,PUPA,ADULT] phases // Lower and upper cutoffs for [EGG,LARVAE,PUPA,ADULT] phases
Double[] dd_lower = {13.0,12.0,15.0,13.0}; Double[] ddLower = {13.0,12.0,15.0,13.0};
Double[] dd_upper = {36.0, 34.0,36.0,36.0}; Double[] ddUpper = {36.0, 34.0,36.0,36.0};
config.setConfigParameter("heatRequirements", heatRequirements); config.setConfigParameter("heatRequirements", heatRequirements);
config.setConfigParameter("dd_lower", dd_lower); config.setConfigParameter("ddLower", ddLower);
config.setConfigParameter("dd_upper", dd_upper); config.setConfigParameter("ddUpper", ddUpper);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment