Wind velocity data interpolation using a weighted cubic spline

. To predict meteorological conditions, it is essential to construct interpolating functions considering the nature of the data. The paper addresses an algorithm for constructing a weighted cubic spline that preserves the monotonicity of the data. The implementation of this algorithm is shown through the example of wind velocity data interpolation when it is required to maintain the positivity of the values. Wind velocity always takes positive values, and its minimum value can be very close to zero. The paper shows that in such a case the construction of an ordinary cubic spline can result in negative values. It presents several numerical examples for the implementation of the proposed algorithm at different sets of initial parameters and makes it possible to draw comparison with the construction of a simple cubic spline and the construction of a spline in MATLAB.


Introduction
Spline construction is used in various meteorological applications related to data interpolation. Among such meteorological data, the following can be mentioned: precipitation, extent of snow cover, temperature (maximum, minimum, and average), humidity, as well as wind velocity and direction. However, in practical problem-solving, classical cubic splines -which are twice continuously differentiable functions -may not retain the geometric properties of the initial data, such as positivity, monotonicity, or convexity. Therefore, to ensure the required properties of a function, various modifications of classical cubic splines have been developed.
Wu et al. [1] studied interpolation of scattered data by using compactly supported radial basis functions, subjected to the constraint of preserving positivity. The authors addressed the application of their algorithm to the interpolation of wind velocity data that can only take positive values. Karim and Raju [2] also considered wind velocity data interpolation. In their paper, they constructed a rational cubic spline and derived conditions on parameters, sufficient to preserve the positivity of spline values. Azizan et al. [3] discussed the construction of a cubic spline for rainfall data interpolation. Sarfraz et al. [4] considered the construction of a rational cubic spline with two parameters to preserve the positivity of the data. All mentioned papers addressed spline construction through the example of meteorological data interpolation aimed to ensure the geometric property of positivity.
Kvasov B.I. [5] proposed algorithms for interpolating using weighted cubic splines with the aim of preserving the monotonicity and convexity of the data. This paper considers a modification of an algorithm for constructing a weighted cubic spline that preserves the monotonicity of the data. It also presents examples of the algorithm implementation for wind velocity data interpolation. The examples given show that in this case preserving the monotonicity of the values makes it possible to retain their positivity.

Definition of a weighted cubic spline
Let us assume that on the segment [a, b] in grid nodes a = x0 < x1 < … <xN+1 = b, values of some function are set: (xi, fi), i=0, …, N+1. (1) Let us introduce the following notation: The shape-preserving interpolation problem [5] is to construct a sufficiently smooth function S such that S(xi) = fi, i=0, …, N+1, and S is monotone on the segments where the initial data is monotone.
A weighted cubic spline with the weights wi > 0, i = 0, …, N is a function S such that: 1) between the grid nodes x0, x1, …, xN+1, the function S is a cubic polynomial; 2) S  C k [a, b], k ≥ 1; 3) wi-1 S''(xi -) = wi S''(xi + ), i = 1, …, N. Let us assume that the cubic spline S satisfies the interpolation conditions: For an unambiguous definition of a spline, we also need boundary conditions. The following types of constraints are those used most often: I

Construction of a weighted cubic spline
Let us introduce the following notations: The spline S can be considered as a Hermite cubic spline that satisfies conditions (2)-(3).
Then for x  [xi, xi+1], it can be written as follows: where t = (x -xi) / hi. The cubic spline represented in such a form on each interval [xi, xi+1] is continuous with its first derivative on the entire [a, b] segment. Using the smoothness condition wi-1 S''(xi -) = wi S''(xi + ), i = 1, …, N, we obtain the following: (5) and i = wi-1 hi / (wi-1 hi + wi hi-1), i= 1 -i. It is required to add equations arising from the boundary conditions to equations (4). Thus, we obtain a system of N+2 equations to determine N+2 unknowns mi, i = 0, …, N+1.
In the case of boundary conditions of type I, we get the following: where c0 = 2f0', cN+1 = 2fN+1' and coefficients ci, i, and i have the form of (5) and (6), respectively.
3 Algorithm for constructing a weighted cubic spline that preserves the monotonicity of the data Kvasov B.I. [5] obtained sufficient conditions for the monotonicity of an interpolating cubic spline. For a monotonically increasing function, the following inequalities shall be fulfilled: Based on these conditions, we can formulate an algorithm for constructing a weighted cubic spline that preserves the monotonicity of the data: 1. First, we determine intervals where the function increases or decreases. 2. Then we determine the first weight parameter w0 by the following equation: choosing some coefficients C0  1 and 0  0.
3. Then we set values for the first derivative: f0' and fN+1', as well as the value for the first derivative at the boundaries of the monotonicity intervals.
4. At each data monotonicity interval, we choose the first parameter wi-1. To ensure spline connection, we take the first parameter wi-1 equal to the last one on the previous segment. If the function monotonically decreases on the interval, we assume that we work with -fi.
Then we choose wi equal to the previous value wi-1. If in this case inequalities (8) and (9) are fulfilled, we assume that wi = wi-1. If one of the inequalities is not fulfilled, then we calculate wi based on the inequality that is not fulfilled at wi = wi-1, replacing the inequality sign with an equal sign.
If at any step wi < , then we assume that wi = , where  is a sufficiently small positive number. This way, we find all weight parameters wi on each function increasing or decreasing interval.
5. Finally, we find a solution for the system of equations (7) and construct a weighted cubic spline S on each monotonicity interval individually.

Numerical results
Let us show the implementation of this algorithm for the interpolation of hydrometeorological data, namely wind velocity. Table 1 presents wind velocity data [2]. The velocity of wind is inherently positive; therefore, we need the resulting approximating function to preserve this geometrical property. Fig. 1 shows data interpolation using a cubic spline, which can be considered as a weighted cubic spline with all weight coefficients equal to one. Here and in all figures below, the points denote the initial data, and the line denotes the constructed interpolating spline. As can be seen in the figure, when an ordinary cubic spline is constructed, there is an interval on which the constructed spline takes negative values.   Table 1 using the MATLAB interp1 function. In this case, the pchip construction method was applied, which uses shapepreserving piecewise cubic interpolation. The pchip function can preserve the positivity of wind velocity, but the interpolating curve is not visually pleasing since on some intervals, the interpolating curves are very tight as well as very sharp [2]. Let us then set values for the first derivative: f0' = 0 and fN+1' = 0, as well as equal to zero at the ends of the function increasing and decreasing intervals.
At each data monotonicity interval, we determine the weight parameters wi according to the algorithm.
Then we find a solution for the system of equations (7) and construct a weighted cubic spline on each monotonicity interval individually. Fig. 3 shows the resulting weighted cubic spline. Table 2 presents values of the first derivative and weight parameters.  We can change the shape of the interpolating curve by setting other values of the first derivative on the boundaries of the intervals. For the next example, we determine the values of the first derivative at the first and last points by the following equations: At intermediate points, similarly to the previous example, we take the values of the first derivative equal to 0. Fig. 4. Example of an interpolating curve using a weighted cubic spline with parameters described in Table 3 Fig. 3 and Fig. 4, we can see differences in the shape of the outermost splines.

Discussion and conclusion
In the course of the work, an algorithm for interpolation using a weighted cubic spline that preserves the monotonicity of the data was developed. The algorithm is based on the determination of the function increasing and decreasing intervals. In this case, the values of weight parameters are chosen in such a way that wi-1 S''(xi -) = wi S''(xi + ). Then a weighted cubic spline is constructed on each monotonicity interval individually so that it would be possible to preserve the continuity of the first derivative. Based on a numerical example of wind velocity data interpolation, it was shown that this algorithm can be used to construct an interpolating spline retaining positive values.