API Reference
Wind Conditions
The WindKit API provides a set of functions to work with wind conditions, the “raw” wind speed and direction data, and wind climates in specific formats: time-series, histogram, weibull, and the WAsPs generalized wind climate and geostrophic wind climate formats.
Wind functions
|
Calculate wind speed from wind vectors. |
|
Calculate wind directions from wind vectors. |
|
Calculate wind speed and wind direction from wind vectors. |
|
Calculate wind vectors u,v from the speed and direction. |
|
Calculate the circular (minimum) distance between two directions (observed and modelled). |
|
Convert wind directions to 0-based sector indices. |
|
Interpolate wind direction to a given height. |
|
Vertically interpolate wind speed to a given height from other height levels. |
|
Calculate the rotor equivalent wind speed (REWS) from given wind speed and directions on height levels. |
Wind climate functions
|
Create empty dataset filled with met_fields |
|
Calculate the mean wind speed moment from a wind climate. |
|
Calculate the wind speed cumulative distribution function from a wind climate. |
|
Calculate the wind speed frequency greater than the mean from a wind climate. |
|
Calculate the mean wind speed from a wind climate. |
|
Calculate the power density of wind climate object |
|
Get cross predictions from a dataset |
Time Series Wind Climate (TSWC)
|
Validation function. |
|
Check that an object is valid. |
|
Create empty time series wind climate dataset. |
|
Reads a time series wind climate file into a xarray.Dataset. |
|
transforms a pandas.DataFrame into a time series wind climate xarray.Dataset. |
|
Resample wind speed and direction to a given frequency. |
Long-term correction
The long-term correction (LTC) module provides functionality for performing long-term corrections on wind time series data. It includes methods for linear regression and variance ratio methods.
|
Sectorwise MCP using Scipy's linear regression. |
|
Sectorwise MCP using variance ratio linear regression. |
Binned Wind Climate (BWC)
|
Validation function. |
|
Check that an object is valid. |
|
Create empty binned wind climate dataset. |
|
Creates binned wind climate xarray.Dataset from file. |
|
Creates object from a timeseries. |
|
Write binned wind climate to file. |
|
Combines a list of bwc's into one binned wind climate. |
|
Returns sectorwise Weibull parameters using WAsP's fitting algorithm. |
Weibull Wind Climate (WWC)
|
Validation function. |
|
Check that an object is valid. |
|
Create empty weibull wind climate dataset. |
|
Read a weibull wind climate dataset from a file. |
|
Read multiple weibull wind climate datasets from files. |
|
Write a weibull wind climate dataset to a file. |
|
Creates object from directional A's and k's. |
|
Return the all sector A & k. |
Generalized Wind Climate (GWC)
|
Validation function. |
|
Check that an object is valid. |
|
Create empty generalized wind climate dataset. |
|
Create gwc xarray.Dataset from file. |
|
Write generalized wind climate to file. |
Geostrophic Wind Climate (GeoWC)
|
Validation function. |
|
Check that an object is valid. |
Topography
Topography provides the roughness and elevation data that is used to model the wind resource. The tools in WindKit allow you to work with both raster and vector based maps, and use the powerful GDAL library behind the scenes to enable a wide variety of file formats to be used.
Landcover
|
Subclass of dictionary that provides a lookup table for landcover and roughness. |
|
Get landcover table from dataset and table name. |
|
Add a landcover table to a GeoDataFrame. |
Converts a roughness map to landcover map. |
|
|
Converts a landcover map to roughness map. |
|
Read roughness map from file. |
|
Read landcover map from file. |
|
Write landcover map to file. |
|
Write roughness map to file. |
Elevation
|
Read elevation map from file. |
|
Write elevation map to file. |
Raster maps
|
Create empty raster map data array The values in the raster map are a 2d gaussian and the boundaries are defined by output_locs. |
|
Download a raster map from DTU, the planetary computer or google earth engine. |
Vector maps
|
Create a square elevation or roughness map within the specified bounding box. |
|
Download a map from the GWA map API. |
Map conversion
|
Converts a GeoDataFrame of lines into polygons. |
|
Convert a GeoDataFrame of polygons into line segments. |
|
Snaps the geometries in a GeoDataFrame to each other within a specified tolerance. |
|
Detects dead ends in a given set of lines. |
|
Detects and handles crossing line geometries in a GeoDataFrame. |
Wind Farm
Wind Turbines
|
Validation function. |
|
Check that an object is valid. |
|
Checks that all keys in a wind turbines object are there. |
|
Creates a point dataset with required metadata from a dataframe. |
|
Creates a point dataset with required metadata from explicit arrays. |
Converts a wind turbine dataset to a geopandas dataframe. |
Wind Turbine Generators (WTG)
Windkit’s wind turbine API has routines to load both wind turbine generator power curves, and to create layouts of wind farms.
|
Validation function. |
|
Check that an object is valid. |
|
|
Estimate the regulation type of a WTG |
|
|
Read in Wind Turbine Generator (WTG) data from a file. |
|
Get power output when the inflow wind speed is ws. |
|
Get power coefficient when the inflow wind speed is ws. |
|
Get the thrust coefficient of a Wind Turbine Generator for given wind speed(s). |
Losses and Uncertainty
Windkit has support for basic loss and uncertainty calculations to obtain, for example, a p90 of AEP estimates.
|
Perform several checks to ensure that an uncertainty table DataFrame is valid. |
|
Get the wind and energy uncertainty DataFrame from the supported uncertainty tables. |
|
Calculate the total uncertainty in the DataFrame. |
|
Print a summary of the uncertainties in the DataFrame. |
|
Calculate the total uncertainty factor for a given exceedance probability or a list of probabilities. |
Spatial
The WindKit Geospatial Tools allow you to perform common GIS functions such as convert between the different Geospatial xarray structures in windkit, reproject or warp the data into common projections, and clip or mask the data based on additional data sources.
In addition to the provided tools, since WindKit stores its objects in the formats of powerful python libraries, you can also make use of additional geopandas functions for vector data, and additional xarray functions for raster data.
Throughout this documentation, the following abbreviations are used to reference different data types.
geodf - either a
geopandas.GeoDataFrame
orgeopandas.GeoSeries
xr_data - either an
xarray.DataArray
orxarray.Dataset
CRS -
pyproj.crs.CRS
Coordinate Reference System
|
Returns a pyproj.crs.CRS object from object metadata. |
|
|
|
Adds a Coordinate Reference System to a WindKit object. |
|
Check if CRS's of two WindKit objects are equal |
Bounding Box
|
WindKit Bounding Box |
Create spatial objects
|
Create a WindKit dataset given a set of locations. |
|
Create a WindKit raster dataset given a set of locations. |
|
Create a WindKit point dataset given a set of locations. |
|
Create a WindKit stacked point dataset given a set of locations. |
|
Create a WindKit cuboid dataset given a set of locations. |
Validate spatial objects
|
Check if WindKit xarray object has 'point' spatial dimension. |
Check if WindKit xarray object has 'stacked_point' dimension. |
|
|
Check if WindKit xarray object has cuboid dimensions. |
|
Check if WindKit xarray object has raster-like dimensions. |
Convert between spatial objects
|
Converts a WindKit xarray.Dataset or xarray.DataArray to 'point' structure |
|
Converts a point based object to a cuboid based object |
Converts a WindKit dataset or dataarray to a 'stacked_point' structure |
|
|
Converts a point based object to a raster based object |
|
Convert geopandas dataframe to windkit spatial structure. |
|
Convert windkit spatial structure to geopandas dataframe. |
Interpolation
|
Interpolate spatially from cuboid dataset/dataarray to another spatial dataset/dataarray |
|
Interpolate spatially from unstructured dataset/dataarray to new coordinates. |
|
Interpolate spatially from unstructured dataset/dataarray to another spatial dataset/dataarray |
Comparison
|
Checks that the spatial points are equivalent for both datasets |
|
Check if two spatial objects have the same shape. |
|
Checks if obj_a covers obj_b |
Spatial operations
|
Clip object to mask. |
|
Clip a 'raster' or 'cuboid' dataset to the bounding box of another 'raster', 'cuboid', 'stacked_point', or 'point' dataset including a margin around that dataset to ensure several points are avaiable around the clipper dataset from the clipped one. |
|
Mask WindKit object with geometric mask. |
|
Get nearest points from dataset in windkit spatial structure |
|
Reprojects WindKit object a new CRS without changing the data. |
|
Warp cuboid WindKit object to another in a new CRS using data interpolation. |
Add the west_east, south_north coordinates to a WRF xarray.Dataset output. |
|
Get the number of spatial points for a dataset or DataArray |
Plotting
WindKit Plotting allows you to execute a number of different plotting functions in order to visualize and analyze your data. Plots are largely broken into two categories; statistical and maps. Statistical plots are generally plotted using Plotly and Dash Python libraries at a single location, e.g. mast or turbine location, while maps use geopandas and xarray functions directly to show an overview of the area.
|
Plot the histogram represented in a binned wind climate. |
|
Create a "distribution" plot and matching frequency wind rose for binned wind climate. |
Wind turbine generator operational curves. |
|
|
Creates a raster map plot. |
|
Create roughness rose plot. |
Wind speed time-series plotting including wind speed and wind direction |
|
|
Plots the vertical profile of the dataArray or dataArrays introduced. |
|
Create wind rose plot. |
Helper functions for colors and colormaps. |
|
|
Plot the polygons in a map colored by a certain field, picking some reasonable defaults for the colors and legend |
Other
Tutorial data
|
Downloads and extracts tutorial data from Zenodo if not already cached. |
Weibull distribution
|
Fit weibull parameters from the first and third moments and the fraction of probability mass above the mean |
|
Fit weibull parameters from the first and third moments |
|
Fit weibull shape parameter from the sum of log of moments |
|
Calculate moment for a weibull distribution. |
|
Calculate the probability density function for a weibull distribution. |
|
Calculate the cumulative distribution function for a weibull distribution. |
Calculate the fraction of probability mass that lie above the mean wind speed for a weibull distribution |
|
|
Calculate Weibull probability. |
WAsP
|
Workspace class for interacting with WAsP workspace XML files |
|
|
|
Read .cfdres file into xarray |
Coordinates
|
Create wind sector coordinate as a data array. |
|
Create wind speed bins coordinates. |
Get reanalysis data
|
Download ERA5 data from the planetary computer. |