Saviztky–Golay Filtering for Solar Power Smoothing and Ramp Rate Reduction Based on Controlled Battery Energy Storage

Energy is present in every touch we make in our modern life. However, with the increase of energy-consuming devices, there is a burden to meet this demand with a clean power generation. Although solar and wind are considered as clean and renewable energy resources, many issues engender with their higher penetration into electricity grids. However, when renewable energy resources are integrated with battery energy storage systems (BESS), more smoothed and easily dispatchable power can be obtained. This paper investigates the smoothing quality of the solar photovoltaic power output with the help of BESS using a couple of approaches such as low pass filtering (LPF), moving average (MA) filtering, Gaussian filter (GF) and Saviztky-Golay (S-G) filter. Obviously, the smoothed dispatchable power has been achieved with all mentioned methods, however, the performance of moving average and low pass filters is not acceptable comparatively especially when longer window size and time constant are used, which consequently deteriorates the performance of storage system. In contrast, the paper introduces using the Savitsky-Golay filter to reduce battery ramp rate and battery charging and discharging power while smoothing the solar power fluctuations. The simulation results depict the performance of the proposed smoothing filter and compare its performance against MA, LPF and GF.


RE
Renewable energy BESS Battery energy storage system ESS Energy storage system SoC State of charge PV Photovoltaic S-G Savitzky-Golay filter LPF Low pass filter MA Moving average GF Gaussain filter P PV Original photovoltaic power P PV Average of photovoltaic power The associate editor coordinating the review of this manuscript and approving it for publication was Firuz Zare.

P po
Smoothing filter power P (grid) Dispatched power into the grid E BESS Battery storage capacity K Zoom coefficient T f Filtering time constant SoC mh The upper limit of the battery's state of charge SoC mL The lower limit of the battery's state of charge P (ref ) Reference power before and after smoothing

I. INTRODUCTION
Nowadays, energy attached to people's lifestyles in a way that makes it more convenient than a few years ago. But unfortunately, conventional power sources use fossil fuel to generate power which emits CO 2 and contributes significantly to the global warming phenomenon. So globally there are many efforts to escalate the use of renewable energy resources which they represent a secure future to generate green power with tremendously low operational cost. However, renewable energy resources typically solar photovoltaic panels and wind farms are weather dependent and they produce unsynchronized power with the load demand [1]. So, with the increase of using renewable energy many problems arise such as voltage deviation, frequency issues and fluctuation of the output power [2]. Power fluctuation, for instance, makes problems with the automatic voltage regulator as it tries to keep the voltage within acceptable limits. Neglecting the effects of PV penetration could cause utility grid damages and even blackouts [3]. Linking to that, power fluctuations also affect on-load tap changers as they change the position on the secondary winding to correct the downstream voltage and the frequent tap changes ended up with more operation and maintenance cost [4]. The previously mentioned problems stand beyond the intermittency of these resources as the generated power is uncontrollable, unpredictable and natural dependent. Review studies demonstrate the capability of integrating energy storage systems (ESS) with renewable energy resources to solve the issue of intermittency, ramp rate and attain more dispatchable power to the grid. In addition, ESS can mitigate power quality issues that may engender from integrating renewable energy resources with the grid [5]. Enhancing the performance of renewable dispatchable power is achieved by smoothing the output power. Many techniques are presented to smooth the output power typically using moving average filter, model predictive control, Kalman filter, and low pass filter. Low pass filter and moving mean algorithm have been adopted as solutions to smooth the PV power before it will be injected into the grid. In [6], a double and simple moving average algorithm has been used with the ESS to smooth the recorded photovoltaic power data. Results show a significant delay is observed with the increase of the window size which means a bigger battery size. In addition, a comparison between using a simple moving average algorithm, exponential moving algorithm and low pass filter have been presented in [7]. Results conclude that low pass filter overperforms simple and moving average algorithm to smooth the wind power fluctuations with smaller battery size.
Smoothing with the help of moving-mean algorithms could introduce bad power tracking in case of using large window size. Bad power tracking changes the battery's state of charge (SoC) and causes the battery to consume more energy as it's shortening the battery's lifetime accordingly. On the other hand, a smoother PV power output can be obtained with a large time constant in case of a low pass filter. The large filter time constant means the larger battery size must be installed which violates the economic considerations.
This paper presents various methodologies to smooth the PV power output before it will be dispatched into the grid to avoid the consequences of voltage fluctuations. Besides, it gives a comparison between them based on the degree of smoothing and their power tracking capability. Additionally, the paper introduces a battery charging control based on charge-discharge depth SoC integrated with the smoothing methodologies. Simulation results demonstrate that the Savitzky-Golay filter along with the ESS shows smoother output and good power tracking comparing with moving mean and low pass filter.
The structure of this paper is organized as follows: Section III and Section IV represent the problem statement and the proposed methodology respectively. The databases have been demonstrated in Section V which is followed by the simulation results in Section VI and finally, the conclusion is given in Section VII.

II. RELATED WORK
Literature reviews revealed that the characteristics of solar output power could be improved by integrating the PV generation with a battery storage system as it adds more flexibility and more power management. Authors in [8] address a solution to the issue of renewable intermittency called general energy filters to demonstrates their capability of power smoothing and show the implementation of filters as series or parallel configurations. The proposed filter works as a low pass filter which can be designed based on its orders and their transfer functions. Furthermore, the study tests a caparison between first and second general energy filters, results show that a better smoothing performance obtained with a second odder filter regardless of the implementation cost. The author in [9] shows that implementing an SoC feedback control with the low pass filter methodology yields a smooth output and a higher battery lifetime could be obtained. The proposed study in [10] proves the relation between optimal capacity and the number of batteries. The results have been assessed by adopting a monotonic charging and discharging approach to optimize the size of battery storage along with reducing the power variations.
Also, the study in [11] presents the smoothing of solar PV output by using an ESS incorporated with a Fast Fourier Transform approach, which has been used for weather spectrum analysis. The PV output power frequency has been classified into low and high as a result the lowest-cost energy storage solution against the weather spectrum is selected to smooth the power. In [12], smoothing the output power besides improving the power quality was demonstrated by using a unified control methodology along with using an active harmonic filter. The author in [13] introduced a realtime dispatch methodology to smooth the active power variations by continuously updates the values of the output power and the forecasted demand power.
In [14], solar active power curtailment is implemented along with designing an optimal allocation model for the hybrid ESS to smooth the power fluctuations.
Moreover, in [15] solar power smoothing has been carried out using two strategies; firstly, using a moving average filter by averaging a data series of the power for a predefined time interval as the data was taken during summer and winter. During summer the battery was subjected to 3.25 cycles while it subjected to 1.4 in winter. Secondly, the paper proposed using an energy block to maximize the use of ESS and minimize the energy bought from the grid. In addition to that, [16] proposes a simple window and half moving average algorithm along with an integral control approach to smooth the power and reduce the battery size and to reduce the change in the state of charge that may be resulted from moving window algorithm alone with the BESS. Furthermore, in [17] an optimal feedback control with a genetic algorithm has been applied for a battery energy system connected with the PV panels to mitigate the power output fluctuation. Results illustrated the enhancement in PV panels dispatching. In addition to that, the smoothing of hybrid PV/wind power is carried out with the help of fuzzy logic control in [18] while in [19] smoothing of a wind farm power is done along with washout filter-based control. In [20], the inertia of the wind turbines rotor is utilized as energy storage to smooth the short-term fluctuations. The study in [21] demonstrates the smoothing of wind power variations using adaptive Kalman Filter. Besides, reducing the capacity of the storage has been achieved by adjusting the filter parameter with wind power variations. Additionally, in [22] the dispatch of a wind farm is done on an hourly basis by designing an optimal loop control with taking the battery constraints into consideration, typically the charge and discharge limits besides the lifetime of the battery. The provided study in [12] demonstrates using the battery system to smooth the wind power fluctuation along with removing harmonics distortions out form the grid by applying unified control topology.
In [23], model predictive control is used to smooth the wind fluctuations which is used to predict the wind power generation and used it as input and feed it to the controller, the control system is used to optimize the maximum ramp rate requirements besides battery SoC. The author in [24] compares the needed energy capacity when wind turbines are located close and far to each other. Results show that distributed arrangement needs a smaller amount of energy for power smoothing comparing to the aggregated arrangement. the study in [25] shows a flywheel energy system to smooth wind output power by making limited capacity flywheel to produce more power to get more smoothed power from the wind farm. The predicted wind power besides the state of charge of the flywheel are inputs to a sliding mode filter which determines the output power. While [26] presents a novel approach to predict the wind output power which useful to enhance the climbing rate performance which helps to control the dispatched wind power. A voltage controller has been used to control the state of charge of supercapacitor besides generating a power profile to smooth the fluctuated power and reducing the high-frequency components of the injected power from the renewable energy [27].
Over and above, Savitzky and Golay have been proved experimentally that least square smoothing reduces data noises and keeps the main characteristics of the data the width, peak, high, and width [28], [29]. Savitzky-Golay filter is widely used to smooth and differentiate time-series data which has been extensively applied in magnetic resonance imaging, speech enhancement, biological, and biomechanical data processing based on its property of maintaining the original signal characteristics whereas removing noises [30], [31].

III. PROBLEM STATEMENT A. INVESTIGATED SYSTEM
Injecting high fluctuated solar photovoltaic power will affect the operation of the low voltage grid, makes mechanical problems with the automatic voltage regulator, and tap changer failures which lead to sever utility damages and even blackouts. To solve the issue of power fluctuations, a battery storage system is connected with the grid along with a smoothing control system to smooth the injected power as shown in Fig. 1.
The system is composed of photovoltaic array beside a boost converter which represents the PV module. Furthermore, the energy storage module combines a battery and a DC-DC converter. The modeled system also contains a DC-AC inverter to dispatch the power into the utility grid. The model contains a state of charge controller connected with the battery system and a smoothing algorithm. The purpose of the smoothing algorithm and the battery management system is to smooth the PV output power as solar irradiance and ambient temperature are uncontrolled in nature. The difference between the real PV power and the output from the smoothing topology will be responsible for charging and discharging the battery system. The resultant power of real PV and the battery output represents the smoothed power, which has to be injected into the grid.
The goal of the study is to smooth the fluctuated PV power whereas controlling the battery ramp rate based on low pass filter, then using a moving average and Savitsky-Golay filter. Smoothing of the fluctuated power not only helps to dispatch a power that complies with the gird code but maximize the total benefits of the PV power as it becomes more controllable.

B. SOLAR POWER GENERATION
The generated power from the solar panels is influenced by the amount of subjected irradiation. The following equation  has been used to calculate the solar-generated power where ε(w/m 2 ) is the global horizontal radiation of the photovoltaic panels whereas the surface of the panels is denoted with s pv . The efficiency of solar conversion is η cell give by and 10% is assumed for the solar conversion.

IV. PROPOSED METHODOLOGY
Smoothing of the photovoltaic power is carried out using different smoothing methodologies. The proposed methodology is firstly executed using a low pass filter, then using a moving average and Savitsky-Golay filter.

A. LOW PASS FILTER
The low pass filter purpose is to filter the high-frequency components from the low-frequency components. The unsmoothed PV output power serves as a control signal that has to be smoothed with the help of the low pass filter. The difference between the smoothed and the unsmoothed photovoltaic signal represents a charging and discharging signal to the BESS. The structure of the model is illustrated in Fig. 2 where P PV is an unsmoothed PV signal while P po is the smoothed output power. Where P ref represents the reference signal between the expected and the unsmoothed PV output. P BESS the charging or discharging battery power and P grid represents the power that has to be injected into the utility network. For selecting filter time constant is selected to account for solar irradiance variation taking into consideration not violating the ramp rate of the grid by 10%. The transfer function of the smoothing filter is given by (2).
The significant smoothing of the filter stem from the effect of the time constant (T f ); the bigger the value of the time constant the more smoothed output power. The reference power before and after the filter is given by (3).
The relation between the battery storage capacity and the state of charge is given by: By assuming the battery has a large capacity means the battery output power can handle the expected photovoltaic output power. And then the battery charge/discharge capacity is the product of the expected PV output power with the time constant: The rated solar power is the average of the output power given byP PV .
There are three cases when the discharge and charge rate equal, bigger, or less than battery storage capacity: Case1: When the product of the rated generated solar power and the and the filtering time constant is higher than the battery capacity. The battery's SoC will exceed the maximum limit of the battery state of charge and lead to overcharging the battery.
Case 2: When the product of the rated generated solar power and the filtering time constant equals the battery capacity. The actual capacity of the battery equals the rated capacity so the maximum battery's SoC equal to 100%.
Case 3: When the product of the rated generated solar power and the filtering time constant is less than the battery capacity. The maximum battery's SoC will be less than 100%. Therefore, lower battery capacity could be utilized To solve the issues that may engender from overcharging or discharging the battery storage a zoom coefficient is added to smoothing time constant. The value of K is subject to the relation (0<K<1). By introducing k coefficient Case 3 will be as following: further by introducing the upper and lower limit of the state of charge, where SOC mh and SOC mL represents the upper and lower limits respectively.
(SoC mh + SoC mL ) * E BESS = E BESS − KT f * P PV (S) (13) To control the battery storage output feedback control of the state of charge is integrated with the system. The resulting VOLUME 8, 2020 discharged battery power equals the sum of the smoothed PV power and the storage capacity margin with real charge and the discharged power: In this case, the capacity of the battery is limited by the coefficient K which means a degree of smoothing the expected PV power is violated. The coefficient K can be optimized. The provided control schematic in Fig. 4 illustrates integrating SoC feedback control with the low pass filter. It is clear from Fig. 3, the dispatched power into the utility is as shown by (15).
When the P BESS > 0 the battery in discharging mode and when P BESS < 0 means the power is injected into the storage system and the battery in charging mode.

B. MOVING AVERAGE ALGORITHM
The real photovoltaic power and the window size are the only inputs to the algorithm. The moving mean algorithm calculates a reference power value by averaging a recorded power data for a certain period. The difference between the real PV power data and the power after applying the smoothing algorithm will charge and discharge the battery. The degree of smoothness can be adjusted by changing the value of the window size taking into consideration a large window size that will lead to better smooth dispatch-able power as it may create some delay or bad tracking. The moving average algorithm is given as follow: The M points are used to calculate the average of a given power series over time while N is total data points. The output is given by Y i while the input signal is given by S i+j . (17) is used when M is odd.

C. SAVIZTKY-GOLAY FILTER
Saviztky-Golay filter is a moving average filter where a leastsquare polynomial fitting is done over the moving average, whereas it is preferred over moving average filter as it keeps the main characteristics of the data the width, peak, high, and width which is attenuated by moving average filter. A good smoothing signal could be obtained with a higher or moderate polynomial order [32].To understand the smoothing performance of S-G filter we consider an estimated time series represented by x(n) whereas the observed time series is represented by y (n) = x (n) + w(n) where w (n) is a noise signal applied on y(n). By applying the S-G filter to the data series, the outputx(n) will be calculated as follows: S-G filter parameter is donated by M where h(n) is the filter impulse response given for (|n| ≤ M ). S-G filter definesx(n) at (n = 0) to be the coefficient of polynomial k that best fit y(n) over (|n| ≤ M ). The polynomial and the squared error between the smoothed and the unsmoothed signal are calculated by (19) and (20) respectively as follows: 33810 VOLUME 8, 2020 The best-fitting polynomial ofx(n) is given by p(0) = C(0), as C (0) is the best fitting polynomial coefficient. the polynomial order k must satisfy the following condition (0 < k ≤ 2M ) as the impulse response is symmetric around (n = 0)that implies h (n) = h (n) [33]. The transfer function of the filter with the impulse response is given by the following equation:

D. GAUSSIAN SMOOTHING
Gaussian smoothing has been widely used with image processing and computer applications. Authors in [34] use the gaussian smoothing to smooth the renewable energy generation and to highlight its capability of reducing the pitfalls of moving average filter. The performance of GF smoothing is like the moving average filter. however, the degree of smoothing is determined by the standard deviation of the gaussian. In filtering different kernel is used which produces the bell-shaped distribution. The gaussian filtering in 1-D is given in (22).
where σ is the standard deviation of the gaussian.

V. DATABASES
To investigate the proposed methodology by simulations, actual recorded solar irradiance and temperature data are considered as shown in Fig. 4 and Fig. 5 respectively. The photovoltaic power output data has been simulated based on 200 KW PV panels subjected to real solar irradiance and cell temperature data which have been imported from the GECAD Photovoltaic system (PV) database as shown in Fig. 6. The data has been recorded for 1400 minutes in May 2013.

VI. SIMULATION RESULTS
Smoothing of photovoltaic power is performed with the help of a low pass filter with 10 min time constant as it is shown in Fig. 7. Fig. 8 shows a comparison between different filter time constants for smoothing typically 20, 40 and 60 minutes   where a smoother power is obtained in the case of 60 minutes time constant. Setting filter time constant is crucial to determine the degree of power smoothing as the smoother power could be dispatched the larger time constant is needed with the low pass filter. Furthermore, with increasing filter time constant more delay is observed from the original PV power which will result in more charging and discharging power.
A comparison was performed to highlight the relationship between filter time constant and the battery's SoC in Fig. 9 which concludes that the longer time constant is VOLUME 8, 2020  needed to get better smoothing performances the more charging and discharging rates.
The capability of photovoltaic power smoothing using a moving average filter has been shown in fig. 10 where a filter with a 50 min window size has been used. Fig. 11 concludes that with increasing the window size of the moving average filter a smoother pv power is obtained, however, the time difference between the dispatchable power and the original pv power is increased as the window size increases. Longer window size will lead to bad power tracking which will increase the amount of charging and discharging power as it is shown in fig. 12. The relationship between using different window sizes against the battery state of charge is shown in fig. 13. Results show that the battery is overcharged with 200 min window size compared to 50 min and 100 min window sizes. The battery capacity has been doubled from 2kwh to 4kwh to handle the large power reference which results from the long window size (200 min). Fig. 14 illustrates the smoothing performance by increasing the battery capacity when large window size is used.
Oversizing the battery is not a practical solution however it is important to highlight that increasing the window size will increase the smoothing performance however a bigger battery capacity is needed to compensate for the   large charging and discharging rate. More change of battery state of charge means more energy consumption from the battery system which contributes to a lower life of the battery.
The smoothing performance using the GF has been demonstrated in Fig.15. A good smoothing performance without fluctuations is obtained with different window sizes typically using 50,100 and 200 window sizes. The charging and discharging power of the battery is shown in Fig.16 as the battery remains in the idling mode till 200 mints and then   starts charging. The charging power is increased by increasing the window size of the filter. The battery's SoC is sown in Fig.17 which illustrates that the battery's SoC is increased with increasing the time constant as the reference power increased accordingly. The battery system is overcharged with 120 mins and 80 mins window sizes.
The result in Fig. 18 shows a smoothing of the PV power variations using a Savitzky-Golay filter with a 65 min window size. A good power tracking is obtained using the second polynomial fitting across the smoothed power curve which helps the smoothed signal to have the same characteristics of   the original PV power curve. Having a filtered power curve with the same PV power characteristics implies having lower charging and discharging power. Fig. 19 and Fig. 20 shows the relationship between increasing the degree of the polynomial fitting and battery charging and discharging power and SoC respectively. A lower power reference and a lower state of charge are resulted from using 6 th order polynomial fitting with S-G filter comparing to 4 th and 2 nd order polynomial fitting. Smaller battery's SoC VOLUME 8, 2020  means lower usage of the battery to smooth the photovoltaic power.
A comparison between using a moving average filter and using the Savitsky Golay filter has been demonstrated in Fig.21 and Fig. 22 where a 225 min window size has been used with S-G filter and 125 min window size used with moving average filter. The smoothing performance of S-G filter with 1st polynomial fitting is identical to smoothing with moving average filter as shown in Fig.21. However, the same degree of smoothing of the moving average is could be obtained with an S-G filter with longer window size which results in less battery state of charge. The polynomial fitting is helped to reduce the short-term fluctuations by applying the least-square polynomial fitting. S-G filter adds an advantage to increase the degree of smoothing while controlling battery ramp rate with the help of sitting an appropriate value for S-G filter window size and polynomial order.
The smoothing performance of S-G filter with 225 min window size and 4th polynomial fitting has been compared to using L.P. filter with 100 min as shown in Fig. 23. Bad power tracking is observed when using a low pass filter which means more power will be injected from and into the battery to smooth the PV power. Fig. 24 shows that using S-G helps to get a smoothed dispatchable power into the grid with good power tracking and low charging and discharging power   which means smoothing the PV power with less battery usage.
The smoothing performance using S-G filter with second and 3 rd polynomial order has been evaluated against using GF smoothing as shown in Fig.25. A 125 mins window size is used with both smoothing methods. Simulated results show that a good smoothing performance could be obtained using both methods with a slight difference between the two filtering techniques. However, using S-G filter yields less charging and discharging power from and to the battery system using 3 rd polynomial order comparing to the S-G   with 2 nd polynomial fitting and GF smoothing which given in Fig.26.
Furthermore, employing the S-G filter with the 3 rd polynomial fitting results with less battery state of charge comparing to GF and the 2 nd polynomial order as highlighted in Fig.27. Results indicate that the same degree of smoothing can be obtained from S-G filter with less battery commitment comparing to GF filtering.
The simulated result in Fig.28 shows the influence of increasing the polynomial order of S.G filter in reducing the injected power ramp rate typically using (25 window size)   with second and 6th degree of the polynomial order. The ramp rate is decreased significantly by increasing the polynomial order with an S-G filter. In Fig.29 a comparison has been performed to highlight the effect of using S-G in decreasing the ramp rate comparing to using the MA filter. A 45 mins window size has been used with both methods where a 2nd polynomial order is used with S-G filter. Using S-G results with less ramp rate comparing to the MA filter. Furthermore, Fig. 30 shows the performance of GF filtering in ramp rate reduction has been evaluated against using an S-G filter. VOLUME 8, 2020 The performance of both methods is good, however, S-G shows better performance is reducing the solar ramp rate.

VII. CONCLUSION
The intermittent nature of renewable energy resources poses a variety of challenges of power quality such as voltage and frequency deviations. The integration of energy storage systems is one of the potential solutions to smooth out the variations of uncontrollable power and consequently to reduce the ramp rate so as to facilitate the higher penetration of renewable power into electricity networks. In this research, an innovative strategy is proposed based on the Savitzky Golay filter coupled with a control technique, to smooth out the highly fluctuating solar power output and to reduce the ramp rate to an acceptable level. The proposed methodology has been compared with relevant smoothing techniques namely moving average, low pass filtering and Gaussian filtering. Simulation results conclude that applying long window size and time constant with moving average, low pass filter and gaussian filtering respectively improve the smoothing performance of the dispatched power. However, a significant delay is introduced which leads to higher unnecessary battery consumption and hence increases storage capacity and consequently the overall cost of the system. The proposed coupled Filter-Control approach (i.e., Savitsky Golay filter & Control) overcomes the mentioned problems and helps to yield the same degree of smoothing with lesser battery capacity and utilization as compared with the other similar techniques. The simulation results attest to the performance of the proposed approach.