diff --git a/src/main/java/no/nibio/vips/logic/scheduling/model/preprocessor/NegativePrognosisModelPreprocessor.java b/src/main/java/no/nibio/vips/logic/scheduling/model/preprocessor/NegativePrognosisModelPreprocessor.java index d9399a86e3c08d81be0486a88ea0ab9dccc2b99f..60402e5b3d6a43500c8e21321452a2f214cb3fe6 100644 --- a/src/main/java/no/nibio/vips/logic/scheduling/model/preprocessor/NegativePrognosisModelPreprocessor.java +++ b/src/main/java/no/nibio/vips/logic/scheduling/model/preprocessor/NegativePrognosisModelPreprocessor.java @@ -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()); diff --git a/src/main/java/no/nibio/vips/util/weather/WeatherDataSourceUtil.java b/src/main/java/no/nibio/vips/util/weather/WeatherDataSourceUtil.java index 47ffee78cf022fc5655dbde23ba2640e4afc42d6..c10ac8085b4215e53d8c95432f97e1b218e7b793 100644 --- a/src/main/java/no/nibio/vips/util/weather/WeatherDataSourceUtil.java +++ b/src/main/java/no/nibio/vips/util/weather/WeatherDataSourceUtil.java @@ -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; diff --git a/src/main/java/no/nibio/vips/util/weather/YrWeatherForecastProvider.java b/src/main/java/no/nibio/vips/util/weather/YrWeatherForecastProvider.java index 407deffef24eda2c0e9785431c7139f4557e643e..f1f310913637348d4afb24f9b2342c70b45aa046 100644 --- a/src/main/java/no/nibio/vips/util/weather/YrWeatherForecastProvider.java +++ b/src/main/java/no/nibio/vips/util/weather/YrWeatherForecastProvider.java @@ -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);