Skip to content

Add Data from wind-turbine-models.com #120

Description

@maurerle

Hello everybody,

I wrote a small script to parse the data from wind-turbine-models.com.
As the Turbine-data already contains records from wind-turbine-models.com (https://github.com/wind-python/windpowerlib/blob/master/windpowerlib/oedb/turbine_data.csv) I hope that the legal issues discussed in OpenEnergyPlatform/data-preprocessing#28 (comment) are cleared and the data can be used.

It would be very good if the power curves could be additionally integrated into the OEP-Database.

The below code is available under the MIT License and free for anyone to use:

from bs4 import BeautifulSoup # parse html
import requests
import json5 # parse js-dict to python
import json
import pandas as pd
from tqdm import tqdm # fancy for loop

# create list of turbines with available powercurves
page = requests.get('https://www.wind-turbine-models.com/powercurves')
soup = BeautifulSoup(page.text, 'html.parser')
# pull all text from the div
name_list = soup.find(class_ ='chosen-select')

wind_turbines_with_curve = []
for i in name_list.find_all('option'):    
    wind_turbines_with_curve.append(i.get('value'))

def downloadTurbineCurve(turbine_id,start = 0, stop=25):
    url = "https://www.wind-turbine-models.com/powercurves"
    headers = dict()
    headers["Content-Type"] = "application/x-www-form-urlencoded"
    data = {'_action': 'compare', 'turbines[]': turbine_id, 'windrange[]': [start, stop]}

    resp = requests.post(url, headers=headers, data=data)
    strings = resp.json()['result']
    begin = strings.find('data:')
    end = strings.find('"}]', begin)
    relevant_js = '{'+strings[begin:end+3]+'}}'
    curve_as_dict = json5.loads(relevant_js)
    x = curve_as_dict['data']['labels']
    y = curve_as_dict['data']['datasets'][0]['data']
    label = curve_as_dict['data']['datasets'][0]['label']
    url = curve_as_dict['data']['datasets'][0]['url']
    df = pd.DataFrame(y, index=x, columns=[label])
    df.index.name = 'wind_speed'
    return df

curves = []
for turbine_id in tqdm(wind_turbines_with_curve):
    curve = downloadTurbineCurve(turbine_id)
    curves.append(curve)
c = pd.concat(curves,axis=1)
d = c[c.any(axis=1)]
    
with open('down.csv','w') as f: 
    d.to_csv(f)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions