Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge into master for release 0.2.2 #140

Merged
merged 65 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
59835c3
Add new whatsnew file and bumb version number to 0.2.2dev
uvchik Mar 9, 2021
15d877a
Fix: Updating turbine data in getting started
thesethtruth Aug 5, 2021
7177285
update documentation in readme
maurerle Nov 12, 2021
f74c20d
Merge pull request #117 from thesethtruth/patch-1
uvchik Nov 15, 2021
5881a8f
Merge pull request #118 from maurerle/patch-1
uvchik Jul 12, 2022
f1649e4
Clean examples
uvchik Apr 12, 2023
2c5af71
Merge branch 'dev' of github.com:wind-python/windpowerlib into dev
uvchik Apr 12, 2023
1c02305
Fix import of pandas testing
birgits Jan 8, 2024
710847b
Only add curve data with unique wind speeds
birgits Jan 8, 2024
ca9e464
Series.append is deprecated, use pd.concat instead
birgits Jan 8, 2024
e963667
Fix error - float can only be applied to single element
birgits Jan 8, 2024
3ce26c7
Make sure data is sorted, sort is now per default False
birgits Jan 8, 2024
3df5e99
Change import of weather data due to deprecation of date_parser
birgits Jan 8, 2024
8792488
Fix full load hours
birgits Jan 10, 2024
4efa95c
Add github workflow for continuous testing
birgits Jan 10, 2024
32fece2
Update tested and supported python versions
birgits Jan 10, 2024
dafb8bc
Bug fix - cannot have uses and run key
birgits Jan 10, 2024
64cb2d3
Make python versions strings so that python3.10 is recognised correctly
birgits Jan 10, 2024
ea7e8a6
Fix missing conda installation
birgits Jan 10, 2024
89c23c4
Fix import of modelchain_example - previous import fails when noteboo…
birgits Jan 12, 2024
07649a9
Use pytest_notebook to test whether notebooks run without errors
birgits Jan 12, 2024
1f48299
Fix tests - tests fail on windows as dtype on one side is np.int32 an…
birgits Jan 12, 2024
a86b50f
Try fixing failing tests on windows - on windows dtype here is np.int…
birgits Jan 12, 2024
bec03ad
Try fixing different index dtype - on windows dtype is int32 and on l…
birgits Jan 12, 2024
b051746
Try fixing import error of example.modelchain_example when notebooks …
birgits Jan 12, 2024
9aec02e
Fix test for windows - on windows dtype on the left is int64 and on t…
birgits Jan 12, 2024
cac3187
Revert "Use pytest_notebook to test whether notebooks run without err…
birgits Jan 12, 2024
4dd5858
Increase timeout to avoid error when tests are run on github
birgits Jan 12, 2024
01be601
Not needed anymore as lower python versions are not supported anymore
birgits Jan 12, 2024
f26de07
Change import back as tests fail now
birgits Jan 12, 2024
5332a8e
Try setting directory to fix error for windows PermissionError: [Errn…
birgits Jan 12, 2024
f275547
Try setting permissions to fix PermissionError
birgits Jan 12, 2024
1d7055f
Comment other tests to run only windows tests
birgits Jan 12, 2024
b668b70
Change permission
birgits Jan 12, 2024
d45d448
Remove setting permissions again as it did not work correctly
birgits Jan 12, 2024
028aa8d
Try workaround - don't import functions from external python file
birgits Jan 12, 2024
4e9fd2c
Remove old imports
birgits Jan 12, 2024
edc6862
Undo commenting linux tests
birgits Jan 12, 2024
5f418bc
Use pytest-notebook again to avoid Permission denied error on windows
birgits Jan 12, 2024
8d488a9
Update documentation
birgits Jan 16, 2024
f5f3d8f
Add changes to whatsnew
birgits Jan 16, 2024
d274ce6
Remove lower limit for pandas as it is not needed anymore
birgits Jan 16, 2024
24be19d
Fixes #129 (#131)
sasanjac Jan 16, 2024
296e58e
Handle faulty turbine library data
birgits Jan 30, 2024
ec6a637
Fix a typo in the examplem plots (#126)
fwitte Jan 30, 2024
b493bd6
add default_turbine_data to pip install package_data (#133)
maurerle Jan 31, 2024
99c58d5
Merge branch 'dev' into features/fix_and_add_automatic_tests
birgits Jan 31, 2024
8a9a769
Add readthedocs.yml
birgits Feb 1, 2024
649fca0
Add sphinx_rtd_theme to rtd requirements
birgits Feb 1, 2024
285a96a
Remove asterisk
birgits Feb 1, 2024
3a6ed88
Fix failing docstring test for NaN values in "has_cp_curve"
birgits Feb 1, 2024
d57801e
Adapt test so that "oedb" is checked as well ("local" is checked in d…
birgits Feb 1, 2024
b4db824
Move extracting curve data from oedb turbine library to own function …
birgits Feb 9, 2024
5af422d
Merge pull request #136 from wind-python/features/fix_and_add_automat…
birgits Feb 9, 2024
8bd75ab
Fix links to data
birgits Feb 9, 2024
2aa2c8d
Update version number
birgits Feb 9, 2024
be0e7cb
Try fixing indentation warnings in sphinx
birgits Feb 9, 2024
e3ee59f
Fix indentation
birgits Feb 9, 2024
10f8db4
Fix typo
birgits Feb 9, 2024
15adc5a
Fix typo
birgits Feb 9, 2024
a216a45
Fix indentation
birgits Feb 9, 2024
101ed12
Fix sphinx warnings
birgits Feb 20, 2024
b837f8b
Add sphinx to dev requirements and change to alphabetical order
birgits Feb 20, 2024
d45c158
Set release date and add contributor
birgits Feb 20, 2024
8f11ea4
Merge pull request #139 from wind-python/features/make_ready_for_rele…
birgits Feb 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
68 changes: 68 additions & 0 deletions .github/workflows/tests-coverage.yml
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
28 changes: 28 additions & 0 deletions .readthedocs.yml
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"
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ language: python

matrix:
include:
- python: 3.6
- python: 3.7
- python: 3.8
- python: 3.10
- python: 3.11
- python: 3.12

# command to install dependencies
#before_install:
Expand Down
8 changes: 4 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ Go to the `download page <http://readthedocs.org/projects/windpowerlib/downloads
Installation
============

If you have a working Python 3 (>= 3.6) environment, use pypi to install the latest windpowerlib version:
If you have a working Python 3 environment, use pypi to install the latest windpowerlib version:

::

pip install windpowerlib

The windpowerlib is designed for Python 3 and tested on Python >= 3.5. We highly recommend to use virtual environments.
The windpowerlib is designed for Python 3 and tested on Python >= 3.10. We highly recommend to use virtual environments.
Please see the `installation page <http://oemof.readthedocs.io/en/stable/installation_and_setup.html>`_ of the oemof documentation for complete instructions on how to install python and a virtual environment on your operating system.

Optional Packages
Expand Down Expand Up @@ -97,8 +97,8 @@ To update your local files with the latest version of the `oedb turbine library

.. code:: python

from windpowerlib.wind_turbine import load_turbine_data_from_oedb
load_turbine_data_from_oedb()
from windpowerlib.data import store_turbine_data_from_oedb
store_turbine_data_from_oedb()

If you find your turbine in the database it is very easy to use it in the
windpowerlib
Expand Down
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@

# General information about the project.
project = u'windpowerlib'
copyright = u'2016-2021, oemof developer group'
copyright = u'2016-2023, oemof developer group'
author = u'oemof developer group'

import windpowerlib
Expand Down
14 changes: 7 additions & 7 deletions doc/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ If you have a working Python 3 environment, use pypi to install the latest windp

pip install windpowerlib

The windpowerlib is designed for Python 3 and tested on Python >= 3.5. We highly recommend to use virtual environments.
The windpowerlib is designed for Python 3 and tested on Python >= 3.10. We highly recommend to use virtual environments.
Please see the `installation page <http://oemof.readthedocs.io/en/stable/installation_and_setup.html>`_ of the oemof documentation for complete instructions on how to install python and a virtual environment on your operating system.

Optional Packages
Expand All @@ -69,9 +69,9 @@ The basic usage of the windpowerlib is shown in the ModelChain example that is a
To run the example you need the example weather and turbine data used:

* :download:`Example weather data file <../example/weather.csv>`
* :download:`Example power curve data file <../example/data/power_curves.csv>`
* :download:`Example power coefficient curve data file <../example/data/power_coefficient_curves.csv>`
* :download:`Example nominal power data file <../example/data/turbine_data.csv>`
* :download:`Example power curve data file <../windpowerlib/data/default_turbine_data/power_curves.csv>`
* :download:`Example power coefficient curve data file <../windpowerlib/data/default_turbine_data/power_coefficient_curves.csv>`
* :download:`Example nominal power data file <../windpowerlib/data/default_turbine_data/turbine_data.csv>`

Furthermore, you have to install the windpowerlib and to run the notebook you also need to install `notebook` using pip3. To launch jupyter notebook type ``jupyter notebook`` in the terminal.
This will open a browser window. Navigate to the directory containing the notebook to open it. See the jupyter notebook quick start guide for more information on `how to install <http://jupyter-notebook-beginner-guide.readthedocs.io/en/latest/install.html>`_ and
Expand Down Expand Up @@ -102,8 +102,8 @@ To update your local files with the latest version of the `oedb turbine library

.. code:: python

from windpowerlib.wind_turbine import load_turbine_data_from_oedb
load_turbine_data_from_oedb()
from windpowerlib.data import store_turbine_data_from_oedb
store_turbine_data_from_oedb()

If you find your turbine in the database it is very easy to use it in the
windpowerlib
Expand Down Expand Up @@ -223,4 +223,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
1 change: 1 addition & 0 deletions doc/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
sphinx>=1.4
sphinx_rtd_theme
ipykernel
nbsphinx
pandas
Expand Down
1 change: 1 addition & 0 deletions doc/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ These are new features and improvements of note in each release
:local:
:backlinks: top

.. include:: whatsnew/v0-2-2.rst
.. include:: whatsnew/v0-2-1.rst
.. include:: whatsnew/v0-2-0.rst
.. include:: whatsnew/v0-1-3.rst
Expand Down
12 changes: 12 additions & 0 deletions doc/whatsnew/v0-2-2.rst
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
5 changes: 3 additions & 2 deletions example/modelchain_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@
" file,\n",
" index_col=0,\n",
" header=[0, 1],\n",
" date_parser=lambda idx: pd.to_datetime(idx, utc=True))\n",
" )\n",
" weather_df.index = pd.to_datetime(weather_df.index, utc=True)\n",
" \n",
" # change time zone\n",
" weather_df.index = weather_df.index.tz_convert(\n",
Expand Down Expand Up @@ -517,7 +518,7 @@
" x='wind_speed', y='value', style='*',\n",
" title='Enercon E126 power coefficient curve')\n",
" plt.xlabel('Wind speed in m/s')\n",
" plt.ylabel('Power in W')\n",
" plt.ylabel('Power coefficient $\\mathrm{C}_\\mathrm{P}$')\n",
" plt.show()\n",
" if e126.power_curve is not None:\n",
" e126.power_curve.plot(x='wind_speed', y='value', style='*',\n",
Expand Down
4 changes: 2 additions & 2 deletions example/modelchain_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ def get_weather_data(filename="weather.csv", **kwargs):
file,
index_col=0,
header=[0, 1],
date_parser=lambda idx: pd.to_datetime(idx, utc=True),
)
weather_df.index = pd.to_datetime(weather_df.index, utc=True)

# change time zone
weather_df.index = weather_df.index.tz_convert("Europe/Berlin")
Expand Down Expand Up @@ -274,7 +274,7 @@ def plot_or_print(my_turbine, e126, my_turbine2):
title="Enercon E126 power curve",
)
plt.xlabel("Wind speed in m/s")
plt.ylabel("Power in W")
plt.ylabel("Power coefficient $\mathrm{C}_\mathrm{P}$")
plt.show()
if my_turbine.power_curve is not False:
my_turbine.power_curve.plot(
Expand Down
145 changes: 145 additions & 0 deletions example/simple_example.py
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()