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

Bugfix: Aggregation of hourly values

parent 6469672d
Branches
Tags
No related merge requests found
...@@ -217,7 +217,7 @@ public class LygusRugulipennisModel extends I18nImpl implements Model{ ...@@ -217,7 +217,7 @@ public class LygusRugulipennisModel extends I18nImpl implements Model{
// OR lastly hourly values of TM (not optimal, but better than nothing) // OR lastly hourly values of TM (not optimal, but better than nothing)
List<WeatherObservation> TM = new ArrayList<>(); List<WeatherObservation> TM = new ArrayList<>();
WeatherUtil wUtil = new WeatherUtil(); WeatherUtil wUtil = new WeatherUtil();
List<WeatherObservation> observations = mapper.convertValue(config.getConfigParameter("observations"), new TypeReference<List<WeatherObservation>>(){}); List<WeatherObservation> observations = modelUtil.extractWeatherObservationList(config.getConfigParameter("observations"));
for(WeatherObservation o:observations) for(WeatherObservation o:observations)
{ {
switch(o.getElementMeasurementTypeId()) switch(o.getElementMeasurementTypeId())
...@@ -250,7 +250,7 @@ public class LygusRugulipennisModel extends I18nImpl implements Model{ ...@@ -250,7 +250,7 @@ public class LygusRugulipennisModel extends I18nImpl implements Model{
{ {
try try
{ {
TXDCalculated = new WeatherUtil().getAggregatedDailyValues(TX, timeZone, 15, 15, WeatherUtil.AGGREGATION_TYPE_MAXIMUM); TXDCalculated = new WeatherUtil().getAggregatedDailyValues(TX, timeZone, 15, WeatherUtil.AGGREGATION_TYPE_MAXIMUM);
}catch(WeatherObservationListException | InvalidAggregationTypeException ex) }catch(WeatherObservationListException | InvalidAggregationTypeException ex)
{ {
throw new ConfigValidationException(ex.getMessage()); throw new ConfigValidationException(ex.getMessage());
...@@ -260,7 +260,7 @@ public class LygusRugulipennisModel extends I18nImpl implements Model{ ...@@ -260,7 +260,7 @@ public class LygusRugulipennisModel extends I18nImpl implements Model{
{ {
try try
{ {
TXDCalculated = new WeatherUtil().getAggregatedDailyValues(TM, timeZone, 15, 15, WeatherUtil.AGGREGATION_TYPE_MAXIMUM); TXDCalculated = new WeatherUtil().getAggregatedDailyValues(TM, timeZone, 15, WeatherUtil.AGGREGATION_TYPE_MAXIMUM);
}catch(WeatherObservationListException | InvalidAggregationTypeException ex) }catch(WeatherObservationListException | InvalidAggregationTypeException ex)
{ {
throw new ConfigValidationException(ex.getMessage()); throw new ConfigValidationException(ex.getMessage());
......
...@@ -45,7 +45,7 @@ import static org.junit.Assert.*; ...@@ -45,7 +45,7 @@ import static org.junit.Assert.*;
/** /**
* *
* @author treinar * @author Tor-Einar Skog <tor-einar.skog@nibio.no>
*/ */
public class LygusRugulipennisModelTest { public class LygusRugulipennisModelTest {
...@@ -79,6 +79,10 @@ public class LygusRugulipennisModelTest { ...@@ -79,6 +79,10 @@ public class LygusRugulipennisModelTest {
instance.setConfiguration(config); instance.setConfiguration(config);
List<Result> result = instance.getResult(); List<Result> result = instance.getResult();
assertNotNull(result); assertNotNull(result);
config = this.getConfiguration("/AgDir_2023.json");
instance.setConfiguration(config);
result = instance.getResult();
assertNotNull(result);
/* /*
Collections.sort(result); Collections.sort(result);
for(Result oneResult:result) for(Result oneResult:result)
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment