Abstract

A more accurate and timely rainfall prediction is needed for flood disaster reduction and prevention in Wuhan. The in situ microelectromechanical systems’ (MEMS) sensors can provide high time and spatial resolution of weather parameter measurement, but they suffer from stochastic measurement error. In order to apply MEMS sensors in real-time rainfall prediction in Wuhan, firstly, seasonal trend decomposition using Loess (STL) algorithm is utilized to decompose the observed time series into trend, seasonal, and remainder components. The trend of the observed series is compared with the corresponding trend of the data downloaded from the authoritative website with the same weather parameter in terms of Euclidean distance and cosine similarity. The similarity demonstrates that the observation of MEMS sensors is believable. Secondly, the long short-term memory (LSTM) is used to predict the real-time rainfall based on the observed data. Compared with autoregressive and moving average (ARMA), random forest (RF), support vector machine (SVM), and back propagation neural networks (BPNNs), LSTM not only performs as well as ARMA in real-time rainfall prediction but also outperforms the other four models in seasonal rainfall pattern description and seasonal real-time rainfall prediction. Our experiment results show that more detailed, timely, and accurate rainfall prediction can be achieved by using LSTM on the MEMS weather sensors.

1. Introduction

Rainfall is one of the major severe phenomena within a climate system. It has a direct influence on water resource management, agriculture, and ecosystems [1]. The heavy rainfall mostly contributes to landslides, mudslides, floods, and other natural disasters. The rainfall-induced disasters in each year lead to serious damage and losses of both life and infrastructure [2]. Take the central large city, Wuhan, for instance, Wuhan locates at longitude between 113°41 and 115°05, latitude between 29°58 and 31°22. Wuhan belongs to subtropical moist monsoon climate [3]. In July 2016, affected by El Nino, Wuhan suffered heavy rainfall disaster. The rainfall from June 30 to July 6 reaches 582.5 mm, which is the highest weekly rainfall since the historical records [4]. It caused severe mass floods, 2.265 billion economic loss, and death of 14 citizens. Therefore, rainfall prediction is a problem that needs to be solved to avoid or minimize losses of both life and belongings.

