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 { ...@@ -449,7 +449,7 @@ public class SchedulingBean {
" failed at + " + taskExecutor.getStartTime() + " failed at + " + taskExecutor.getStartTime() +
", finished at " + new Date() + ", finished at " + new Date() +
". Status is " + taskHistory.getTaskHistoryStatusId() + ". 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{ ...@@ -249,7 +249,7 @@ public class AppleScabModelPreprocessor extends ModelRunPreprocessor{
//System.out.println(wUtil.dumpWeatherObservationList(RR)); //System.out.println(wUtil.dumpWeatherObservationList(RR));
} }
BT = wUtil.checkForAndFixHourlyTimeSeriesHoles(BT);
// Unequal length of lists // Unequal length of lists
if ( if (
...@@ -267,25 +267,6 @@ public class AppleScabModelPreprocessor extends ModelRunPreprocessor{ ...@@ -267,25 +267,6 @@ public class AppleScabModelPreprocessor extends ModelRunPreprocessor{
// Fallback if missing leaf wetness: If we have relative humidity. leaf wetness may be calculated // Fallback if missing leaf wetness: If we have relative humidity. leaf wetness may be calculated
if(BT.size() != TM.size() && UM.size() == TM.size()) 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); BT = wUtil.calculateLeafWetnessHourSeriesBestEffort(BT,TM, RR, Q0, FM2, UM);
if(BT.size() != TM.size()) if(BT.size() != TM.size())
......
...@@ -210,7 +210,7 @@ public class NaerstadModelPreprocessor extends ModelRunPreprocessor{ ...@@ -210,7 +210,7 @@ public class NaerstadModelPreprocessor extends ModelRunPreprocessor{
// Problems with weather observations // Problems with weather observations
//System.out.println("BT=" + BT.size() + " [First=," + BT.get(0).getTimeMeasured() + " last=" + BT.get(BT.size()-1).getTimeMeasured() + "]"); //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 // Unequal length of lists
if ( if (
......
...@@ -99,7 +99,7 @@ public class WeatherProxyService { ...@@ -99,7 +99,7 @@ public class WeatherProxyService {
@Path("fmi/{stationId}") @Path("fmi/{stationId}")
@GZIP @GZIP
@Produces("application/json;charset=UTF-8") @Produces("application/json;charset=UTF-8")
public Response getMetosRIMProWeatherData( public Response getFMIVIPSWeatherData(
@PathParam("stationId") String stationId, @PathParam("stationId") String stationId,
@FormParam("timeZone") String timeZonePOST, @FormParam("timeZone") String timeZonePOST,
@QueryParam("timeZone") String timeZoneGET, @QueryParam("timeZone") String timeZoneGET,
...@@ -109,7 +109,7 @@ public class WeatherProxyService { ...@@ -109,7 +109,7 @@ public class WeatherProxyService {
@QueryParam("endDate") String endDateGET @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; List<WeatherObservation> observations;
try try
{ {
......
...@@ -24,6 +24,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; ...@@ -24,6 +24,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.SocketTimeoutException;
import java.net.URL; import java.net.URL;
import java.net.URLConnection; import java.net.URLConnection;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
...@@ -181,10 +182,15 @@ public class WeatherDataSourceUtil { ...@@ -181,10 +182,15 @@ public class WeatherDataSourceUtil {
InputStream URLStream = null; InputStream URLStream = null;
InputStream error = null; InputStream error = null;
String URLOutput; String URLOutput;
int connectTimeout = 30;
int readTimeout = 120;
try { try {
URL weatherURL = new URL(URL.toString()); URL weatherURL = new URL(URL.toString());
//System.out.println("URL=" + weatherURL); //System.out.println("URL=" + weatherURL);
URLConn = weatherURL.openConnection(); 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(); URLStream = URLConn.getInputStream();
URLOutput = IOUtils.toString(URLStream); URLOutput = IOUtils.toString(URLStream);
List<WeatherObservation> preliminaryResult = this.getWeatherObservations(URLOutput); List<WeatherObservation> preliminaryResult = this.getWeatherObservations(URLOutput);
...@@ -207,6 +213,10 @@ public class WeatherDataSourceUtil { ...@@ -207,6 +213,10 @@ public class WeatherDataSourceUtil {
errorOutput = IOUtils.toString(error); errorOutput = IOUtils.toString(error);
} catch (IOException | NullPointerException ex2) { } 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()) { if (errorOutput.isEmpty()) {
errorMessage.append("There was no output from weather data server to explain this."); errorMessage.append("There was no output from weather data server to explain this.");
} else { } else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment