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

bugfixes in weather data handling

parent f0eca88a
No related branches found
No related tags found
No related merge requests found
......@@ -449,7 +449,7 @@ public class SchedulingBean {
" failed at + " + taskExecutor.getStartTime() +
", finished at " + new Date() +
". Status is " + taskHistory.getTaskHistoryStatusId() +
". Error was " + taskHistory.getMessage().substring(0,400) + "[...]" +
". Error was " + taskHistory.getMessage().substring(0, Math.min(400, taskHistory.getMessage().length())) + "[...]" +
" ############");
}
......
......@@ -249,7 +249,7 @@ public class AppleScabModelPreprocessor extends ModelRunPreprocessor{
//System.out.println(wUtil.dumpWeatherObservationList(RR));
}
BT = wUtil.checkForAndFixHourlyTimeSeriesHoles(BT);
// Unequal length of lists
if (
......@@ -267,25 +267,6 @@ public class AppleScabModelPreprocessor extends ModelRunPreprocessor{
// Fallback if missing leaf wetness: If we have relative humidity. leaf wetness may be calculated
if(BT.size() != TM.size() && UM.size() == TM.size())
{
Q0 = wUtil.fixHourlyValuesForParameters(
Q0,
new HashSet(Arrays.asList("Q0")),
firstTimeStamp,
null
);
FM2 = wUtil.fixHourlyValuesForParameters(
FM2,
new HashSet(Arrays.asList("FM2")),
firstTimeStamp,
null
);
BT = wUtil.fixHourlyValuesForParameters(
BT,
new HashSet(Arrays.asList("BT")),
firstTimeStamp,
null
);
BT = wUtil.calculateLeafWetnessHourSeriesBestEffort(BT,TM, RR, Q0, FM2, UM);
if(BT.size() != TM.size())
......
......@@ -210,7 +210,7 @@ public class NaerstadModelPreprocessor extends ModelRunPreprocessor{
// Problems with weather observations
//System.out.println("BT=" + BT.size() + " [First=," + BT.get(0).getTimeMeasured() + " last=" + BT.get(BT.size()-1).getTimeMeasured() + "]");
BT = wUtil.checkForAndFixHourlyTimeSeriesHoles(BT);
//BT = wUtil.checkForAndFixHourlyTimeSeriesHoles(BT);
// Unequal length of lists
if (
......
......@@ -99,7 +99,7 @@ public class WeatherProxyService {
@Path("fmi/{stationId}")
@GZIP
@Produces("application/json;charset=UTF-8")
public Response getMetosRIMProWeatherData(
public Response getFMIVIPSWeatherData(
@PathParam("stationId") String stationId,
@FormParam("timeZone") String timeZonePOST,
@QueryParam("timeZone") String timeZoneGET,
......@@ -109,7 +109,7 @@ public class WeatherProxyService {
@QueryParam("endDate") String endDateGET
)
{
String FMI_URL_TEMPLATE="http://www.cropinfra.com:8080/weather/resources/fmi/temporal/vips/{0}/{1}/{2}";
String FMI_URL_TEMPLATE="http://192.194.211.203/weather/resources/fmi/temporal/vips/{0}/{1}/{2}";
List<WeatherObservation> observations;
try
{
......
......@@ -24,6 +24,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.SocketTimeoutException;
import java.net.URL;
import java.net.URLConnection;
import java.text.SimpleDateFormat;
......@@ -181,10 +182,15 @@ public class WeatherDataSourceUtil {
InputStream URLStream = null;
InputStream error = null;
String URLOutput;
int connectTimeout = 30;
int readTimeout = 120;
try {
URL weatherURL = new URL(URL.toString());
//System.out.println("URL=" + weatherURL);
URLConn = weatherURL.openConnection();
URLConn.setConnectTimeout(1000 * connectTimeout); // If weather data server does not reply in 30 seconds, abort
URLConn.setReadTimeout(1000 * readTimeout); // If weather data server is not done delivering the data in two minutes, abort
URLStream = URLConn.getInputStream();
URLOutput = IOUtils.toString(URLStream);
List<WeatherObservation> preliminaryResult = this.getWeatherObservations(URLOutput);
......@@ -207,6 +213,10 @@ public class WeatherDataSourceUtil {
errorOutput = IOUtils.toString(error);
} catch (IOException | NullPointerException ex2) {
}
if(ex instanceof SocketTimeoutException)
{
errorMessage.append("The weather data server is deemed unresponsive. The connection times out after " + connectTimeout + " seconds of no reply and " + readTimeout + " seconds of no data received after established connection.\n");
}
if (errorOutput.isEmpty()) {
errorMessage.append("There was no output from weather data server to explain this.");
} else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment