Gap-filling meteorological data series using the GapMET software in the state of Mato Grosso, Brazil

HIGHLIGHTS: GapMET provides accurate gap-filling methods for meteorological data series. Simple linear regression gap-filling had more accuracy for Mato Grosso’s automatic weather station network density. The use of satellite data as reference series reduces chances of fails to gap-fill, but also reduces the filling accuracy. ABSTRACT This paper aimed to introduce the GapMET software, developed by the authors, and evaluate the accuracy of its six methods for gap-filling the main meteorological variables monitored by weather station in the state of Mato Grosso, Brazil, using reference time series from neighbour weather station and/or remote sensing products. The methods were tested on seven different databases, with 25 to 80% artificial gaps, and their accuracy was given by the number of gaps left unfilled, the bias, the RMSE, and Pearson’s correlation. The GapMET software showed good results in filling meteorological gaps regardless of the method applied. Methods that use only one neighbour weather station as a reference series showed better results because, in the state, the minimum distance for a weather station to have at least three neighbours as reference was 350 km, reducing the climatic similarity between them and consequently the accuracy when more than one reference series were needed. The use of satellite reference series reduced the probability of unfilled gaps; however, it showed higher bias and RMSE and lower correlations.


Introduction
Meteorological time series are essential to designing agrometeorological and environmental projects (Xiang et al., 2020;Sarnighausen et al., 2021).However, in Brazil, acquisition and storage of automated weather station (AWS) data are susceptible to instrumental and operational failures (Bier & Ferraz, 2017;Brubacher et al., 2020), affecting their use to assess climatic trends, stationarity, or seasonality (Box & Cox, 1964).
Although statistical analyses are used to calibrate and validate these methods, there is no consensus of which is the best methodology or reference dataset, since it depends on the desired accuracy and on the number and distance of nearby AWS.The state of Mato Grosso, despite its dimension and different climate types: Af (tropical rainforest climate), Aw (tropical savanna climate), and Cwa (tropical climate) (Souza et al., 2013;Jerszurki et al., 2019), has only 33 AWS of the National Institute of Meteorology (INMET) that meet the world meteorological organization (WMO) minimum period requirement (10 years) to estimate Provisional Climatological Normals (WMO, 1998).
Therefore, this paper aims to introduce the GapMET, a software program for gap-filling meteorological data series developed by the authors, and evaluate the accuracy of its six methods (MAS, MUK, MID, MPR, RLS, and RLM) for gap-filling the main variables monitored by AWS in the state of Mato Grosso, using reference time series from neighbour AWS and remote sensing.

Material and Methods
The time series, with data from 01/01/2008 to 12/31/2020, were obtained from automatic weather stations (AWS) belonging to the National Institute of Meteorology (INMET), located in 33 municipalities in Mato Grosso state, Brazil (Table 1).In each AWS, datasets of the meteorological variables were collected: downward solar radiation (SRD -MJ m -2 per day), relative air humidity (RH -%), maximum air temperature (Tmax -°C), minimum air temperature (Tmin -°C), and mean wind speed at 2 m (WS -m s -1 ).
The gap-filling was done by GapMET 1.0 program, developed by the authors in MATLAB and 'R' language, and available at (https://github.com/Marlus-Sabino/GapMET).GapMET allows one to choose among six methods of gapfilling that are commonly used in Brazil, as well as setting the reference time series between neighbour AWS or external datasets.
The GapMET flowchart is shown in Figure 1.In the program, the user needs to input five parameters: 1) Type of reference series (neighbour AWS or external datasets); 2) Gapfilling method (simple arithmetic means -MAS, UK traditional method -MUK, inverse distance method -MID, regional weighting method -MPR, simple linear regression -RLS, or multiple linear regression -RLM); 3) Maximum standard deviations (limits the filling values between "D" standard deviations of the mean observed data); 4) Maximum distance between AWS (a limit, in km, for an AWS to be included as reference time series); and 5) Minimum reference AWS (defines the minimum amount of reference AWS required for the method).In addition, the user must provide the original dataset to be gap-filled, along with the geographic coordinates of the AWS (in methods that use neighbour AWS as reference) or the external reference time-series datasets.
In the selection of neighbour reference AWS, a less than 350 km distance was established as inclusion criteria.This distance was chosen because it was the minimum distance at which there were always at least three neighbours as reference time series.In the methods in which gap-filling is performed using only 1 AWS as a reference (RLS and MUK), within the AWS that passes the distance criteria, the one with the highest absolute value of Pearson's correlation coefficient was selected.Finally, since the wind speed measurements did not show a Gaussian distribution, a maximum of five standard deviations (D = 5) was adopted.
In the methods that used remote sensing datasets as reference time series, data from the meteorological reanalysis products from the land component of the fifth generation of European ReAnalysis (ERA5-Land) were used.These products, according to Muñoz-Sabater et al. (2021), are generated by the assimilation of data from surface and atmospheric observations from various sources into models that are physically and dynamically consistent.ERA5-Land products are freely available by Muñoz-Sabater (2019) in partnership with the independent intergovernmental organization Copernicus Climate Change Service (C3S/ECMWF) and are developed in hourly or monthly temporal resolution and 9 x 9 km spatial resolution.
The six methods of gap-filling tested were separated into two groups: 1) methods that use only neighbour AWS for reference time series, denoted with a (v) after the method initials; 2) methods that use as reference time series both neighbour AWS (v) and external datasets of the ERA5-Land product, denoted with an (s) after the method initials.
The methods belonging to group 1 were: i) simple arithmetic mean (MAS) (Eq.1), in which the missing data are obtained by the mean of the values observed in the neighbour AWS; ii) inverse distance method (MID) (Eq.2), whose gapfilling is performed by the mean values of the neighbour AWS weighted by their distance from the gap-filled AWS; iii) regional weighting method (MPR) (Eq.3), which uses mean values of the neighbour AWS weighted by their historical time series mean; iv) multiple linear regression (MLR) (Eq.4), in which the estimate is obtained by the linear and angular coefficients of a linear regression between the gap-filled AWS and the neighbour reference AWS.
The methods belonging to group 2 were: i) the traditional method of the United Kingdom (MUK) (Eq.5), in which the estimate is made assuming a constant difference value between the historical mean on the reference series and the gap-filled AWS; ii) the simple linear regression (RLS) method (Eq.6), Figure 1.Flowchart of the GapMET gap-filling meteorological data procedure which uses the coefficients obtained from the linear regression between the gap-filled AWS and the neighbour reference AWS.

Results and Discussion
The effects of the percentage of gaps on the accuracy of the different gap-filling methods (Table 2) indicate that the errors rise with the increase of gaps in the time series, reaching, on average, 2.42% of unfilled gaps, 1.37% Bias, 10.08% normalized RMSE and minimum correlation of 0.6851, in the time series with up to 80% missing data.
Among the methods, those belonging to group 1 (MAS, MID, MPR, RLM) showed, in general, the worst results with an increase in the error magnitude as more gaps were added to the time series.This aspect is more explicit in the ability to fill all gaps, which shows that in the methods of group 1, approximately 0.05 to 9.94% of the gaps were left unfilled, while in the methods of group 2 (MUK (v) and RLS (v)), the remaining unfilled gaps do not exceed 0.1%.This is mainly because the methods of group 1 require at least three neighbour AWS with data to fill the gaps; consequently, the increase in missing data in the time series of all AWS reduces the probability of meeting this condition.
In addition, as GapMET allows the estimated data in an AWS to be used as reference when gap-filling a neighbour AWS, error propagation can occur when not using only original measure of the variable.This process, however, does not occur in the methods that use external series (MUK (s) and RLS (s)), since these series, a priori, do not have gaps, consequently allowing the errors to remain relatively constant regardless of the number of gaps in the time series to be filled.Therefore, in methods with external series, the accuracy depends only on the quality of the external datasets.
Nevertheless, it is important to note that the performance errors are similar among the methods in the tests with up to 40% missing data.Therefore, in the real circumstances of the AWS time series of Mato Grosso state, whose number of missing data is approximately 20%, all gap-filling methods showed good results.
The results of Bias (Figures 2A to E), RMSE (Figures 2F to J), as well as the dispersion and correlation of observed and gap-filled data (Figure 3) as a function of the meteorological variable and method, are shown below.The variables relative air humidity (RH), maximum air temperature (Tmax), and minimum air temperature (Tmin) showed more accurate gap-filling estimates, with bias ranging between -1.0 and 1.5% and Pearson's correlations between 0.69 and 0.91.On the other hand, the variables incident global radiation (SRD) and wind speed (WS), despite generating bias between -3 and 5% (except for the MPR method), showed greater dispersion of the estimated data, with correlations lower than 0.60 for SRD and lower than 0.75 for WS.
Variables are shown on Y axis: SRD -Downward solar radiation; RH -Relative air humidity; Tmax -Maximum air temperature; Tmin -Minimum air temperature; WS -Wind speed.Gap-filling methods are shown on X axis: MAS -Simple arithmetic means; MUK -UK traditional method; MID -Inverse distance method; MPR -Regional weighting method; RLS -Simple linear regression; RLM -Multiple linear regression.Gap-filling methods followed by (v) used neighbour weather stations as reference time series, while methods followed by (s) used remote sense data as reference where: X i -variable to be gap-filled in AWS "i"; n -number of AWSs considered; X r -corresponding observed data in the reference AWS "r"; d r -distance between the AWS to be filled in and the reference AWS "r"; Xm r -historical averages in the reference AWS "r"; Xm i -historical average in the AWS to be filled; β 0 -linear coefficient of the regression; β 1 -angular coefficients; and, β 1r -angular coefficients to be estimated at reference stations "1" to "n".
The preliminary analysis of the 33 automatic weather stations in the state of Mato Grosso showed that each AWS had, on average, 18.61% gaps in the time series of each variable reaching a maximum of 62.06% (Table 1).Hence, to test the potential of each gap-filling method to estimate the variable for different possible amounts of gaps, from the original database of each meteorological variable, seven databases containing artificially and randomly inserted gaps were generated, so that in each AWS there were 25, 30, 40, 50, 60, 70 and 80% gaps in the time series.
The gap-filling accuracy was obtained by comparing the observed with the filled data of the artificially inserted gaps employing the bias, the root mean squared error (RMSE and normalized RMSE), Pearson's correlation coefficient, and the percentage of data not filled.Finally, the filling methods were ranked in a way that the methods whose results of Bias, RMSE, and percentage of unfilled gaps were closer to zero and whose Pearson coefficients, in absolute values, were close to one received better positions (lower rank value).Gap-filling methods: MAS -Simple arithmetic means; MUK -UK traditional method; MID -Inverse distance method; MPR -Regional weighting method; RLS -Simple linear regression; RLM -Multiple linear regression.Gap-filling methods followed by (v) used neighbour weather stations as reference time series, while methods followed by (s) used remote sense data as reference time series effects not considered in the methods, such as altitude and cloud cover (Xavier et al., 2016).
Based on the ranking results as a function of the different errors (Figure 4E), better performances are observed for the methods of group 2, especially the RLS method.In this group, methods based on ERA5-land data showed lower performance in terms of RMSE and Pearson's correlation (Figures 4C and  D).However, these methods were able to reduce the probability of unfilled gaps and showed less dispersion of errors with an increase in missing data (Figures 4A and B), indicating that the test with other external databases besides ERA5-land could promote improvements in the estimates.
Meanwhile, the RLM method, despite obtaining good positions in the analysis of bias errors, RMSE, and correlation (Figures 4B, C and D), had more difficulty in filling in all missing data of any meteorological variables (Figure 4A).
Gap-filling methods are shown on Y axis: MAS -Simple arithmetic means; MUK -UK traditional method; MID -Inverse distance method; MPR -Regional weighting method; RLS -Simple linear regression; RLM -Multiple linear regression.Gap-filling methods followed by (v) used neighbour weather stations as reference time series, while methods followed by (s) used remote sense data as reference time series.Methods with lower rank value show better results These results disagree with those found by Fernandez (2007), Ventura et al. (2016), andBier &Ferraz (2017), who suggested the RLM method as the most accurate among similar methods considered in this study.However, these authors did not consider the impact of the increase in the number of missing data, which were being tested in time series with a percentage of gaps below 30% of the datasets.Bleidorn et al. (2022), for example, compared the MAS, RLS, and RLM methods with a percentage of missing data ranging from 5 to 40% and observed better performances with the RLS method.In this case, these results were justified by the algorithm used, which, similarly to GapMET, selects the reference AWS by the highest correlation coefficient, allowing the change of the reference AWS when finding missing data in it, which does not occur with the RLM method, which requires at least three reference AWS.Besides, it is also important to highlight that, when evaluating the performance in the datasets with less than 40% of missing values (Table 2), the errors were similar among all methods, and in the analyses of the normalized RMSE and Pearson's correlation coefficient the RLM method showed better performance than the RLS.
Moreover, the lower performance of group 1 methods, as well as the divergences between these results and the literature regarding the differences between the RLS and RLM methods, results from the fact that in this study the minimum distance for all AWS to have at least three reference AWS was 350 km, while in Fernandez (2007), Ventura et al. (2016), andBier &Ferraz (2017) this distance was, usually, less than 100 km due to the higher AWS network density of the South and Southeast regions of Brazil.The use of nearby AWS as reference is justified because, in general, it has a higher correlation with the AWS to be filled, reducing the risk of using AWS that are in different climatic regions (Brubacher et al., 2020), although the use of 100 km criteria can limit the gap-filling in areas with low AWS network density, such as in the Mato Grosso state.

Conclusions
1.All six methods of the GapMET software had good performance for gap-filling meteorological datasets with less 40% of missing values.
2. In Mato Grosso state, Brazil, with minimum distance between AWS of 350 km, the best statistical performances are obtained with methods that use only one reference AWS, especially RLS.
3. The use of refence series obtained from remote sensing reduces the probability of unfilled gaps; however, an analysis of other satellite products sources is necessary to reduce RMSE and improve the correlations of the estimated data.
Mean performance of the six Gap-filling methods based on the percentage of artificial missing data generated in the time series of 33 weather stations in the state of Mato Grosso, Brazil MAS -Simple arithmetic means; MUK -UK traditional method; MID -Inverse distance method; MPR -Regional weighting method; RLS -Simple linear regression; RLM -Multiple linear regression time series.The red line on the diagram represents the Pearson correlation coefficient (r), and the colour variation represents the amount of data in the x and y coordinates Similarly, Ventura et al. (2016) and Xavier et al. (2016) found better estimates in the variables air temperature and relative air humidity compared to the variables wind speed and incident solar radiation.The lower precision in gap-filling the variables SRD and WS can be explained by the fact that the daily values of these variables show greater spatial variations when compared to Tmin, Tmax, and RH, in addition to local Meteorological variables: SRD -Downward solar radiation; RH -Relative air humidity; Tmax -Maximum air temperature; Tmin -Minimum air temperature; WS -Wind speed.

Figure 2 .Figure 3 .
Figure 2. Performance of Bias (A to E) and root mean squared error (F to J) based on the meteorological variables and methods used to gap-fill the time series of 33 weather stations in the state of Mato Grosso, Brazil

Figure 4 .
Figure 4. Error analysis ranking of the six methods to gap-fill meteorological data of 33 weather stations in the state of Mato Grosso, Brazil