Coder Social home page Coder Social logo

uk-wind-modelling-basic's Introduction

uk-wind-modelling-basic

The idea is to create a simple model for predicting wind farm generation.

Wind Farm Data

Lets look at the wind generation from the Elexon API. Technically its a 1 hour forecast, but I think its good to start with. Lets look at the data from the WesterMost Rough wind farm. Its located 53°49′N 0°09′E, which is in the North Sea, just off the coast of Hull.

A good package to use is https://github.com/OSUKED/ElexonDataPortal

The expected wind generation can be generated from

from ElexonDataPortal import api
client = api.Client('your_api_key_here')

start_date = '2020-01-01'
end_date = '2020-01-02'

# data from `WesterMost Rough` wind farm
df_PHYBMDATA = client.get_PHYBMDATA(start_date=start_date, end_date=end_date, BMUnitId='T_WTMSO-1')
df_PHYBMDATA = df_PHYBMDATA[df_PHYBMDATA['recordType'] == 'PN']
df_PHYBMDATA = df_PHYBMDATA[['local_datetime','pnLevelFrom']]

*PN means Physical notification, this is how much the wind farm is expected to generate.

NWP data

Lets get some NWP (numerical weather prediction) data from the GFS. This is a global model, so we will need to extract the data for the UK.

A good package to use is Herbie - https://herbie.readthedocs.io/en/stable/

Here's an example of how to get some wind speeds

import pandas as pd
from herbie import FastHerbie

# Create a range of dates
dates = pd.date_range(
    start="2023-01-01 00:00",
    periods=4,
    freq="6H",
)

# Just get the 1 hour forecast
fxx = range(0, 1)
# Make FastHerbie Object.
FH = FastHerbie(dates, model="gfs", fxx=fxx)
# download the U V wind components at 80m
ds = FH.xarray(":(U|V)GRD:80 m")

# reduce to just the wind farm location
ds = ds.sel(latitude=slice(53, 53), longitude=slice(0, 0))

# here are the values
u = ds.u.values
v = ds.v.values
time = ds.time.values

ML

Here's the fun bit, and its very open ended.

  1. Decide on your train and test set, perhaps 1 year of each.
  2. Start with a simple model, and try to predict the wind generation
  3. Evaluate your results, and iterate.

Questions to think about:

  • What features should you use?
  • What model should you use?
  • How should you evaluate your model?
  • How much data to use?
  • Can we get more data from different wind farms?

uk-wind-modelling-basic's People

Contributors

peterdudfield avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

srennug

uk-wind-modelling-basic's Issues

error pulling wind power generation data from elexon

I keep getting the following error:
TypeError: Cannot compare tz-naive and tz-aware datetime-like objects

PHYBMDATA: 100%|██████████| 95/95 [00:38<00:00, 2.48it/s]
the data looks like it loads to completion, then it gives the error.
I've tried updating my packages etc.

code:
from ElexonDataPortal import api
client = api.Client('api key')

start_date = '2020-01-01'
end_date = '2020-01-02'

data from WesterMost Rough wind farm

df_PHYBMDATA = client.get_PHYBMDATA(start_date=start_date, end_date=end_date, BMUnitId='T_WTMSO-1')
df_PHYBMDATA = df_PHYBMDATA[df_PHYBMDATA['recordType'] == 'PN']
df_PHYBMDATA = df_PHYBMDATA[['local_datetime','pnLevelFrom']]

Retrieving wind speed data

Describe the bug

When pulling a larger time frame of wind speed data, errors occur.
It also takes a long time to retrieve the data, not sure if this can be improved

To Reproduce

Set periods > 400

Expected behaviour

This should just pull all the values for u v wind speeds from the selected time frame.

Additional context

Add any other context about the problem here.
windspeeds.txt

Power prediction

Detailed Description

The code attached predicts the power generated at the wind farm, using the trueU V wind speed at the location.

Context

I'm having trouble rescaling the power values but thought I would post this while I'm fixing it.

This is the closest I've got my predicted values and it came from using a conv layer instead of an lstm.

The data I've pulled so far is 11 months at 6H intervals. The Elexon database has no problem pulling data at shorter periods but the wind speeds give errors when setting lower periods. Extending the training data for longer than a year should help with accuracy.

Possible Implementation

I have a model that predicts the U V wind speeds which once I've improved could be used as data for the power predictions.

windspeeds_6H2021.03 copy.txt
Wind_gen copy.txt
power_predict copy.txt

Predictions with a larger data set.

Having pulled a much larger data set from the open-meteo database, I have been able to obtain hourly variables for wind speed(Kph), Wind direction, Temperature, relative humidity, and sea level pressure.

With 6 hour time steps, the lowest the RMSE got was 30. The new dataset has reduced this to 8.
image

Although this is a big improvement, it is still a significant error. The covariance matrices reveal a very strong correlation between windspeed and power produced (expected) and the very weak correlation for all the other variables in this particular dataset.

A similar prediction is made when only the windspeed is used.

I have been thinking about including more wind farms to expose the model to new weather patterns. Blade radius is one of the main factors impacting wind power generation. Do you think I should only include wind farms with the same radius in order to maintain the same relationships?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.