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

Weather data handling for negative prognosis model

parent c6f75d2d
Branches
Tags
No related merge requests found
......@@ -30,6 +30,8 @@ import no.nibio.vips.logic.entity.PointOfInterestWeatherStation;
import no.nibio.vips.logic.scheduling.model.ModelRunPreprocessor;
import no.nibio.vips.logic.scheduling.model.PreprocessorException;
import no.nibio.vips.util.WeatherElements;
import no.nibio.vips.util.WeatherObservationListException;
import no.nibio.vips.util.WeatherUtil;
import no.nibio.vips.util.weather.WeatherDataSourceException;
import no.nibio.vips.util.weather.WeatherDataSourceUtil;
......@@ -45,13 +47,14 @@ public class NegativePrognosisModelPreprocessor extends ModelRunPreprocessor{
TimeZone timeZone = TimeZone.getTimeZone(weatherStation.getTimeZone());
WeatherDataSourceUtil wdsUtil = new WeatherDataSourceUtil();
WeatherUtil wUtil = new WeatherUtil();
List<WeatherObservation> observations;
try {
observations = wdsUtil.getWeatherObservations(
weatherStation.getDataFetchUri(),
weatherStation,
WeatherObservation.LOG_INTERVAL_ID_1H,
new String[]{
WeatherElements.TEMPERATURE_MEAN,
......@@ -59,12 +62,12 @@ public class NegativePrognosisModelPreprocessor extends ModelRunPreprocessor{
WeatherElements.RELATIVE_HUMIDITY_MEAN
},
configuration.getDateStartInTimeZone(),
configuration.getDateEndInTimeZone(),
timeZone);
} catch (WeatherDataSourceException ex) {
configuration.getDateEndInTimeZone());
observations = wUtil.checkForAndFixHourlyTimeSeriesHolesMultiParameter(observations);
} catch (WeatherDataSourceException | WeatherObservationListException ex) {
throw new PreprocessorException(ex.getMessage());
}
ModelConfiguration retVal = new ModelConfiguration();
retVal.setModelId(this.getModelId());
retVal.setConfigParameter("timeZone", weatherStation.getTimeZone());
......
......@@ -86,6 +86,7 @@ public class WeatherDataSourceUtil {
continue;
}
Collections.sort(paramObs);
//System.out.println("elementMeasurementType " + elementMeasurementType + " first date = " + paramObs.get(0).getTimeMeasured());
latestCommonDate = latestCommonDate == null ? paramObs.get(paramObs.size() - 1).getTimeMeasured() : new Date(Math.min(latestCommonDate.getTime(), paramObs.get(paramObs.size() - 1).getTimeMeasured().getTime()));
}
Integer previousObsSize = null;
......
......@@ -152,6 +152,7 @@ public class YrWeatherForecastProvider implements WeatherForecastProvider{
}
catch(IOException | ParserConfigurationException | SAXException | ParseException ex)
{
ex.printStackTrace();
throw new ParseWeatherDataException(ex.getClass().getName() + ": " + ex.getMessage());
}
return this.createHourlyDataFromYr(yrValues);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment