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
No related branches found
No related tags found
No related merge requests found
...@@ -30,6 +30,8 @@ import no.nibio.vips.logic.entity.PointOfInterestWeatherStation; ...@@ -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.ModelRunPreprocessor;
import no.nibio.vips.logic.scheduling.model.PreprocessorException; import no.nibio.vips.logic.scheduling.model.PreprocessorException;
import no.nibio.vips.util.WeatherElements; 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.WeatherDataSourceException;
import no.nibio.vips.util.weather.WeatherDataSourceUtil; import no.nibio.vips.util.weather.WeatherDataSourceUtil;
...@@ -45,13 +47,14 @@ public class NegativePrognosisModelPreprocessor extends ModelRunPreprocessor{ ...@@ -45,13 +47,14 @@ public class NegativePrognosisModelPreprocessor extends ModelRunPreprocessor{
TimeZone timeZone = TimeZone.getTimeZone(weatherStation.getTimeZone()); TimeZone timeZone = TimeZone.getTimeZone(weatherStation.getTimeZone());
WeatherDataSourceUtil wdsUtil = new WeatherDataSourceUtil(); WeatherDataSourceUtil wdsUtil = new WeatherDataSourceUtil();
WeatherUtil wUtil = new WeatherUtil();
List<WeatherObservation> observations; List<WeatherObservation> observations;
try { try {
observations = wdsUtil.getWeatherObservations( observations = wdsUtil.getWeatherObservations(
weatherStation.getDataFetchUri(), weatherStation,
WeatherObservation.LOG_INTERVAL_ID_1H, WeatherObservation.LOG_INTERVAL_ID_1H,
new String[]{ new String[]{
WeatherElements.TEMPERATURE_MEAN, WeatherElements.TEMPERATURE_MEAN,
...@@ -59,12 +62,12 @@ public class NegativePrognosisModelPreprocessor extends ModelRunPreprocessor{ ...@@ -59,12 +62,12 @@ public class NegativePrognosisModelPreprocessor extends ModelRunPreprocessor{
WeatherElements.RELATIVE_HUMIDITY_MEAN WeatherElements.RELATIVE_HUMIDITY_MEAN
}, },
configuration.getDateStartInTimeZone(), configuration.getDateStartInTimeZone(),
configuration.getDateEndInTimeZone(), configuration.getDateEndInTimeZone());
timeZone); observations = wUtil.checkForAndFixHourlyTimeSeriesHolesMultiParameter(observations);
} catch (WeatherDataSourceException ex) { } catch (WeatherDataSourceException | WeatherObservationListException ex) {
throw new PreprocessorException(ex.getMessage()); throw new PreprocessorException(ex.getMessage());
} }
ModelConfiguration retVal = new ModelConfiguration(); ModelConfiguration retVal = new ModelConfiguration();
retVal.setModelId(this.getModelId()); retVal.setModelId(this.getModelId());
retVal.setConfigParameter("timeZone", weatherStation.getTimeZone()); retVal.setConfigParameter("timeZone", weatherStation.getTimeZone());
......
...@@ -86,6 +86,7 @@ public class WeatherDataSourceUtil { ...@@ -86,6 +86,7 @@ public class WeatherDataSourceUtil {
continue; continue;
} }
Collections.sort(paramObs); 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())); 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; Integer previousObsSize = null;
......
...@@ -152,6 +152,7 @@ public class YrWeatherForecastProvider implements WeatherForecastProvider{ ...@@ -152,6 +152,7 @@ public class YrWeatherForecastProvider implements WeatherForecastProvider{
} }
catch(IOException | ParserConfigurationException | SAXException | ParseException ex) catch(IOException | ParserConfigurationException | SAXException | ParseException ex)
{ {
ex.printStackTrace();
throw new ParseWeatherDataException(ex.getClass().getName() + ": " + ex.getMessage()); throw new ParseWeatherDataException(ex.getClass().getName() + ": " + ex.getMessage());
} }
return this.createHourlyDataFromYr(yrValues); 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