PyWAsP tutorial 4 PyWAsP - PyWake integration
Introduction
The example works through a complete wind turbine siting operation, starting with some measured wind data and ending up with a prediction of the power yield by erecting wind turbies at a specific site. This example includes AEP calculation which consider wake losses.
pywasp note: This is a classical step-by-step example from the
WAsP
help but extended with PyWake calculations of AEP.
Next, you will set up a wind farm consisting of several wind turbines and predict the annual energy production from this farm. Finally, we’ll map the wind resource over an area.
pywake note: To install pywake make sure you are in a conda enviroment containing
pywasp
and execute following command in a terminalpip install py_wake
pywake note: To install pywake PARK plugin make sure you are in a conda enviroment containing
pywasp
andpywask
and execute following command in a terminalpip install git+https://gitlab.windenergy.dtu.dk/TOPFARM/cuttingedge/pywake/pywake_park.git
The situation
The company Friends of Wind Energy, E-Corp Ltd. has asked you to provide a prediction of the power yield from locating a wind turbine in Serra Santa Luzia area in Portugal. They propose to erect a single 1-MW wind turbine at the summit of Serra Santa Luzia hill (they have modest energy requirements).
No wind measurements have been taken at the turbine site itself, but data have been collected from a meteorological station at nearby hill.
You are equipped with:
a contour map of the area
the wind data from the met station
a simple description of the land cover in the area
a description of the power-generating characteristics of the turbine
These data are located in the data
subfolder as following files:
a digital map of elevations and roughness
SerraSantaLuzia.map
a file containing wind data
SerraSantaLuzia.omwc
a data file containing a power production curve for the turbine
Bonus_1_MW.wtg
Working with WAsP to provide a prediction
From engineering data, you know how much power will be generated by the turbine at a given wind speed. If the plan was to erect the turbine at exactly the same place where the meteorological data had been collected, then it would be a really simple task to work out how much power to expect.
However, just from looking at the map it is obvious that the proposed turbine site is completely different from the meteorological station at the airport: the properties of the meteorological station itself will affect the wind data recorded there. In addition, the properties of the turbine site will have an effect on the way that the wind behaves near the turbine. It is also unlikely that the hub height of the turbine would be the same as the height of the anemometer.
What you need is a way to take the wind climate recorded at the meteorological station, and use it to predict the wind climate at the turbine site. That is what pywasp
does.
Using pywasp
, you can analyse the recorded wind data, correcting for the recording site effects to produce a site-independent characterization of the local wind climate. This site-independent characterization of the local wind climate is called a wind atlas data set or generalised wind climate. You can also use pywasp
to apply site effects to generalised wind climate data to produce a site-specific interpretation of the local wind climate.
Providing a prediction in the Waspdale case will therefore be a two-stage process (depicted in the right image). First, the data from the meteorological station need to be analysed to produce a wind atlas (“going up” in WAsP lingo), and then the resulting generalised wind climate needs to be applied to the proposed turbine site to estimate the wind power (“going down” in WAsP lingo).
Import packages
Usually the first step when writing a python program is importing standard and external packages we will need. For this analysis we will import numpy
, pandas
, matplotlib
, xarray
, pywasp
, pywake
and PARK pywake
plugin.
numpy
is python’s main numerical array package https://www.numpy.org/pandas
is python’s main package for manipulation of tabular data https://pandas.pydata.org/matplotlib
is python’s main plotting package https://matplotlib.org/xarray
is a powerful high level package for labelled multi-dimensional arrays http://xarray.pydata.orgpywasp
docummentation is found at http://docs.wasp.dk/py_wake
docummentation is found at https://topfarm.pages.windenergy.dtu.dk/PyWake/py_wake_park
docummentation is found at https://gitlab.windenergy.dtu.dk/TOPFARM/cuttingedge/pywake/pywake_park
As you work your way through the notebook, make sure to run the python code in each cell in the order that they appear. You run the code by clicking on the cell (outlines around the cell should appear) and pressing <shift> + <enter>
on the keyboard.
notebook note: if something looks wrong, or when errors occur, it can be helpful to restart the python kernel via the kernel tab in the top
[1]:
import warnings
warnings.filterwarnings("ignore") # We will ignore warnings to avoid cluttering the notebook
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import xarray as xr
import pyproj
%load_ext autoreload
%autoreload 2
import pywasp as pw
import windkit as wk
import py_wake
from pywasp_tutorial import plot_bwc;
It is common to make a short alias of the package when importing using the import - as -
syntax. The functions and classes of imported packages must be accessed through explicitly typing the package name or alias, e.g. np.cos(3.14)
will use the cosine function from numpy
.
Observed wind climate
Now we will import our (observed) binned wind climate from the mast located at hill nearby Serra Santa Luzia hill where the turbine is going to be installed. As mentioned earlier, the binned wind climates is stored in SerraSantaLuzia.omwc
in the data
folder. It represents the observed wind climate for the period
1997-2002 at 25.3 m above ground level.
pywasp note
pywasp
includes functionality to both read and write wind climate files in many data formats, including ascii (.tab
), xml (.owc
and.omwc
), and netCDF (.nc
).
The geospatial coordinate in the file is in the World Geodetic System 1984, (EPSG:4326). We will tell pywasp
this by explicitly passing a keyword argument srs=4326
to the open_bwc
.
[2]:
bwc = wk.read_bwc('./data/SerraSantaLuzia.omwc', crs=4326)
print(bwc)
<xarray.Dataset>
Dimensions: (point: 1, sector: 12, wsbin: 32)
Coordinates:
height (point) float64 25.3
south_north (point) float64 41.74
west_east (point) float64 -8.823
crs int8 0
* wsbin (wsbin) float64 0.5 1.5 2.5 3.5 4.5 ... 28.5 29.5 30.5 31.5
wsceil (wsbin) float64 1.0 2.0 3.0 4.0 5.0 ... 29.0 30.0 31.0 32.0
wsfloor (wsbin) float64 0.0 1.0 2.0 3.0 4.0 ... 28.0 29.0 30.0 31.0
* sector (sector) float64 0.0 30.0 60.0 90.0 ... 270.0 300.0 330.0
sector_ceil (sector) float64 15.0 45.0 75.0 105.0 ... 285.0 315.0 345.0
sector_floor (sector) float64 345.0 15.0 45.0 75.0 ... 255.0 285.0 315.0
Dimensions without coordinates: point
Data variables:
wdfreq (sector, point) float64 0.05314 0.03321 ... 0.1148 0.0707
wsfreq (wsbin, sector, point) float64 0.02601 0.04219 ... 0.0 0.0
Attributes:
Conventions: CF-1.8
history: 2024-06-05T12:32:31+00:00:\twindkit==0.7.1.dev52+gc85bf...
wasp_header: SerraSantaluzia
Package name: windkit
Package version: 0.7.1.dev52+gc85bfbd
Creation date: 2024-06-05T12:32:32+00:00
Object type: Binned Wind Climate
author: Bjarke Tobias Olsen
author_email: btol@dtu.dk
institution: DTU Wind Energy
Notice that the bwc
object is of type <xarray.Dataset>
and that it contains four kinds of data:
Dimensions: core named dimensions
Coordinates: coordinate values along dimensions
Data variables: named arrays with data along 0-N named dimensions
Attributes: additional meta data attached to the dataset
xarray note the primitive datatype and dimensions of each variable are also shown, along with a small sample of the data.
wsfreq
is a four-dimensionalfloat64
(double precision) variable along dimensions(wsbin, sector, height, point)
Xarray datasets wrap numpy arrays, annotating them with human-readable dimensions and coordinates, and allowing for easy subsetting, data manipulation, and plotting of the underlying data. An xarray.Dataset
object is a collection of data variables, while each varible itself has type xarray.DataArray
.
xarray note Use the
.values
object attribute to access the underlying numpy array
Beyond the wind speed and wind direction distributions, the wind climate contains information about the height of the measurements (height
) and the geospatial location (west_east
and south_north
), which in this case hold the location information in the projected coordinates of the EPSG:4326 projection (i.e., south_north
=latitude
and west_east
=longitude
). However, as our terrain and rougness data are in the UTM Zone 29 (EPSG:32629) we will convert and update
the mast coordinates. Once the coordiantes are converted we will store them in in variables loc_x
and loc_y
for later use.
[3]:
bwc = wk.spatial.reproject(bwc, "EPSG:32629")
loc_y = bwc.south_north
loc_x = bwc.west_east
The next step is to plot the wind rose and wind speed distributions in the binned wind climate. For convinience a plotting function plot_bwc
has been implemented in pywasp_tutorial
that will do this.
notebook note: you can view the documentation for a function in jupyter notebooks by placing a
?
in front of the function, and you can get the entire function by using??
.
[4]:
wk.plot.histogram_lines(bwc)