-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #140 from wind-python/dev
Merge into master for release 0.2.2
- Loading branch information
Showing
35 changed files
with
709 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# Tests with pytest the package and monitors the coverage and sends it to coveralls.io | ||
# Coverage is only send to coveralls.io when no pytest tests fail | ||
name: "Tests & Coverage" | ||
|
||
on: [push] | ||
|
||
# Cancel jobs on new push | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref || github.run_id }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
build: | ||
name: "${{ matrix.name-suffix }} at py${{ matrix.python-version }} on ${{ matrix.os }}" | ||
runs-on: ${{ matrix.os }} | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- name-suffix: "coverage" | ||
os: ubuntu-latest | ||
python-version: "3.11" | ||
- name-suffix: "basic" | ||
os: ubuntu-latest | ||
python-version: "3.10" | ||
- name-suffix: "basic" | ||
os: ubuntu-latest | ||
python-version: "3.12" | ||
- name-suffix: "basic" | ||
os: windows-latest | ||
python-version: "3.11" | ||
|
||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Set up Conda | ||
if: runner.os == 'Windows' | ||
uses: conda-incubator/setup-miniconda@v2 | ||
with: | ||
miniconda-version: "latest" | ||
python-version: ${{ matrix.python-version }} | ||
activate-environment: testenv | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip wheel setuptools | ||
python -m pip install .[dev] | ||
- name: Run tests | ||
if: ${{ !(runner.os == 'Linux' && matrix.python-version == 3.9 && matrix.name-suffix == 'coverage') }} | ||
run: | | ||
python -m pytest --disable-warnings --color=yes -v | ||
- name: Run tests, coverage and send to coveralls | ||
if: runner.os == 'Linux' && matrix.python-version == 3.9 && matrix.name-suffix == 'coverage' | ||
run: | | ||
coverage run --source=windpowerlib -m pytest --disable-warnings --color=yes -v | ||
coveralls | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
COVERALLS_SERVICE_NAME: github |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# .readthedocs.yml | ||
# Read the Docs configuration file | ||
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details | ||
|
||
# Required | ||
version: 2 | ||
|
||
# Build documentation in the docs/ directory with Sphinx | ||
sphinx: | ||
configuration: doc/conf.py | ||
|
||
# Build documentation with MkDocs | ||
#mkdocs: | ||
# configuration: mkdocs.yml | ||
|
||
# Optionally build your docs in additional formats such as PDF and ePub | ||
formats: all | ||
|
||
# Optionally set the version of Python and requirements required to build your docs | ||
python: | ||
install: | ||
- requirements: doc/requirements.txt | ||
|
||
# Set the version of Python | ||
build: | ||
os: ubuntu-22.04 | ||
tools: | ||
python: "3.11" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
sphinx>=1.4 | ||
sphinx_rtd_theme | ||
ipykernel | ||
nbsphinx | ||
pandas | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
v0.2.2 (February 20, 2024) | ||
++++++++++++++++++++++++++++++ | ||
|
||
* Updated the code basis to work for newer versions of python (support for python 3.6 to | ||
python 3.9 is discontinued, supported python versions are now >= python 3.9) and added | ||
github actions to run tests automatically when changes are pushed to github | ||
(`PR 136 <https://github.com/wind-python/windpowerlib/pull/136>`_). | ||
|
||
Contributors | ||
############ | ||
* Birgit Schachler | ||
* Florian Maurer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
""" | ||
The ``turbine_cluster_modelchain_example`` module shows how to calculate the | ||
power output of wind farms and wind turbine clusters with the windpowerlib. | ||
A cluster can be useful if you want to calculate the feed-in of a region for | ||
which you want to use one single weather data point. | ||
Functions that are used in the ``modelchain_example``, like the initialization | ||
of wind turbines, are imported and used without further explanations. | ||
SPDX-FileCopyrightText: 2019 oemof developer group <contact@oemof.org> | ||
SPDX-License-Identifier: MIT | ||
""" | ||
import pandas as pd | ||
import requests | ||
import os | ||
|
||
from windpowerlib import WindFarm | ||
from windpowerlib import WindTurbine | ||
from windpowerlib import TurbineClusterModelChain | ||
from windpowerlib import WindTurbineCluster | ||
|
||
# You can use the logging package to get logging messages from the windpowerlib | ||
# Change the logging level if you want more or less messages | ||
import logging | ||
|
||
logging.getLogger().setLevel(logging.INFO) | ||
|
||
|
||
def get_weather_data(filename="weather.csv", **kwargs): | ||
r""" | ||
Imports weather data from a file. | ||
The data include wind speed at two different heights in m/s, air | ||
temperature in two different heights in K, surface roughness length in m | ||
and air pressure in Pa. The height in m for which the data applies is | ||
specified in the second row. | ||
In case no weather data file exists, an example weather data file is | ||
automatically downloaded and stored in the same directory as this example. | ||
Parameters | ||
---------- | ||
filename : str | ||
Filename of the weather data file. Default: 'weather.csv'. | ||
Other Parameters | ||
---------------- | ||
datapath : str, optional | ||
Path where the weather data file is stored. | ||
Default is the same directory this example is stored in. | ||
Returns | ||
------- | ||
:pandas:`pandas.DataFrame<frame>` | ||
DataFrame with time series for wind speed `wind_speed` in m/s, | ||
temperature `temperature` in K, roughness length `roughness_length` | ||
in m, and pressure `pressure` in Pa. | ||
The columns of the DataFrame are a MultiIndex where the first level | ||
contains the variable name as string (e.g. 'wind_speed') and the | ||
second level contains the height as integer at which it applies | ||
(e.g. 10, if it was measured at a height of 10 m). The index is a | ||
DateTimeIndex. | ||
""" | ||
|
||
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 | ||
|
||
|
||
def run_example(): | ||
r""" | ||
Runs the example. | ||
""" | ||
weather = get_weather_data("weather.csv") | ||
e126 = WindTurbine( | ||
**{ | ||
"turbine_type": "E-126/4200", # turbine type as in register | ||
"hub_height": 135, # in m | ||
} | ||
) | ||
v90 = WindTurbine( | ||
**{ | ||
"turbine_type": "V90/2000", # turbine name as in register | ||
"hub_height": 120, # in m | ||
} | ||
) | ||
|
||
# specification of wind farm data (2) containing a wind farm efficiency | ||
# wind turbine fleet is provided using the to_group function | ||
example_farm = WindFarm( | ||
**{ | ||
"name": "example_farm_2", | ||
"wind_turbine_fleet": [ | ||
v90.to_group(number_turbines=6), | ||
e126.to_group(total_capacity=12.6e6), | ||
], | ||
"efficiency": 0.5 | ||
} | ||
) | ||
|
||
example_cluster = WindTurbineCluster(**{ | ||
"name": "Offshore_cluster", | ||
"wind_farms": [example_farm, example_farm], | ||
}) | ||
|
||
# ModelChain with wind farm | ||
mc_farm = TurbineClusterModelChain( | ||
example_farm, wake_losses_model=None, | ||
).run_model(weather) | ||
flh_farm = mc_farm.power_output.sum() / example_farm.nominal_power | ||
|
||
# ModelChain with wind cluster | ||
mc_cluster = TurbineClusterModelChain( | ||
example_cluster, wake_losses_model=None, | ||
).run_model(weather) | ||
flh_cluster = mc_cluster.power_output.sum() / example_cluster.nominal_power | ||
|
||
print("Full Load Hours of cluster:", flh_cluster) | ||
print("Full Load Hours of farm:", flh_farm) | ||
|
||
|
||
if __name__ == "__main__": | ||
run_example() |
Oops, something went wrong.