Skip to content
Snippets Groups Projects

Avoiding meltdown in Grid Model run

Merged Tor-Einar Skog requested to merge spotit_wp_34_bugfix into develop
3 files
+ 45
9
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -20,8 +20,13 @@
package no.nibio.vips.logic.scheduling.model.grid.preprocessor;
import com.vividsolutions.jts.geom.Coordinate;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalUnit;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.stream.Collectors;
@@ -34,6 +39,7 @@ 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.logic.util.SessionControllerGetter;
import no.nibio.vips.logic.util.SystemTime;
import no.nibio.vips.util.WeatherElements;
import no.nibio.vips.util.WeatherObservationListException;
import no.nibio.vips.util.WeatherUtil;
@@ -105,6 +111,10 @@ public class ZymoseptoriaSimpleRiskGridModelPreprocessor extends ModelRunPreproc
List<WeatherObservation> stationObs;// = new ArrayList<>();
WeatherDataSourceUtil wdsUtil = new WeatherDataSourceUtil();
WeatherUtil wUtil = new WeatherUtil();
// We run this for max 1 week back in time to make sure it doesn't crash
ZonedDateTime aWeekAgo = ZonedDateTime.ofInstant(SystemTime.getSystemTime().toInstant(), ZoneId.of("Europe/Oslo")).minus(1, ChronoUnit.WEEKS);
ZonedDateTime aWeekAhead = ZonedDateTime.ofInstant(SystemTime.getSystemTime().toInstant(), ZoneId.of("Europe/Oslo")).plus(1, ChronoUnit.WEEKS);
try {
stationObs = wdsUtil.getWeatherObservations(
@@ -116,8 +126,8 @@ public class ZymoseptoriaSimpleRiskGridModelPreprocessor extends ModelRunPreproc
WeatherElements.PRECIPITATION,
WeatherElements.TEMPERATURE_MEAN
},
configuration.getDateStartInTimeZone(),
configuration.getDateEndInTimeZone(),
Date.from(aWeekAgo.toInstant()),
Date.from(aWeekAhead.toInstant()),
true
);
stationObs = wUtil.checkForAndFixHourlyTimeSeriesHoles(stationObs);
Loading