### Install and Test Development Environment Source: https://github.com/wind-python/windpowerlib/blob/dev/README.rst Provides commands for installing the library in editable mode and running the test suite to verify code integrity. ```bash pip install -e /path/to/the/repository pytest ``` -------------------------------- ### run_example Source: https://github.com/wind-python/windpowerlib/blob/dev/doc/example.md Runs the basic example of the windpowerlib library. ```APIDOC ## GET /windpowerlib/modelchain_example/run_example ### Description Runs the basic example. ### Method GET ### Endpoint /windpowerlib/modelchain_example/run_example ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **status** (string) - Indicates the example ran successfully. #### Response Example ```json { "status": "Basic example ran successfully." } ``` ``` -------------------------------- ### initialize_wind_turbines Example Source: https://github.com/wind-python/windpowerlib/blob/dev/doc/example.md Demonstrates how to initialize three WindTurbine objects. ```APIDOC ## POST /windpowerlib/modelchain_example/initialize_wind_turbines ### Description Initializes three `WindTurbine` objects. ### Method POST ### Endpoint /windpowerlib/modelchain_example/initialize_wind_turbines ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **wind_turbines** (list of WindTurbine objects) - A list containing three initialized WindTurbine objects. #### Response Example None ``` -------------------------------- ### Install windpowerlib for development Source: https://github.com/wind-python/windpowerlib/blob/dev/doc/getting_started.md Installs the windpowerlib repository in editable mode, allowing developers to modify the source code and see changes reflected immediately. ```bash pip install -e /path/to/the/repository ``` -------------------------------- ### calculate_power_output Example Source: https://github.com/wind-python/windpowerlib/blob/dev/doc/example.md Demonstrates how to calculate power output of wind turbines using the ModelChain. ```APIDOC ## POST /windpowerlib/modelchain_example/calculate_power_output ### Description Calculates power output of wind turbines using the `ModelChain`. ### Method POST ### Endpoint /windpowerlib/modelchain_example/calculate_power_output ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **wind_turbines** (list of WindTurbine objects) - A list of wind turbine objects. - **weather_data** (DataFrame) - Weather data for power calculation. - **modelchain_params** (dict) - Parameters for the ModelChain. ### Request Example ```json { "wind_turbines": [ { "type": "WindTurbine", "name": "Turbine 1", "hub_height": 100, "rotor_diameter": 120 } ], "weather_data": { "time": ["2023-01-01 00:00:00", "2023-01-01 01:00:00"], "wind_speed": [8, 9], "temperature": [10, 11], "density": [1.2, 1.2] }, "modelchain_params": { "wind_turbine_model": "turbine_type_1", "power_curve_model": "power_curve_type_1" } } ``` ### Response #### Success Response (200) - **power_output** (Series) - Calculated power output for each turbine. #### Response Example ```json { "power_output": [1000, 1200] } ``` ``` -------------------------------- ### Initialize ModelChain with WindTurbine Source: https://github.com/wind-python/windpowerlib/blob/dev/doc/temp/windpowerlib.modelchain.ModelChain.md This example demonstrates how to instantiate a WindTurbine object and configure a ModelChain instance with custom model parameters. ```python from windpowerlib import modelchain from windpowerlib import wind_turbine enerconE126={ 'hub_height': 135, 'rotor_diameter': 127, 'turbine_type': 'E-126/4200'} e126=wind_turbine.WindTurbine(**enerconE126) modelchain_data={'density_model': 'ideal_gas'} e126_mc=modelchain.ModelChain(e126, **modelchain_data) print(e126_mc.density_model) ``` -------------------------------- ### Install from TestPyPI Source: https://github.com/wind-python/windpowerlib/wiki/How-to-release This command installs the windpowerlib package from TestPyPI, allowing you to test its functionality before the official release. It uses the `--index-url` for TestPyPI and `--extra-index-url` for the main PyPI to resolve dependencies. ```bash pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple windpowerlib ``` -------------------------------- ### get_weather_data Example Source: https://github.com/wind-python/windpowerlib/blob/dev/doc/example.md Demonstrates how to import weather data from a file using the get_weather_data function. ```APIDOC ## GET /windpowerlib/modelchain_example/get_weather_data ### Description Imports weather data from a file. ### Method GET ### Endpoint /windpowerlib/modelchain_example/get_weather_data ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **weather_data** (DataFrame) - Imported weather data. #### Response Example None ``` -------------------------------- ### GET /weather-data Source: https://github.com/wind-python/windpowerlib/blob/dev/doc/temp/example.modelchain_example.get_weather_data.md Imports weather data from a specified CSV file or downloads an example file if the local file is missing. ```APIDOC ## GET /weather-data ### Description Imports weather data from a file. The data includes wind speed, air temperature, surface roughness length, and air pressure. If the file does not exist, an example file is downloaded automatically. ### Method GET ### Endpoint /weather-data ### Parameters #### Query Parameters - **filename** (str) - Optional - Filename of the weather data file. Default: 'weather.csv'. - **datapath** (str) - Optional - Path where the weather data file is stored. ### Request Example GET /weather-data?filename=weather.csv ### Response #### Success Response (200) - **DataFrame** (pandas.DataFrame) - A MultiIndex DataFrame containing time series data for wind_speed, temperature, roughness_length, and pressure. #### Response Example { "status": "success", "data": "pandas.DataFrame object with MultiIndex columns (variable, height)" } ``` -------------------------------- ### plot_or_print Example Source: https://github.com/wind-python/windpowerlib/blob/dev/doc/example.md Demonstrates how to plot or print power output and power (coefficient) curves. ```APIDOC ## POST /windpowerlib/modelchain_example/plot_or_print ### Description Plots or prints power output and power (coefficient) curves. ### Method POST ### Endpoint /windpowerlib/modelchain_example/plot_or_print ### Parameters #### Path Parameters None #### Query Parameters - **output_type** (string) - Optional - 'plot' to generate a plot, 'print' to print data. #### Request Body - **turbine_data** (object) - Data related to the turbine, including power output and power coefficient curves. - **...** (any) - Additional parameters for plotting or printing. ### Request Example ```json { "turbine_data": { "power_output": [1000, 1200], "power_coefficient_curve": [0.4, 0.45] } } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message indicating the plot was generated or data was printed. #### Response Example ```json { "message": "Power output plot generated successfully." } ``` ``` -------------------------------- ### Build Documentation Locally Source: https://github.com/wind-python/windpowerlib/wiki/How-to-release This command builds the project's documentation locally using Sphinx. It requires Sphinx to be installed and the documentation source files to be present. The output will be generated in the specified output path. ```bash sphinx-build -b html path/to/doc/ output/path/ ``` -------------------------------- ### Initialize Wind Farm Source: https://github.com/wind-python/windpowerlib/blob/dev/example/turbine_cluster_modelchain_example.ipynb Demonstrates how to initialize a wind farm by defining its turbine fleet. The fleet can be specified using a pandas DataFrame, detailing the wind turbines, their number, or their total installed capacity. ```python # specification of wind farm data where turbine fleet is provided in a # pandas.DataFrame # for each turbine type you can either specify the number of turbines of # that type in the wind farm (float values are possible as well) or the # total installed capacity of that turbine type in W wind_turbine_fleet = pd.DataFrame( {'wind_turbine': [my_turbine, e126], # as windpowerlib.WindTurbine 'number_of_turbines': [6, None], 'total_capacity': [None, 12.6e6]} ) ``` -------------------------------- ### Setup Matplotlib for Visualization Source: https://github.com/wind-python/windpowerlib/blob/dev/doc/modelchain_example_notebook.ipynb Configures the environment to use matplotlib for plotting, including handling potential import errors and enabling inline plotting for Jupyter notebooks. ```python logging.getLogger().setLevel(logging.WARNING) try: from matplotlib import pyplot as plt %matplotlib inline except ImportError: plt = None ``` -------------------------------- ### Build Distribution Archives Source: https://github.com/wind-python/windpowerlib/wiki/How-to-release This command builds the source distribution (sdist) and wheel (bdist_wheel) archives for the windpowerlib package. These archives are necessary for uploading to package indexes like PyPI. Ensure setuptools and wheel are installed. ```bash python3 -m pip install --upgrade setuptools wheel twine ``` ```bash python3 setup.py sdist bdist_wheel ``` -------------------------------- ### Retrieve turbine data from CSV using windpowerlib Source: https://github.com/wind-python/windpowerlib/blob/dev/doc/temp/windpowerlib.wind_turbine.get_turbine_data_from_file.md This example demonstrates how to import the wind_turbine module and use get_turbine_data_from_file to load turbine data from a specified CSV path. It shows how to access specific values and calculate the maximum power from the returned DataFrame. ```python from windpowerlib import wind_turbine import os my_path = os.path.join(os.path.dirname(__file__), '../tests/data', 'power_curves.csv') d3 = get_turbine_data_from_file('DUMMY 3', my_path) print(d3['value'][7]) print(d3['value'].max()) ``` -------------------------------- ### Plot Turbine Power Output with Matplotlib Source: https://github.com/wind-python/windpowerlib/blob/dev/doc/turbine_cluster_modelchain_example_notebook.ipynb This code snippet visualizes the calculated power output for an example cluster and an example farm using matplotlib. It requires matplotlib to be installed and configured for inline plotting in notebooks. The plot displays wind speed on the x-axis and power on the y-axis. ```python logging.getLogger().setLevel(logging.WARNING) try: from matplotlib import pyplot as plt # matplotlib inline needed in notebook to plot inline %matplotlib inline except ImportError: plt = None if plt: example_cluster.power_output.plot(legend=True, label='example cluster') example_farm.power_output.plot(legend=True, label='example farm') plt.xlabel('Wind speed in m/s') plt.ylabel('Power in W') plt.show() ``` -------------------------------- ### Get Weather Data Function Source: https://github.com/wind-python/windpowerlib/blob/dev/example/turbine_cluster_modelchain_example.ipynb Defines a function to import weather data from a CSV file. It handles downloading the example data if it doesn't exist and processes it into a pandas DataFrame with appropriate indexing and timezone conversion. ```python def get_weather_data(filename='weather.csv', **kwargs): """ Imports weather data from a file. """ if 'datapath' not in kwargs: kwargs['datapath'] = os.path.dirname(__file__) file = os.path.join(kwargs['datapath'], filename) # download example weather data file in case it does not yet exist if not os.path.isfile(file): logging.debug("Download weather data for example.") req = requests.get("https://osf.io/59bqn/download") with open(file, "wb") as fout: fout.write(req.content) # read csv file weather_df = pd.read_csv( file, index_col=0, header=[0, 1], ) weather_df.index = pd.to_datetime(weather_df.index, utc=True) # change time zone weather_df.index = weather_df.index.tz_convert( 'Europe/Berlin') return weather_df # Read weather data from csv weather = get_weather_data(filename='weather.csv', datapath='') print(weather[['wind_speed', 'temperature', 'pressure']][0:3]) ``` -------------------------------- ### Initialize WindFarm with different fleet configurations Source: https://github.com/wind-python/windpowerlib/blob/dev/doc/temp/windpowerlib.wind_farm.WindFarm.md Demonstrates how to instantiate a WindFarm object using three different input methods: a pandas DataFrame, a list of WindTurbineGroup objects, and a dictionary. Each method calculates the total nominal power of the farm. ```python from windpowerlib import wind_farm from windpowerlib import WindTurbine import pandas as pd # Define turbines enerconE126 = {'hub_height': 135, 'rotor_diameter': 127, 'turbine_type': 'E-126/4200'} e126 = WindTurbine(**enerconE126) vestasV90 = {'hub_height': 90, 'turbine_type': 'V90/2000', 'nominal_power': 2e6} v90 = WindTurbine(**vestasV90) # 1. Using a pandas DataFrame wind_turbine_fleet = pd.DataFrame({'wind_turbine': [e126, v90], 'number_of_turbines': [6, None], 'total_capacity': [None, 3 * 2e6]}) example_farm = wind_farm.WindFarm(wind_turbine_fleet, name='my_farm') print(example_farm.nominal_power) # 2. Using a list of WindTurbineGroup objects wind_turbine_fleet = [e126.to_group(6), v90.to_group(total_capacity=3 * 2e6)] example_farm = wind_farm.WindFarm(wind_turbine_fleet, name='my_farm') print(example_farm.nominal_power) # 3. Using a list of dictionaries example_farm_data = {'name': 'my_farm', 'wind_turbine_fleet': [{'wind_turbine': e126, 'number_of_turbines': 6}, {'wind_turbine': v90, 'total_capacity': 3 * 2e6}]} example_farm = wind_farm.WindFarm(**example_farm_data) print(example_farm.nominal_power) ``` -------------------------------- ### Importing and Initializing WindPowerLib Environment Source: https://github.com/wind-python/windpowerlib/blob/dev/doc/turbine_cluster_modelchain_example_notebook.ipynb Sets up the necessary logging and imports for windpowerlib functionality. This is the foundational step for any wind farm or cluster simulation. ```python import os import pandas as pd import requests from windpowerlib import create_power_curve, TurbineClusterModelChain, WindFarm, WindTurbine, WindTurbineCluster import logging logging.getLogger().setLevel(logging.DEBUG) ``` -------------------------------- ### Initialize WindFarm objects Source: https://github.com/wind-python/windpowerlib/blob/dev/example/turbine_cluster_modelchain_example.ipynb Demonstrates how to instantiate a WindFarm object using a fleet of turbines. It also shows how to define a wind farm with a constant efficiency parameter. ```python example_farm = WindFarm(name='example_farm', wind_turbine_fleet=wind_turbine_fleet) example_farm_2_data = { 'name': 'example_farm_2', 'wind_turbine_fleet': [my_turbine.to_group(6), e126.to_group(total_capacity=12.6e6)], 'efficiency': 0.9} example_farm_2 = WindFarm(**example_farm_2_data) ``` -------------------------------- ### Visualize Turbine Power Output Source: https://github.com/wind-python/windpowerlib/blob/dev/example/turbine_cluster_modelchain_example.ipynb Plots the calculated power output time series for both the example cluster and example farm using matplotlib. Requires a successful import of the matplotlib library. ```python if plt: example_cluster.power_output.plot(legend=True, label='example cluster') example_farm.power_output.plot(legend=True, label='example farm') plt.xlabel('Wind speed in m/s') plt.ylabel('Power in W') plt.show() ``` -------------------------------- ### Initialize WindTurbine and Access Properties (Python) Source: https://github.com/wind-python/windpowerlib/blob/dev/doc/temp/windpowerlib.wind_turbine.WindTurbine.md Demonstrates initializing a WindTurbine object with predefined turbine data (Enercon E-126) and accessing its nominal power. It also shows initializing a turbine with custom parameters and a specified path, then accessing specific points on its power curve and its nominal power. ```python >>> import os >>> from windpowerlib import WindTurbine >>> enerconE126={ ... 'hub_height': 135, ... 'turbine_type': 'E-126/4200'} >>> e126=WindTurbine(**enerconE126) >>> print(e126.nominal_power) 4200000.0 >>> # Example with own path >>> path=os.path.join(os.path.dirname(__file__), '../tests/data') >>> example_turbine={ ... 'hub_height': 100, ... 'rotor_diameter': 70, ... 'turbine_type': 'DUMMY 3', ... 'path' : path} >>> e_t_1=WindTurbine(**example_turbine) >>> print(e_t_1.power_curve['value'][7]) 18000.0 >>> print(e_t_1.nominal_power) 1500000.0 ``` -------------------------------- ### GET /wind_farm/nominal_power Source: https://github.com/wind-python/windpowerlib/blob/dev/doc/temp/windpowerlib.wind_farm.WindFarm.md Retrieves the total nominal power of the initialized wind farm. ```APIDOC ## GET /wind_farm/nominal_power ### Description Calculates and returns the sum of the nominal power of all turbines within the specified wind farm. ### Method GET ### Endpoint /wind_farm/nominal_power ### Response #### Success Response (200) - **nominal_power** (float) - The total nominal power in Watts. #### Response Example { "nominal_power": 31200000.0 } ``` -------------------------------- ### Initializing WindTurbine Objects Source: https://github.com/wind-python/windpowerlib/blob/dev/doc/turbine_cluster_modelchain_example_notebook.ipynb Demonstrates how to create WindTurbine objects using predefined types or custom power curves. It returns a collection of turbine instances for use in farm simulations. ```python def initialize_wind_turbines(): enercon_e126 = {"turbine_type": "E-126/4200", "hub_height": 135} e126 = WindTurbine(**enercon_e126) my_turbine = {"nominal_power": 3e6, "hub_height": 105, "power_curve": pd.DataFrame({"value": [0.0, 26000.0, 180000.0, 1500000.0, 3000000.0, 3000000.0], "wind_speed": [0.0, 3.0, 5.0, 10.0, 15.0, 25.0]})} my_turbine = WindTurbine(**my_turbine) my_power = pd.Series([0.0, 39000.0, 270000.0, 2250000.0, 4500000.0, 4500000.0]) my_wind_speed = (0.0, 3.0, 5.0, 10.0, 15.0, 25.0) my_turbine2 = {"nominal_power": 6e6, "hub_height": 115, "power_curve": create_power_curve(wind_speed=my_wind_speed, power=my_power)} my_turbine2 = WindTurbine(**my_turbine2) return my_turbine, e126, my_turbine2 ``` -------------------------------- ### GET WindFarm.nominal_power Source: https://github.com/wind-python/windpowerlib/blob/dev/doc/temp/windpowerlib.wind_farm.WindFarm.nominal_power.md Retrieves the total nominal power of the wind farm instance. ```APIDOC ## GET /wind_farm/nominal_power ### Description Returns the sum of the nominal power of all turbines within the wind farm instance. ### Method GET ### Endpoint /wind_farm/nominal_power ### Parameters None ### Request Example N/A ### Response #### Success Response (200) - **nominal_power** (float) - The total nominal power of the wind farm in Watts (W). #### Response Example { "nominal_power": 1500000.0 } ``` -------------------------------- ### GET /wind-turbines Source: https://github.com/wind-python/windpowerlib/blob/dev/doc/modelchain_example_notebook.ipynb Retrieves a list of all available wind turbine types from the library. ```APIDOC ## GET /wind-turbines ### Description Retrieves a DataFrame containing all available wind turbine types, including manufacturer, turbine type, and availability of power/cp curves. ### Method GET ### Endpoint wt.get_turbine_types(print_out=False) ### Parameters #### Query Parameters - **print_out** (boolean) - Optional - If True, prints the list to console. ### Response #### Success Response (200) - **df** (DataFrame) - A pandas DataFrame containing columns: manufacturer, turbine_type, has_power_curve, has_cp_curve. ### Response Example { "manufacturer": "Enercon", "turbine_type": "E-101/3050", "has_power_curve": true, "has_cp_curve": true } ``` -------------------------------- ### Initialize a wind turbine from internal library Source: https://github.com/wind-python/windpowerlib/blob/dev/doc/getting_started.md Demonstrates how to instantiate a WindTurbine object using pre-defined turbine types and hub heights available in the library. ```python from windpowerlib import WindTurbine enercon_e126 = { "turbine_type": "E-126/4200", "hub_height": 135, } e126 = WindTurbine(**enercon_e126) ``` -------------------------------- ### ModelChain Custom Configuration and Intermediate Calculations (Python) Source: https://context7.com/wind-python/windpowerlib/llms.txt Demonstrates how to configure ModelChain with custom models for wind speed, temperature, density, and power output. It also shows how to access intermediate calculation results like wind speed and density at hub height. ```python from windpowerlib import ModelChain # Assuming 'turbine' and 'weather_df' are defined elsewhere # mc_custom = ModelChain( # turbine, # wind_speed_model="logarithmic", # or 'hellman', 'interpolation_extrapolation' # temperature_model="linear_gradient", # or 'interpolation_extrapolation' # density_model="ideal_gas", # or 'barometric', 'interpolation_extrapolation' # power_output_model="power_curve", # or 'power_coefficient_curve' # density_correction=True, # Apply density correction to power curve # obstacle_height=0, # Height of surrounding obstacles in m # hellman_exp=None, # Hellman exponent (None = auto-calculate) # ).run_model(weather_df) # Access intermediate calculations # wind_speed_at_hub = mc_custom.wind_speed_hub(weather_df) # density_at_hub = mc_custom.density_hub(weather_df) # temperature_at_hub = mc_custom.temperature_hub(weather_df) ``` -------------------------------- ### Import Libraries and Initialize Wind Turbines Source: https://github.com/wind-python/windpowerlib/blob/dev/example/turbine_cluster_modelchain_example.ipynb Imports necessary libraries from pandas, requests, and windpowerlib. It also includes logging configuration and demonstrates the initialization of various WindTurbine objects with different parameters like hub height and power curves. ```python import os import pandas as pd import requests from windpowerlib import create_power_curve, TurbineClusterModelChain, WindFarm, WindTurbine, WindTurbineCluster import logging logging.getLogger().setLevel(logging.DEBUG) ``` -------------------------------- ### Initialize WindTurbine Objects Source: https://context7.com/wind-python/windpowerlib/llms.txt Demonstrates how to instantiate a WindTurbine object using either the built-in OEDB database or custom power curve data. It also shows the use of the create_power_curve helper function for defining custom turbine specifications. ```python import pandas as pd from windpowerlib import WindTurbine, create_power_curve # Initialize from oedb turbine library enercon_e126 = WindTurbine( turbine_type="E-126/4200", hub_height=135, ) # Initialize with custom power curve data my_turbine = WindTurbine( hub_height=105, nominal_power=3e6, power_curve=pd.DataFrame({ "wind_speed": [0.0, 3.0, 5.0, 10.0, 15.0, 25.0], "value": [0.0, 26000.0, 180000.0, 1500000.0, 3000000.0, 3000000.0], }), ) # Using create_power_curve helper function wind_speeds = [0.0, 3.0, 5.0, 10.0, 15.0, 25.0] power_values = [0.0, 39000.0, 270000.0, 2250000.0, 4500000.0, 4500000.0] turbine_with_helper = WindTurbine( hub_height=115, nominal_power=6e6, power_curve=create_power_curve(wind_speed=wind_speeds, power=power_values), ) ``` -------------------------------- ### GET /get_turbine_types Source: https://github.com/wind-python/windpowerlib/blob/dev/doc/whats_new.md Retrieves a list of available turbine types from the OpenEnergy Database (oedb). ```APIDOC ## GET /get_turbine_types ### Description Fetches all turbine types currently supported and available in the OpenEnergy Database (oedb). ### Method GET ### Endpoint /get_turbine_types ### Parameters None ### Response #### Success Response (200) - **turbine_types** (list) - A list of available turbine type identifiers. #### Response Example { "turbine_types": ["E-126/4200", "Gamesa G128/4500"] } ``` -------------------------------- ### GET windpowerlib.wake_losses.get_wind_efficiency_curve Source: https://github.com/wind-python/windpowerlib/blob/dev/doc/temp/windpowerlib.wake_losses.get_wind_efficiency_curve.md Retrieves wind efficiency curves based on the provided curve name or returns all available curves. ```APIDOC ## GET windpowerlib.wake_losses.get_wind_efficiency_curve ### Description Reads wind efficiency curve(s) specified in curve_name. The function returns a pandas DataFrame containing wind speed and efficiency columns. ### Method GET ### Endpoint windpowerlib.wake_losses.get_wind_efficiency_curve(curve_name='all') ### Parameters #### Query Parameters - **curve_name** (str or list) - Optional - Specifies the curve to retrieve. Use 'all' to get all curves in a MultiIndex DataFrame or a specific curve name. Default: 'all'. ### Response #### Success Response (200) - **DataFrame** (pandas.DataFrame) - A DataFrame containing 'wind_speed' and 'efficiency' columns. If 'all' or a list is requested, returns a MultiIndex DataFrame. ### Response Example { "wind_speed": [0, 5, 10, 25], "efficiency": [0.0, 0.85, 0.92, 0.0] } ``` -------------------------------- ### Initialize Wind Turbine with Custom Data Source: https://github.com/wind-python/windpowerlib/blob/dev/README.rst Illustrates how to create a WindTurbine object using your own custom power curve data, loaded from a CSV file using pandas. ```APIDOC ## Initialize Wind Turbine with Custom Data ### Description This example demonstrates how to use your own wind turbine data, specifically a custom power curve, by loading it from a CSV file using the pandas library and then creating a `WindTurbine` object. ### Method `WindTurbine(**turbine_data)` and `create_power_curve()` ### Endpoint N/A (Python class instantiation and function call) ### Parameters #### Request Body (for `WindTurbine` constructor) - **nominal_power** (float) - Required - The nominal power of the turbine in Watts (e.g., 6e6). - **hub_height** (float) - Required - The hub height of the turbine in meters (e.g., 115). - **power_curve** (object) - Required - A power curve object created using `create_power_curve`. #### Parameters for `create_power_curve` - **wind_speed** (pandas.Series) - Required - Series of wind speeds. - **power** (pandas.Series) - Required - Series of corresponding power values. ### Request Example ```python import pandas as pd from windpowerlib import WindTurbine, create_power_curve # Assuming 'my_data.csv' contains 'wind,power' columns my_data = pd.read_csv("path/to/my/data/file.csv") my_turbine_data = { "nominal_power": 6e6, # in W "hub_height": 115, # in m "power_curve": create_power_curve( wind_speed=my_data["wind"], power=my_data["power"] ), } my_turbine = WindTurbine(**my_turbine_data) ``` ### Response - **my_turbine** (WindTurbine object) - An instance of the `WindTurbine` class configured with the custom turbine data. ``` -------------------------------- ### POST /wind_turbine_cluster/mean_hub_height Source: https://github.com/wind-python/windpowerlib/blob/dev/doc/temp/windpowerlib.wind_turbine_cluster.WindTurbineCluster.mean_hub_height.md Calculates the weighted mean hub height of a wind turbine cluster based on installed power capacity. ```APIDOC ## POST /wind_turbine_cluster/mean_hub_height ### Description Calculates the mean hub height of a wind turbine cluster. The calculation is weighted by the nominal power of the individual wind farms within the cluster. ### Method POST ### Endpoint /wind_turbine_cluster/mean_hub_height ### Parameters #### Request Body - **wind_farms** (list) - Required - A list of wind farm objects containing hub_height and nominal_power attributes. ### Request Example { "wind_farms": [ {"hub_height": 100, "nominal_power": 5000}, {"hub_height": 120, "nominal_power": 3000} ] } ### Response #### Success Response (200) - **mean_hub_height** (float) - The calculated weighted mean hub height of the cluster. #### Response Example { "mean_hub_height": 107.12 } ``` -------------------------------- ### Import windpowerlib packages and configure logging Source: https://github.com/wind-python/windpowerlib/blob/dev/example/modelchain_example.ipynb Initializes the environment by importing required libraries including pandas, requests, and windpowerlib modules. It also sets the logging level to DEBUG to monitor library operations. ```python import os import pandas as pd import requests import logging from windpowerlib import ModelChain, WindTurbine, create_power_curve from windpowerlib import data as wt logging.getLogger().setLevel(logging.DEBUG) ``` -------------------------------- ### GET /wind_turbine/data_from_file Source: https://github.com/wind-python/windpowerlib/blob/dev/doc/temp/windpowerlib.wind_turbine.get_turbine_data_from_file.md Fetches turbine data (power curve or power coefficient curve) from a specified CSV file path. ```APIDOC ## GET /wind_turbine/data_from_file ### Description Retrieves power curve or power coefficient curve data for a specific wind turbine type from a CSV file. ### Method GET ### Endpoint windpowerlib.wind_turbine.get_turbine_data_from_file(turbine_type, path) ### Parameters #### Path Parameters - **turbine_type** (str) - Required - Specifies the turbine type data is fetched for. - **path** (str) - Required - Specifies the file system path to the source CSV file. ### Request Example ```python from windpowerlib import wind_turbine import os my_path = 'path/to/power_curves.csv' data = get_turbine_data_from_file('DUMMY 3', my_path) ``` ### Response #### Success Response (200) - **data** (pandas.DataFrame or float) - Returns a DataFrame containing power/coefficient curve values or a float representing nominal power. #### Response Example ```json { "value": [18000.0, 1500000.0] } ``` ``` -------------------------------- ### Initialize WindTurbineCluster Source: https://github.com/wind-python/windpowerlib/blob/dev/example/turbine_cluster_modelchain_example.ipynb Shows how to create a WindTurbineCluster by aggregating multiple WindFarm objects into a single dictionary-based configuration. ```python example_cluster_data = { 'name': 'example_cluster', 'wind_farms': [example_farm, example_farm_2]} example_cluster = WindTurbineCluster(**example_cluster_data) ``` -------------------------------- ### GET /wind_farm/mean_hub_height Source: https://github.com/wind-python/windpowerlib/blob/dev/doc/temp/windpowerlib.wind_farm.WindFarm.mean_hub_height.md Calculates the mean hub height of a wind farm, weighted by the nominal power of individual wind turbines. ```APIDOC ## GET /wind_farm/mean_hub_height ### Description Calculates the mean hub height of a wind farm. This is necessary for power output calculations when the wind farm contains turbines with different hub heights. The calculation uses a weighted average where turbines with higher nominal power have more influence. ### Method GET ### Endpoint /wind_farm/mean_hub_height ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - None ### Request Example {} ### Response #### Success Response (200) - **self** (WindFarm) - Returns the WindFarm object with the updated hub_height attribute. #### Response Example { "status": "success", "hub_height": 120.5 } ``` -------------------------------- ### Get Turbine Types Source: https://github.com/wind-python/windpowerlib/blob/dev/doc/temp/windpowerlib.data.get_turbine_types.md Retrieves a list of available wind turbine types from specified libraries, with options to filter and print output. ```APIDOC ## GET windpowerlib.data.get_turbine_types ### Description Get all provided wind turbine types provided. Choose by turbine_library whether to get wind turbine types provided by the OpenEnergy Database (‘oedb’) or wind turbine types provided in your local file(s) (‘local’). By default only turbine types for which a power coefficient curve or power curve is provided are returned. Set filter_=False to see all turbine types for which any data (e.g. hub height, rotor diameter, …) is provided. ### Method GET ### Endpoint /windpowerlib.data.get_turbine_types ### Parameters #### Query Parameters - **turbine_library** (string) - Optional - Specifies if the oedb turbine library (‘oedb’) or your local turbine data file (‘local’) is evaluated. Default: ‘local’. - **print_out** (boolean) - Optional - Directly prints a tabular containing the turbine types in column ‘turbine_type’, the manufacturer in column ‘manufacturer’ and information about whether a power (coefficient) curve exists (True) or not (False) in columns ‘has_power_curve’ and ‘has_cp_curve’. Default: True. - **filter_** (boolean) - Optional - If True only turbine types for which a power coefficient curve or power curve is provided in the oedb turbine library are returned. Default: True. ### Response #### Success Response (200) - **DataFrame** (pandas.DataFrame) - Contains turbine types in column ‘turbine_type’, the manufacturer in column ‘manufacturer’ and information about whether a power (coefficient) curve exists (True) or not (False) in columns ‘has_power_curve’ and ‘has_cp_curve’. ### Request Example ```python from windpowerlib import get_turbine_types df=get_turbine_types(print_out=False) print(df[df["turbine_type"].str.contains("E-126")].iloc[0]) ``` ### Response Example ``` manufacturer Enercon turbine_type E-126/4200 has_power_curve True has_cp_curve True Name: 5, dtype: object ``` ``` -------------------------------- ### WindTurbine Class Initialization Source: https://context7.com/wind-python/windpowerlib/llms.txt Demonstrates how to initialize the WindTurbine class using data from the OpenEnergy Database or custom power curve data. ```APIDOC ## WindTurbine Class ### Description The `WindTurbine` class represents an individual wind turbine with attributes like hub height, rotor diameter, nominal power, and power curves. Turbine data can be loaded from the built-in oedb library by specifying a turbine type, or users can provide custom power curves directly. ### Method Initialization ### Endpoint N/A (Class Initialization) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python import pandas as pd from windpowerlib import WindTurbine, create_power_curve # Initialize from oedb turbine library enercon_e126 = WindTurbine( turbine_type="E-126/4200", # Turbine type from database hub_height=135, # Hub height in meters ) print(f"Nominal power: {enercon_e126.nominal_power} W") print(f"Rotor diameter: {enercon_e126.rotor_diameter} m") print(f"Power curve available: {enercon_e126.power_curve is not None}") # Initialize with custom power curve data my_turbine = WindTurbine( hub_height=105, nominal_power=3e6, # 3 MW in Watts power_curve=pd.DataFrame({ "wind_speed": [0.0, 3.0, 5.0, 10.0, 15.0, 25.0], # m/s "value": [0.0, 26000.0, 180000.0, 1500000.0, 3000000.0, 3000000.0], # W }), ) # Using create_power_curve helper function wind_speeds = [0.0, 3.0, 5.0, 10.0, 15.0, 25.0] power_values = [0.0, 39000.0, 270000.0, 2250000.0, 4500000.0, 4500000.0] turbine_with_helper = WindTurbine( hub_height=115, nominal_power=6e6, power_curve=create_power_curve(wind_speed=wind_speeds, power=power_values), ) ``` ### Response #### Success Response (200) Attributes of the initialized `WindTurbine` object. #### Response Example ```json { "nominal_power": 4200000.0, "rotor_diameter": 126.0, "power_curve_available": true } ``` ``` -------------------------------- ### Plot Aggregated Power Curve Source: https://github.com/wind-python/windpowerlib/blob/dev/example/turbine_cluster_modelchain_example.ipynb Visualizes the aggregated and smoothed power curve of the example cluster. It plots wind speed against power values using a star-style marker. ```python if plt: example_cluster.power_curve.plot(x='wind_speed', y='value', style='*') plt.xlabel('Wind speed in m/s') plt.ylabel('Power in W') plt.show() ``` -------------------------------- ### Configuring Wind Farm Fleet Source: https://github.com/wind-python/windpowerlib/blob/dev/doc/turbine_cluster_modelchain_example_notebook.ipynb Defines a wind farm fleet using a pandas DataFrame, specifying turbine types and either the count or total installed capacity for each type. ```python wind_turbine_fleet = pd.DataFrame({'wind_turbine': [my_turbine, e126], 'number_of_turbines': [6, None], 'total_capacity': [None, 12.6e6]}) ``` -------------------------------- ### WindFarm Class Initialization and Power Curve Assignment (Python) Source: https://context7.com/wind-python/windpowerlib/llms.txt Illustrates the creation of a WindFarm object, specifying wind turbines using the to_group() method or a DataFrame. It also shows how to assign an aggregated power curve considering wake losses and farm efficiency. ```python import pandas as pd from windpowerlib import WindTurbine, WindFarm # Create wind turbines e126 = WindTurbine(turbine_type="E-126/4200", hub_height=135) v90 = WindTurbine(turbine_type="V90/2000", hub_height=120) # Define wind farm using to_group() method (recommended) wind_farm = WindFarm( wind_turbine_fleet=[ e126.to_group(number_turbines=6), # 6 turbines of E-126 v90.to_group(total_capacity=6e6), # V90s totaling 6 MW ], efficiency=0.9, # Wind farm efficiency for wake losses (0-1) name="My Wind Farm", ) # Alternative: Define using DataFrame fleet_df = pd.DataFrame({ "wind_turbine": [e126, v90], "number_of_turbines": [6, None], "total_capacity": [None, 6e6], }) wind_farm_df = WindFarm(wind_turbine_fleet=fleet_df, efficiency=0.9) # Access farm properties print(f"Total nominal power: {wind_farm.nominal_power} W") # Calculate mean hub height and aggregated power curve wind_farm.mean_hub_height() print(f"Mean hub height: {wind_farm.hub_height} m") wind_farm.assign_power_curve( wake_losses_model="wind_farm_efficiency", # or None smoothing=False, block_width=0.5, ) print(f"Farm power curve:\n{wind_farm.power_curve}") ``` -------------------------------- ### Logarithmic Interpolation and Extrapolation for Wind Speed Source: https://github.com/wind-python/windpowerlib/blob/dev/doc/whats_new.md Provides an example of using the logarithmic_interpolation_extrapolation() function, which is a tool for handling wind speed time series, particularly for interpolation and extrapolation tasks. ```python from windpowerlib import logarithmic_interpolation_extrapolation # Example usage with wind speed data points # result = logarithmic_interpolation_extrapolation(wind_speeds, heights, target_height) ``` -------------------------------- ### Initialize Wind Turbine with Internal Data Source: https://github.com/wind-python/windpowerlib/blob/dev/README.rst Demonstrates how to initialize a WindTurbine object using pre-existing turbine data available within the windpowerlib, sourced from the OpenEnergy database. ```APIDOC ## Initialize Wind Turbine with Internal Data ### Description This example shows how to create a `WindTurbine` object using data for a specific turbine type that is available in the windpowerlib's internal dataset, which is sourced from the OpenEnergy database. ### Method `WindTurbine(**turbine_data)` ### Endpoint N/A (Python class instantiation) ### Parameters #### Request Body - **turbine_type** (string) - Required - The type of the wind turbine as registered in the database (e.g., "E-126/4200"). - **hub_height** (float) - Required - The hub height of the turbine in meters (e.g., 135). ### Request Example ```python from windpowerlib import WindTurbine enercon_e126 = { "turbine_type": "E-126/4200", # turbine type as in register "hub_height": 135, # in m } e126 = WindTurbine(**enercon_e126) ``` ### Response - **e126** (WindTurbine object) - An instance of the `WindTurbine` class configured with the specified internal turbine data. ``` -------------------------------- ### Initialize WindTurbine Object with Power Curve (Python) Source: https://github.com/wind-python/windpowerlib/blob/dev/doc/modelchain_example_notebook.ipynb Demonstrates initializing a WindTurbine object using specifications from the oedb turbine library, including turbine type and hub height. It requires the windpowerlib library. ```python from windpowerlib import WindTurbine enercon_e126 = { 'turbine_type': 'E-126/4200', # turbine type as in oedb turbine library 'hub_height': 135 # in m } # initialize WindTurbine object e126 = WindTurbine(**enercon_e126) ```