According to the definition of World Meteorological Organization (WMO) (http://www.wmo.int/pages/prog/www/DPS/GDPS-Supplement5-AppI-4.html), the weather forecasting can be divided into real-time, short-term, middle-term, and long-term forecasting. Real time forecasting means 0–2 hours of weather prediction. Short-term forecasting ranges from 2 hours to 72 hours. Middle-term forecasting is beyond 72 hours and up to 240 hours. Long-term forecasting is beyond 10 days and up to 30 days and further extends to 2 years. Most weather forecasts provide today’s and tomorrow’s weather, an hour-by-hour forecast, and a 15-day forecast for a region. The hour level weather forecasting usually does not provide timely and accurate weather parameters for early warning, especially during rainstorm. The accurate early warning is difficult to extract from the current weather forecasting data to support the emergency response and disaster management. A shorter and more accurate weather prediction is needed for flood disaster reduction and prevention.

Weather parameters have been measured by gauges, weather radars, or satellites. The observation equipment evaluation index involves measurement precision, spatial range, time range, and deployment price. Satellite-based measurement has a wider spatial coverage but a longer repeated observation period. The common sampling interval for weather radar is 15 minutes [5]. The microelectromechanical systems’ (MEMS) sensors for weather observation have the highest time resolution and spatial resolution. The local weather parameters around the sensors can be repeatedly measured within one minute or less. selected points are computed. Combined with the embedded technique and wireless communication interface, such as WiFi, Zigbee, or Bluetooth, an automatic meteorological station can be established. The price to build a meteorological network using MEMS sensors is cheaper than that paid on a radar or a satellite. However, the MEMS sensors suffer from deterministic and stochastic errors. The deterministic error can be removed by calibration techniques before sale. The stochastic error cannot be directly removed from the measurement. The stochastic error is modeled as additive noise [6]. The law of weather change is hidden in the sensor time series with error.

We have built several weather monitoring stations that utilized MEMS sensors to monitor local weather in China. Two stations located in Wuhan. Four stations were deployed around Erhai, Yunnan. Each station has been equipped with seven sensors, which are wind speed, wind direction, atmospheric temperature, atmospheric humidity, atmospheric pressure, rainfall sensor, and radiation sensor. The 7 weather parameters are sampled every 5 minutes. After obtaining weather sensor data for more than 3 years in Wuhan, we wish to demonstrate that the MEMS sensor observation is believable and the data are available to real-time rainfall prediction. The accurate and more timely rainfall prediction can strongly support flooding disaster relief decision.

We focus on the short-term weather variation of Wuhan. It is assumed that the observed sensor time series have trend, seasonal, and residual components. Trend component reflects the progression of the time series, while seasonal component represents the seasonal variation. The original observed data cannot exhibit the trend because of the stochastic error. According to Alexandrov et al. [7], Loess filter behaves well in capturing the details of the trends. Seasonal trend decomposition using Loess (STL) is a filtering procedure that was developed to decompose the time series into seasonal, trend, and remainder components [8]. STL has been demonstrated that it is a robust estimation of the trend and seasonal components. More importantly, STL is able to decompose the time series with missing values, which is the inevitable cases for the wireless sensor network (WSN) due to the interruption of communication link or power-off. Therefore, we applied STL to extract the trend of the observed data and that of the published weather data. The referenced weather data were downloaded from the website (https://rp5.ru/). The validity of the observed time series is proved by calculating the similarity parameters, Euclidean distance (ED), and cosine similarity (CS), between the two trends.

Rainfall is a complex meteorological phenomenon. Accurate and real-time rainfall prediction remains challenging for many decades because of its stochastic and nonlinear nature. The proposed methods for rainfall prediction can be roughly divided into two categories, classic algorithms and machine learning algorithms. The model-based approaches, singular spectrum analysis, and wavelet are the typical classic algorithms. Autoregressive and moving average (ARMA) model is the common time series model for rainfall prediction [9]. The wavelet decomposition uses a pair of filters to decompose the original time series iteratively. The trend is separated from noise at each scale domains. Because wavelet decomposition is usually dependent on other parameter estimation models, its application is less than the ARMA model. We select the ARMA model as the representative of classic algorithms.

In recent years, artificial intelligence (AI) develops rapidly. A great deal of machine learning and deep learning algorithms have been proposed for time series analysis. The models of machine learning algorithms have been applied to solve the real-time rainfall prediction problem. Support vector machine (SVM) shows better performance than random forest (RF) in 2 and 3 h ahead prediction [10]. Artificial neural networks (ANNs), such as radial basic function neural networks (RBFNNs) and back propagation neural networks (BPNNs), also perform satisfactorily in some cases. The best algorithm is difficult to choose, because the data used by the models are different. Recurrent neural networks (RNNs) have been proved well in time series prediction [11]. However, with the vanishing and exploding gradient problems, RNNs are not capable of solving the long-term dependency rainfall sequence. The long short-term memory (LSTM) was proposed in 1997 by Hochreiter and Schmidhuber [12] and was improved in 2000 by Gers et al. [13] to overcome the shortage of RNN. LSTM has been widely acknowledged as the current state-of-art prediction models for time series [14]. We choose the LSTM to predict real-time rainfall based on the observed sensor data at Wuhan University. The experiment results show that LSTM is better to describe the seasonal rainfall process than ARMA, RF, SVM, and BPNNs. LSTM is also found more suitable for the sensor time series that usually have missing data.

This paper has two main contributions. (i) The weather time series sampled by WSN with 5-minute interval have been proved to be effective and valuable in local meteorological monitoring. (ii) The real-time rainfall can be well predicted by LSTM.

The rest of this paper is organized as follows. In Section 2, the WSN for local weather parameter sampling is introduced. The validity of the observed time series is demonstrated in Section 3. Real-time rainfall prediction using LSTM is presented in Section 4. The results of prediction are shown in Section 5. Conclusion is given in Section 6.

2. Weather Data Observed by a Wireless Sensor Network

2.1. WSN for Weather Observation

The WSN for local weather monitoring was built from December 2014 to July 2015. The star topology sensor network shown in Figure 1 is composed of one server and six automatic meteorological monitoring stations that are called sensor nodes. One node powered by electricity was set on the roof of Wuhan University. Another node powered by solar energy was set at Baoxie, suburb of Wuhan. The other four nodes that were deployed around Erhai Lake are all powered by electricity. All the nodes communicate with the server by GPRS (General Packet Radio Service) modules through the China Mobile’s network. The server can send command to adjust the operation of each node. Weather data transmitted from nodes are all saved in the server. Besides, the server provides data services, such as publishing the real-time data on the website or providing data services to specific users. Figure 2 shows the webpage screenshot of our website.

Each sensor node is composed of seven sensors, one Globe Positioning Systems’ (GPS) receiver module, and one GPRS module. Each measurement includes not only the values of the seven sensors but also the corresponding time and the geographical location information (longitude, latitude, and height). The default observation interval is 5 minutes. The repeating measurement cycle can be reset through the command issued from the server to the sensor node.

2.2. Performance of the MEMS Weather Sensors

The performance of each sensor is shown in Table 1. The measuring range and resolution can meet the requirement for weather observation, but the accuracy shows that the deviation is relatively high. Moreover, stochastic error exists in each measurement. Whether the time series observed by WSN is available needs to be proven.

2.3. Fault of the Time Series

There is another problem in the observed time series. The interval between consecutive measurements is not strictly in accordance with the set period. Missing data happened sometime. The reasons include out of power, interruption of communication connection, the system onboard rebooting, or attack on server by a hacker. Therefore, processing the observed weather data may encounter more difficulties than analyzing the authoritative released weather data.

3. Proof of Validity of the Observed Time Series

To prove the validity of the sensor data, we downloaded the weather data of Wuhan City from the website (https://rp5.ru/) as authoritative reference. The downloaded data are provided by the ground stations certified by National Oceanic and Atmospheric Administrator (NOAA). The station locates near Wuhan Tianhe International Airport. Although the station is about 35 kilometers away from our weather sensor node at Wuhan University, both time series reflect the Wuhan weather. Therefore, it is assumed that if the trend of the observed time series resembles closely the trend of the downloaded time series, the observation of the sensor nodes can be applied to weather research.

3.1. Weather Trend Extraction by STL

STL is a filtering procedure for decomposing a time series into three components: trend, seasonal, and remainder components. It is supposed that the weather time series , such as atmospheric temperature, are composed of trend, seasonal, and remainder components, which are denoted by , , and , respectively, for . Then,

is the trend data that are extracted from the observed time series and the downloaded time series.

Key to the STL approach is the locally weighted scatterplot smoothing (Loess) process, in which the closest point is assigned to the biggest weight. Suppose for is the observed time series, and the regression result is the smoothing of given . points that are closest to are used in the regression. The observed time series by WSN were resampled to match the 3-hour interval of the downloaded time series. Considering the 24 hours each day, we set to be 8 with the interval of 3 hours. The weight function is described in the following formula:

Thus, the weights of selected points are computed according to the distance from , as shown in the following formula: where is the distance between the th farthest point and .

Weight of the point decreases with the increasing distance between and . Weight of the th farthest point comes to zero. Then, we can get the regression result using polynomial regression with the weights based on least squares methods (LSM). The polynomial degree is usually set to be 1 or 2, corresponding to linear regression or quadratic regression separately. We chose the quadratic regression. With the smoother Loess, data is divided into trend component of low frequency, seasonal component of high frequency, and remainder component of random variation.

We applied STL to extract the trends of both observed weather data and downloaded weather data. The observed time series started in June 2015 at Wuhan University. Correspondingly, the downloaded weather data also started on the same date. Take atmospheric temperature data in spring 2016, for example, the result of STL decomposition on the observed time series is shown in Figure 3. The result of STL decomposition on the downloaded atmospheric temperature data in 2016 is shown in Figure 4. The falling peak in Figure 4 represents the missing data on 16 July 2016. Because of the robustness of STL, trend has not been affected.

3.2. Similarity Comparison

The paper [15] contributes to presenting an overview of nine similarity measurements for time series data. ED, dynamic time warping (DTW), and CS are widely used to measure the similarity of numerical time series. ED is straightforward for intuitive understanding and easy to implement. In particular, when the length of time series is relatively large, ED is an ideal choice [15]. DTW is designed to handle the time-warping series or the time series in which lengths do not matched [16]. CS is a similarity measure for orientation rather than magnitude. In CS, the cosine of the angle between two vectors is calculated. If the value of CS is equal to 1, the two vectors are in the same direction.

We chose ED and CS to measure the similarity of two trends, ED for magnitude and CS for orientation. Each year, the two types of dataset are divided into four subdatasets according to the seasonal partition of Wuhan [17]. The seasonal division is shown in Table 2. The results of ED and CS in 2016 are presented in Table 3. To make the similarity comparison more visible, two trends of temperature in spring 2016 and their subtraction are shown in Figure 5.

Table 3 exhibits that the trend of the observed time series is similar to that of the downloaded series in terms of atmospheric temperature, atmospheric humidity, atmospheric pressure, wind speed, and rainfall. The reason that the comparison of wind direction was not done is that the downloaded wind direction data is in word description, but the observed wind direction data is in degree number. Table 3 demonstrates that the weather parameters measured by the MEMS sensors can be used for local weather observation and climate research.

4. Local Real-Time Rainfall Prediction with LSTM

Our weather observation node may reflect the weather change of an area around Wuhan University. Real-time rainfall prediction information can attract students’ more attention than the published one-hour forecasting, especially during a thunderstorm. They can decide whether to take an umbrella, whether to go outside, or whether their laboratory has the risk of inundation.

We set the observed time series as the input of LSTM. represents the weather vector observed at time step . According to the correlation analysis of observed weather parameters, atmospheric temperature, atmospheric humidity, atmospheric pressure, and rainfall data are selected as the input vector . Then, the dimension of input data equals to 4. is the length of the observed time series. The output of LSTM is the predicted rainfall data at time step , denoted as . The dimension of output data equals to 1. The actual rainfall value is denoted as . Each time step is set to 5 minutes. It means that LSTM can be used to predict next 5-minute rainfall. We also adjust the interval of each time step to predict 10- or 15-minute rainfall.

The basic unit in the hidden layer of an LSTM network is the memory block. Memory block contains one or more memory cells and three adaptive and multiplicative units [13]. These units are called gates, including input gate, forget gate, and output gate. The structure and data flow of memory block is shown in Figure 6. The symbols , , and , respectively, refer to the input gate, forget gate, and output gate. The symbols and are the memory cell input and cell output activation function, respectively. At each time step , input sequence can be propagated to the memory cell, if the input gate is activated. Forget gate controls whether the past memory cell status can be added as the input to the current memory cell. The updated status of memory cell will be propagated to the output based on the activation of the output gate [18]. The overall data flow can be described with the following mathematical formulas: where denote the input of memory block, and denotes the output of memory block. denotes weight matrices and denotes biases’ vector, which are both shared in all time steps and learned during the phase of training. represents the sigmoid activation function [19]. At each time step , the output of memory block is updated by input sequence , input gate , forget gate , output gate , memory cell status, output , and at previous time step . The predicted rainfall data is the output of LSTM output layer with the as the input.

5. Results

The LSTM was used by two manners to predict rainfall. One is called real-time prediction. The other is called seasonal real-time prediction. Real-time prediction means to predict the rainfall based on the previous adjacent time sequence. Seasonal real-time prediction means to predict the rainfall based on the rules extracted by LSTM from the same season data of the previous year.

We have conducted real-time rainfall prediction by LSTM for 5 minutes, 10 minutes, and 15 minutes based on observations. Considering the weather characteristics of Wuhan, rainy days are much less than nonrainy days in the whole year. A great deal of observed rainfall is equal to zero. Assuming the observed rainfall as positive samples, to balance the positive and negative samples, we select the observations from March 2016 to July 2016 in Wuhan University. This period is called the rainy season of Wuhan. In addition, we select ARMA as the representative of classic algorithms and RF, SVM, and BPNNs as the representatives of machine learning algorithms for performance comparison.

Seasonal real-time rainfall was predicted for 5 minutes, 10 minutes, and 15 minutes in autumn 2016 based on the rules obtained in autumn 2015. ARMA is not suitable for seasonal real-time prediction because it predicts rainfall step by step. We used RF, SVM, BPNNs, and LSTM, respectively, to make seasonal real-time prediction.

5.1. Evaluation Metrics

For numeric weather prediction (NWP), several evaluation metrics have been defined to evaluate prediction performance in the paper [20]. We chose the mean absolute error (MAE) and root mean square error (RMSE) as the evaluation metrics, which are described in the following formulas: where is the length of test set, denotes the actual rainfall data, and is the predicted value at the given time .

5.2. Experimental Results

The real-time rainfall prediction results by LSTM for 5 minutes is shown in Figure 7. Five minutes, 10 minutes, and 15 minutes real-time rainfall are all predicted by five models. The prediction performance are shown in Table 4. Except for SVM, the performances of other algorithms are quite near. LSTM has better performance than the other machine learning models. LSTM has similar performance with ARMA in real-time rainfall prediction. This phenomenon may be inconsistent with the conclusions that LSTM much outperforms classic models in time series prediction. However, it meets the conclusion that machine learning methods such as neural networks (NNs) do not often outperform simple methods for short individual series in the paper [21].

The seasonal real-time rainfall prediction results for 5 minutes in autumn 2016 based on the previous seasonal rules with LSTM are shown in Figure 8. The prediction performance of the four models is shown in Table 5. LSTM outperforms the other models in seasonal rainfall prediction. If the seasonal prediction exhibits large deviation, it may mean that the abnormal rainfall happens. It can be concluded that LSTM not only performs well in real-time rainfall prediction but also works well in seasonal rainfall pattern detection as shown in Tables 4 and 5.

6. Conclusion

The developed automatic meteorological stations based on MEMS sensors can provide high time resolution and spatial resolution weather monitoring. However, MEMS sensors suffer from stochastic error. In order to demonstrate the observed time series by MEMS sensors, STL is utilized to extract trends from the time series observed at Wuhan University. The similarity between the trend of the observed series and the trend extracted from the downloaded authoritative time series with the same weather parameter is computed according to ED and CS. High similarity illustrates that the MEMS sensors of weather can be applied to meteorological research, and their measurement is believable. LSTM is used in two manners for rainfall prediction. Real-time prediction uses the previous sequence to predict the next 5-, 10-, and 15-minute rainfall. Seasonal real-time prediction applies the rule obtained from the previous season to predict the next same season rainfall. Evaluated by MAE and RMSE, LSTM is similar to ARMA but outperforms RF, SVM, and BPNNs in the real-time prediction. LSTM also outperforms RF, SVM, and BPNNs in the seasonal real-time prediction, while ARMA cannot work. Experiment results demonstrate that LSTM is powerful in the extraction of the change rules of seasonal rainfall. Application of LSTM to the time series observed by MEMS weather sensors will provide accurate and timely rainfall prediction to support local heavy rain emergency response.

Data Availability

The data used to support the findings of this study are available from the corresponding author upon request.

Conflicts of Interest

The authors declare that there are no conflicts of interest.

Acknowledgments

This work was supported by the National Key Research and Development Program of China under Grant no. 2016YFB0502601. It was also supported by Major Science and Technology Program for Water Pollution Control and Treatment (2013ZX07105-005-003), and the Fundamental Research Funds for the Central Universities under Grant no. 2042017kf0211. Gratitude is due to Associate Professor Liqiong Chen from Wuhan University, who helped us to establish the WSN.