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

Add parameterization of THRESHOLD_DSV_MAX

parent e37da69f
No related branches found
No related tags found
No related merge requests found
...@@ -71,9 +71,11 @@ public class AlternariaModel extends I18nImpl implements Model { ...@@ -71,9 +71,11 @@ public class AlternariaModel extends I18nImpl implements Model {
public final static String NAME_MODEL_ID = "ALTERNARIA"; public final static String NAME_MODEL_ID = "ALTERNARIA";
public final static ModelId MODEL_ID = new ModelId(NAME_MODEL_ID); public final static ModelId MODEL_ID = new ModelId(NAME_MODEL_ID);
public final static int THRESHOLD_LW = 30; // Threshold for leave wetness public final static int THRESHOLD_LW = 30; // Threshold for leave wetness
public final static int THRESHOLD_DSV_MAX = 20; // Threshold Minimum for DSV private Double THRESHOLD_DSV_MAX = 20.0; // Threshold Minimum for DSV
public final static String THRESHOLD_DSV_MAX_NAME = "thresholdDSVMax";
public final static int THRESHOLD_DSV_DIFF_MIN_MAX = 5; // Threshold Maximum for DSV public final static int THRESHOLD_DSV_DIFF_MIN_MAX = 5; // Threshold Maximum for DSV
private Double THRESHOLD_DSV_TEMP_MIN = 13.0; // Minimum temp for getting a DSV value private Double THRESHOLD_DSV_TEMP_MIN = 13.0; // Minimum temp for getting a DSV value
public final static String THRESHOLD_DSV_TEMP_MIN_NAME = "thresholdDSVTempMin";
public final static String YES = "Y"; // Spray Date public final static String YES = "Y"; // Spray Date
public final static String NO = "N"; public final static String NO = "N";
...@@ -420,6 +422,16 @@ public class AlternariaModel extends I18nImpl implements Model { ...@@ -420,6 +422,16 @@ public class AlternariaModel extends I18nImpl implements Model {
List<WeatherObservation> altenariaWeatherLIstHourly_tm = new ArrayList<WeatherObservation>(); List<WeatherObservation> altenariaWeatherLIstHourly_tm = new ArrayList<WeatherObservation>();
List<WeatherObservation> altenariaWeatherLIstHourly_lw = new ArrayList<WeatherObservation>(); List<WeatherObservation> altenariaWeatherLIstHourly_lw = new ArrayList<WeatherObservation>();
try
{
this.THRESHOLD_DSV_TEMP_MIN = config.getConfigParameter(AlternariaModel.THRESHOLD_DSV_TEMP_MIN_NAME) != null ? modelUtil.getDouble(config.getConfigParameter(AlternariaModel.THRESHOLD_DSV_TEMP_MIN_NAME)): this.THRESHOLD_DSV_TEMP_MIN;
this.THRESHOLD_DSV_MAX = config.getConfigParameter(AlternariaModel.THRESHOLD_DSV_MAX_NAME) != null ? modelUtil.getDouble(config.getConfigParameter(AlternariaModel.THRESHOLD_DSV_MAX_NAME)) : this.THRESHOLD_DSV_MAX;
}
catch(ClassCastException ex)
{
throw new ConfigValidationException(ex.getMessage());
}
Date dateHourlyTm_currentDay = null; Date dateHourlyTm_currentDay = null;
Date dateHourlyTm_previousDay = null; Date dateHourlyTm_previousDay = null;
Date dateHourlyLw_currentDay = null; Date dateHourlyLw_currentDay = null;
......
...@@ -25,6 +25,7 @@ import org.junit.jupiter.api.AfterAll; ...@@ -25,6 +25,7 @@ import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.DynamicTest.stream;
/** /**
* *
...@@ -104,6 +105,90 @@ public class AlternariaModelTest { ...@@ -104,6 +105,90 @@ public class AlternariaModelTest {
*/ */
}
@org.junit.jupiter.api.Test
public void testGetResultWithThresholdDSVTempMin() throws Exception {
System.out.println("getResultWithThresholdDSVTempMin");
ModelConfiguration config = this.getConfiguration(getWeatherDataFile());
config.setConfigParameter("sprayingDates", this.getConfigurationSprayingDates(getResetDataFile()));
config.setConfigParameter(AlternariaModel.THRESHOLD_DSV_TEMP_MIN_NAME, 10.0);
AlternariaModel instance = new AlternariaModel();
instance.setConfiguration(config);
List<Result> result = instance.getResult();
assertNotNull(result);
config.setConfigParameter(AlternariaModel.THRESHOLD_DSV_TEMP_MIN_NAME, "10.0");
instance.setConfiguration(config);
result = instance.getResult();
assertNotNull(result);
/*
for(Result res:result)
{
// LOGGER.log(Level.INFO, res.toString());
System.out.println(res.toString());
}*/
config.setConfigParameter(AlternariaModel.THRESHOLD_DSV_TEMP_MIN_NAME, "13.0");
//System.out.println(config.toJSON());
instance.setConfiguration(config);
result = instance.getResult();
assertNotNull(result);
/*
for(Result res:result)
{
// LOGGER.log(Level.INFO, res.toString());
System.out.println(res.toString());
} */
}
@org.junit.jupiter.api.Test
public void testGetResultWithThresholdDSVMax() throws Exception {
System.out.println("getResultWithThresholdDSVMax");
ModelConfiguration config = this.getConfiguration(getWeatherDataFile());
config.setConfigParameter("sprayingDates", this.getConfigurationSprayingDates(getResetDataFile()));
config.setConfigParameter(AlternariaModel.THRESHOLD_DSV_MAX_NAME, 21);
AlternariaModel instance = new AlternariaModel();
instance.setConfiguration(config);
List<Result> result = instance.getResult();
assertNotNull(result);
config.setConfigParameter(AlternariaModel.THRESHOLD_DSV_MAX_NAME, "21");
instance.setConfiguration(config);
result = instance.getResult();
assertNotNull(result);
/*
for(Result res:result)
{
// LOGGER.log(Level.INFO, res.toString());
System.out.println(res.toString());
}*/
config.setConfigParameter(AlternariaModel.THRESHOLD_DSV_MAX_NAME, "13.0");
//System.out.println(config.toJSON());
instance.setConfiguration(config);
result = instance.getResult();
assertNotNull(result);
/*
for(Result res:result)
{
// LOGGER.log(Level.INFO, res.toString());
System.out.println(res.toString());
} */
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment