openclimatefix / india-forecast-app

Runs wind and PV forecasts for India and saves to database
MIT License
1 stars 4 forks source link

Remove rolling mean for PV #53

Closed dfulu closed 5 months ago

dfulu commented 5 months ago

Pull Request

Description

In production, the solar values look like they are lagged by an hour compared to actual. The rolling mean currently in the app would cause this effect.

Screenshot 2024-03-28 at 13 52 05

By example:

When the forecast is going up the rolling mean systematically decreases all the values

da = xr.DataArray(
    np.linspace(0, 11, num=12),
    coords=[
        pd.date_range(
            "2024-01-01 00:00",
            periods=12,
            freq="15T",
        )
    ],
    dims="time",
)
da
<xarray.DataArray (time: 12)>
array([ 0.,  1.,  2.,  3.,  4.,  5.,  6.,  7.,  8.,  9., 10., 11.])
Coordinates:
  * time     (time) datetime64[ns] 2024-01-01 ... 2024-01-01T02:45:00
da.rolling(time=4,  min_periods=1).mean()
array([0. , 0.5, 1. , 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5])

Also when the forecast is going down the rolling mean will systematically increase all the values.