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

Outsourced weather data validation (at least some of it)

parent cddf0f2a
Branches
Tags
No related merge requests found
...@@ -320,47 +320,18 @@ public class AppleScabModel extends I18nImpl implements Model{ ...@@ -320,47 +320,18 @@ public class AppleScabModel extends I18nImpl implements Model{
} }
} }
// Basic time series health check
WeatherUtil wUtil = new WeatherUtil(); WeatherUtil wUtil = new WeatherUtil();
// Must be of same length, try
if(this.TM.size() != this.RR.size() || this.TM.size() != BT.size())
{ {
throw new ConfigValidationException("Unequal length of weather parameter lists. " wUtil.isHomogenousTimeSeries(this.TM, this.RR, this.BT);
+ "Temperature list size = " + this.TM.size()
+ ", precipitation list size = " + this.RR.size()
+ ", leaf wetness list size = " + this.BT.size()
);
} }
catch(WeatherObservationListException ex)
// Must be starting at same time
if(
this.TM.get(0).getTimeMeasured().compareTo(this.RR.get(0).getTimeMeasured()) != 0
|| this.TM.get(0).getTimeMeasured().compareTo(this.BT.get(0).getTimeMeasured()) != 0
)
{ {
throw new ConfigValidationException("Weather parameter lists do not start at same time " throw new ConfigValidationException(ex.getMessage());
+ "Temperature list starts at = " + this.TM.get(0).getTimeMeasured()
+ ", precipitation list starts at = " + this.RR.get(0).getTimeMeasured()
+ ", leaf wetness list starts at = " + this.BT.get(0).getTimeMeasured()
);
} }
// Must be ending at same time
int lastIndex = this.TM.size() -1;
if(
this.TM.get(lastIndex).getTimeMeasured().compareTo(this.RR.get(lastIndex).getTimeMeasured()) != 0
|| this.TM.get(lastIndex).getTimeMeasured().compareTo(this.BT.get(lastIndex).getTimeMeasured()) != 0
)
{
throw new ConfigValidationException("Weather parameter lists do not end at same time "
+ "Temperature list ends at = " + this.TM.get(lastIndex).getTimeMeasured()
+ ", precipitation list ends at = " + this.RR.get(lastIndex).getTimeMeasured()
+ ", leaf wetness list ends at = " + this.BT.get(lastIndex).getTimeMeasured()
);
}
// If all that's OK, chop of all hour values exceeding the last full day // If all that's OK, chop of all hour values exceeding the last full day
// of hourly data // of hourly data
this.TM = wUtil.cutTrailingHourlyValues(this.TM, timeZone); this.TM = wUtil.cutTrailingHourlyValues(this.TM, timeZone);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment