res-wind-up 0.1.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- res_wind_up-0.1.5.dist-info/LICENSE.txt +26 -0
- res_wind_up-0.1.5.dist-info/METADATA +121 -0
- res_wind_up-0.1.5.dist-info/RECORD +46 -0
- res_wind_up-0.1.5.dist-info/WHEEL +5 -0
- res_wind_up-0.1.5.dist-info/top_level.txt +1 -0
- wind_up/__init__.py +3 -0
- wind_up/caching.py +35 -0
- wind_up/combine_results.py +151 -0
- wind_up/constants.py +45 -0
- wind_up/conversions.py +11 -0
- wind_up/detrend.py +348 -0
- wind_up/interface.py +204 -0
- wind_up/long_term.py +226 -0
- wind_up/main_analysis.py +898 -0
- wind_up/math_funcs.py +14 -0
- wind_up/models.py +446 -0
- wind_up/northing.py +188 -0
- wind_up/northing_utils.py +17 -0
- wind_up/optimize_northing.py +671 -0
- wind_up/plots/__init__.py +0 -0
- wind_up/plots/combine_results_plots.py +52 -0
- wind_up/plots/data_coverage_plots.py +143 -0
- wind_up/plots/detrend_plots.py +307 -0
- wind_up/plots/long_term_plots.py +86 -0
- wind_up/plots/misc_plots.py +210 -0
- wind_up/plots/northing_plots.py +128 -0
- wind_up/plots/optimize_northing_plots.py +71 -0
- wind_up/plots/pp_analysis_plots.py +512 -0
- wind_up/plots/reanalysis_plots.py +102 -0
- wind_up/plots/scada_funcs_plots.py +406 -0
- wind_up/plots/scada_power_curve_plots.py +89 -0
- wind_up/plots/waking_state_plots.py +45 -0
- wind_up/plots/windspeed_drift_plots.py +27 -0
- wind_up/plots/ws_est_plots.py +125 -0
- wind_up/plots/yaw_direction_plots.py +207 -0
- wind_up/pp_analysis.py +559 -0
- wind_up/reanalysis_data.py +190 -0
- wind_up/result_manager.py +17 -0
- wind_up/scada_funcs.py +522 -0
- wind_up/scada_power_curve.py +84 -0
- wind_up/smart_data.py +194 -0
- wind_up/waking_state.py +300 -0
- wind_up/wind_funcs.py +13 -0
- wind_up/windspeed_drift.py +74 -0
- wind_up/ws_est.py +163 -0
- wind_up/yaml_loader.py +27 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024, RENEWABLE ENERGY SYSTEMS LIMITED, all rights reserved.
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted
|
|
6
|
+
provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
* Redistributions of source code must retain the above copyright notice, this list of conditions
|
|
9
|
+
and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
* Redistributions in binary form must reproduce the above copyright notice, this list of
|
|
12
|
+
conditions and the following disclaimer in the documentation and/or other materials provided
|
|
13
|
+
with the distribution.
|
|
14
|
+
|
|
15
|
+
* Neither the name of the copyright holder nor the names of its contributors may be used to
|
|
16
|
+
endorse or promote products derived from this software without specific prior written permission.
|
|
17
|
+
|
|
18
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
|
19
|
+
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
20
|
+
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
|
|
21
|
+
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
22
|
+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
23
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
24
|
+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
|
25
|
+
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
26
|
+
POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: res-wind-up
|
|
3
|
+
Version: 0.1.5
|
|
4
|
+
Summary: A tool to assess yield uplift of wind turbines
|
|
5
|
+
Author-email: Alex Clerc <alex.clerc@res-group.com>
|
|
6
|
+
License: BSD 3-Clause License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2024, RENEWABLE ENERGY SYSTEMS LIMITED, all rights reserved.
|
|
9
|
+
|
|
10
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted
|
|
11
|
+
provided that the following conditions are met:
|
|
12
|
+
|
|
13
|
+
* Redistributions of source code must retain the above copyright notice, this list of conditions
|
|
14
|
+
and the following disclaimer.
|
|
15
|
+
|
|
16
|
+
* Redistributions in binary form must reproduce the above copyright notice, this list of
|
|
17
|
+
conditions and the following disclaimer in the documentation and/or other materials provided
|
|
18
|
+
with the distribution.
|
|
19
|
+
|
|
20
|
+
* Neither the name of the copyright holder nor the names of its contributors may be used to
|
|
21
|
+
endorse or promote products derived from this software without specific prior written permission.
|
|
22
|
+
|
|
23
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
|
24
|
+
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
25
|
+
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
|
|
26
|
+
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
27
|
+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
28
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
29
|
+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
|
30
|
+
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
31
|
+
POSSIBILITY OF SUCH DAMAGE.
|
|
32
|
+
|
|
33
|
+
Project-URL: Homepage, https://github.com/resgroup/wind-up
|
|
34
|
+
Classifier: Development Status :: 4 - Beta
|
|
35
|
+
Classifier: Programming Language :: Python :: 3
|
|
36
|
+
Classifier: License :: OSI Approved :: BSD License
|
|
37
|
+
Classifier: Operating System :: OS Independent
|
|
38
|
+
Requires-Python: >=3.10
|
|
39
|
+
Description-Content-Type: text/markdown
|
|
40
|
+
License-File: LICENSE.txt
|
|
41
|
+
Requires-Dist: geographiclib
|
|
42
|
+
Requires-Dist: matplotlib
|
|
43
|
+
Requires-Dist: pandas >=2.0.0
|
|
44
|
+
Requires-Dist: pyarrow
|
|
45
|
+
Requires-Dist: pydantic >=2.0.0
|
|
46
|
+
Requires-Dist: python-dotenv
|
|
47
|
+
Requires-Dist: pyyaml
|
|
48
|
+
Requires-Dist: requests
|
|
49
|
+
Requires-Dist: ruptures
|
|
50
|
+
Requires-Dist: scipy
|
|
51
|
+
Requires-Dist: seaborn
|
|
52
|
+
Requires-Dist: tabulate
|
|
53
|
+
Requires-Dist: toml
|
|
54
|
+
Requires-Dist: utm
|
|
55
|
+
Requires-Dist: tqdm
|
|
56
|
+
Provides-Extra: dev
|
|
57
|
+
Requires-Dist: pytest ; extra == 'dev'
|
|
58
|
+
Requires-Dist: coverage ; extra == 'dev'
|
|
59
|
+
Requires-Dist: poethepoet ; extra == 'dev'
|
|
60
|
+
Requires-Dist: types-pyyaml ; extra == 'dev'
|
|
61
|
+
Requires-Dist: types-tabulate ; extra == 'dev'
|
|
62
|
+
Requires-Dist: types-toml ; extra == 'dev'
|
|
63
|
+
Requires-Dist: types-requests ; extra == 'dev'
|
|
64
|
+
Requires-Dist: types-tqdm ; extra == 'dev'
|
|
65
|
+
Requires-Dist: ruff ; extra == 'dev'
|
|
66
|
+
Requires-Dist: mypy ; extra == 'dev'
|
|
67
|
+
Provides-Extra: jupyter
|
|
68
|
+
Requires-Dist: jupyterlab ; extra == 'jupyter'
|
|
69
|
+
Requires-Dist: notebook ; extra == 'jupyter'
|
|
70
|
+
Requires-Dist: ipywidgets ; extra == 'jupyter'
|
|
71
|
+
|
|
72
|
+
# wind-up
|
|
73
|
+
A tool to assess yield uplift of wind turbines
|
|
74
|
+
|
|
75
|
+
[](https://github.com/resgroup/wind-up/actions/workflows/CI.yaml)
|
|
76
|
+
[](https://www.python.org/downloads/release/python-3100/)
|
|
77
|
+
[](https://github.com/charliermarsh/ruff)
|
|
78
|
+
[](https://github.com/python/mypy)
|
|
79
|
+
[](https://github.com/nat-n/poethepoet)
|
|
80
|
+
|
|
81
|
+
## Getting Started
|
|
82
|
+
See [`examples`](examples) folder for example analysis using the wind-up package. [`smarteole_example.ipynb`](examples%2Fsmarteole_example.ipynb) is a good place to start.
|
|
83
|
+
|
|
84
|
+
The wind-up package can be installed in a virtual environment with the following commands:
|
|
85
|
+
```shell
|
|
86
|
+
# create and activate a virtual environment, if needed
|
|
87
|
+
python -m venv .venv
|
|
88
|
+
source .venv/Scripts/activate # or .venv/bin/activate on linux or ".venv/Scripts/activate" in Windows command prompt
|
|
89
|
+
# install the wind-up package in the virtual environment
|
|
90
|
+
pip install res-wind-up # alternatively clone the repo, navigate to the wind-up folder and run "pip install ."
|
|
91
|
+
```
|
|
92
|
+
Note that the package is named `wind_up` (with an underscore) in Python code. For example to print the version of the installed package use the following code snippet:
|
|
93
|
+
```python
|
|
94
|
+
import wind_up
|
|
95
|
+
print(wind_up.__version__)
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Contributing
|
|
99
|
+
To start making changes fork the repository or make a new branch from `main`. Note `main` is protected;
|
|
100
|
+
if a commit fails to push and you want to undo it try `git reset origin/main --hard`
|
|
101
|
+
|
|
102
|
+
After cloning the repository (and creating and activating the virtual environment), use the following commands to install the wind-up package in editable mode with the dev dependencies:
|
|
103
|
+
```shell
|
|
104
|
+
git clone https://github.com/resgroup/wind-up # or your fork of wind-up
|
|
105
|
+
cd wind-up
|
|
106
|
+
# create and activate a virtual environment
|
|
107
|
+
python -m venv .venv
|
|
108
|
+
source .venv/Scripts/activate # or .venv/bin/activate on linux or ".venv/Scripts/activate" in Windows command prompt
|
|
109
|
+
# install the package in editable mode with the dev dependencies
|
|
110
|
+
pip install -e .[dev] # or .[jupyter,dev] if you want jupyter dependencies as well
|
|
111
|
+
```
|
|
112
|
+
Use `poe all` to run all required pre-push commands (make sure the virtual environment is activated)
|
|
113
|
+
|
|
114
|
+
## Running tests
|
|
115
|
+
Install dev dependencies and use `poe test` to run unit tests (make sure the virtual environment is activated)
|
|
116
|
+
|
|
117
|
+
## License
|
|
118
|
+
See [`LICENSE.txt`](LICENSE.txt)
|
|
119
|
+
|
|
120
|
+
## Contact
|
|
121
|
+
Alex.Clerc@res-group.com
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
wind_up/__init__.py,sha256=FHt7YmAQu2Eh93KclR8ifJld-7zUVZasJr4BQifdU6M,78
|
|
2
|
+
wind_up/caching.py,sha256=4YEZwry4JObdK9vPrVVRzlxwsoXF90czC1BWgUACPq8,1186
|
|
3
|
+
wind_up/combine_results.py,sha256=t_EY-6fOi1w58cqzSBS0OkpWrE0y_w2e0wGln4lPXJA,6035
|
|
4
|
+
wind_up/constants.py,sha256=qneOsf2QYitrp2HiUSvzBrk1Vwy98Ue3S2sRoCqlSos,1443
|
|
5
|
+
wind_up/conversions.py,sha256=RBCrU_8WqBUwGnIEHYaJTrefaaW_dkT7H7n5YnCF1iQ,230
|
|
6
|
+
wind_up/detrend.py,sha256=zZESO9rCVW5YiGjPZvBoQ4Ne4gQ-sDbEhwkionlnqVk,13306
|
|
7
|
+
wind_up/interface.py,sha256=-kkcsV4qhGfVuGM6g_6hRcREz_O30Qmzoj5L2AeDS8o,8632
|
|
8
|
+
wind_up/long_term.py,sha256=C_oc7DoqpquoH_ILR0KeqBmTXdP0bodk4TjjEl8gcZI,7943
|
|
9
|
+
wind_up/main_analysis.py,sha256=OmvPYzXhILrHxpbbJi1Xy79xlJG0N7RpgJXoie-gs7g,35985
|
|
10
|
+
wind_up/math_funcs.py,sha256=AxMgW6IdfxGtNdg0d3VUJR8nNfIcbLoECoi716WrjTQ,616
|
|
11
|
+
wind_up/models.py,sha256=5DSUtshgpI_25uF-7TR6aC8sqd3LkhIaRtEK5K_DRHw,20687
|
|
12
|
+
wind_up/northing.py,sha256=eNHZnLivEVcGRK3KPtlpTsaFfOI3NSGVXcnihfn4vfc,7173
|
|
13
|
+
wind_up/northing_utils.py,sha256=eAU6qbOoYMPJ7Qv88N25DGQeNT6ov-3uMzRlgUKmkQM,568
|
|
14
|
+
wind_up/optimize_northing.py,sha256=hP9ncyGDcJ4bm1QNdS2VoVN6MaNUvTlpvZzSpcmeNz0,24852
|
|
15
|
+
wind_up/pp_analysis.py,sha256=_82CfySIFPj2GPF_ZF1NQXbcsORxNYvhM_Aw-f5Vpv4,23149
|
|
16
|
+
wind_up/reanalysis_data.py,sha256=LMWkfjN35y5LlxG3inat0gLtSowwyeGNTG7ozbBlXj4,6907
|
|
17
|
+
wind_up/result_manager.py,sha256=S-pOYOOCgobg5roOGfzLtEy5ZYptZ-NOk-p39GvbH4Y,337
|
|
18
|
+
wind_up/scada_funcs.py,sha256=BwBP_DjNjBVi38Hkkz0swDCZ4F75_KHkqt4vCtsSe6E,20543
|
|
19
|
+
wind_up/scada_power_curve.py,sha256=0w6rsGGAUl-tih2l384Nlb6Wgzq2RXKWfK7a_TZB8G8,3497
|
|
20
|
+
wind_up/smart_data.py,sha256=CoiYH1b333al-80kv6v2k_ZCfzgF_eZAmc6HipIgYzA,8435
|
|
21
|
+
wind_up/waking_state.py,sha256=ebBXs0vdY8A1BZOTkMM0nxIXRmNBJBT-uNuIX3i1_MA,12243
|
|
22
|
+
wind_up/wind_funcs.py,sha256=Tod6_HnTVuv6MC2cKJW7xUtOVaeeEu33NlBapFowtxo,361
|
|
23
|
+
wind_up/windspeed_drift.py,sha256=zE7d8-LmcfvkTUxRgYqC1KhCWjLFcq3AA7xmi2UNOTU,3017
|
|
24
|
+
wind_up/ws_est.py,sha256=TlQuSspdwj7acvmZhRI8jkbeiuJGSHR7heDnSNTNlc4,6726
|
|
25
|
+
wind_up/yaml_loader.py,sha256=MbjAsruWVEZrUf8Ni7DMNN5_X58Dp3Z9MIoL83jD4VM,849
|
|
26
|
+
wind_up/plots/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
27
|
+
wind_up/plots/combine_results_plots.py,sha256=Z4zXnNMZ-fCOg8NBT2wXmGu4MAMdHLBfbsVikdLrQL0,1715
|
|
28
|
+
wind_up/plots/data_coverage_plots.py,sha256=U6JA5VJooYwng-fqzV2FFAcTo6B095Pr7Yr12ShtmH8,5602
|
|
29
|
+
wind_up/plots/detrend_plots.py,sha256=e18j9WUJgjTi3tdHGuhPxNcb9lNvDla0zjXd7ZT79Hw,9845
|
|
30
|
+
wind_up/plots/long_term_plots.py,sha256=z5fI5pqXogLcYmtLOhSxtTqPBTn18ST6Emnue5FPLBk,2999
|
|
31
|
+
wind_up/plots/misc_plots.py,sha256=DNCb763IuIYrfX2O-d4Z8YtKLpFyoTRP-2MWUbpzrSw,6480
|
|
32
|
+
wind_up/plots/northing_plots.py,sha256=Mex60h90hK3G7qah-z7fdqkXJveCoWFGoklTvERQyLA,4600
|
|
33
|
+
wind_up/plots/optimize_northing_plots.py,sha256=_FLZmzuNUPoaUF2avlo649f3Tue21_VoO-TcT-OYs7c,2742
|
|
34
|
+
wind_up/plots/pp_analysis_plots.py,sha256=LFKwPl9mIlq7HPyM243VNRZraBfmrEZULz5JVSfgC20,15872
|
|
35
|
+
wind_up/plots/reanalysis_plots.py,sha256=9EbTNQMPyE9-Uagc-yAi_ukMTELGj-4Kh-foHsXfBhI,3685
|
|
36
|
+
wind_up/plots/scada_funcs_plots.py,sha256=7PFDDd84rYzXnLqt0Fure9_FRtSyBfjknppuRuunctY,15759
|
|
37
|
+
wind_up/plots/scada_power_curve_plots.py,sha256=1YF-jKPe4mUOH4o7_S3XIy-sSvfZVabfOO4hZ9t3L6I,3283
|
|
38
|
+
wind_up/plots/waking_state_plots.py,sha256=xs-7q8lxNN41Djc5jAQ5BJuB7ifw7kl_g6UuCCEzFeM,1442
|
|
39
|
+
wind_up/plots/windspeed_drift_plots.py,sha256=ryHwtmfs3rOYxjAyZ_V4do3_wIZbjefQJUm1g2Qks78,775
|
|
40
|
+
wind_up/plots/ws_est_plots.py,sha256=yntSPCVSEMcgaC_bi0Wqdt-ZWFfa6KplqPGBDRowVaI,4063
|
|
41
|
+
wind_up/plots/yaw_direction_plots.py,sha256=BFF_6-B71kLQQazAOvh1tTdgEpqx9ESxarvt-dD9M7M,7399
|
|
42
|
+
res_wind_up-0.1.5.dist-info/LICENSE.txt,sha256=czey0_ea5L8l0GNuhpnHAox9CmWIWULUzBhaBUrQ0h8,1549
|
|
43
|
+
res_wind_up-0.1.5.dist-info/METADATA,sha256=jB4MzDnPQvUZHbCYOLhRvTUUvQVS9iSHxup0BbfN4Go,6087
|
|
44
|
+
res_wind_up-0.1.5.dist-info/WHEEL,sha256=y4mX-SOX4fYIkonsAGA5N0Oy-8_gI4FXw5HNI1xqvWg,91
|
|
45
|
+
res_wind_up-0.1.5.dist-info/top_level.txt,sha256=WXJ6arh0IlkVqkCpnk2L20gM3VfjVxr4iogAAxzB_5o,8
|
|
46
|
+
res_wind_up-0.1.5.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
wind_up
|
wind_up/__init__.py
ADDED
wind_up/caching.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import pickle
|
|
2
|
+
from collections.abc import Callable
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
import pandas as pd
|
|
7
|
+
|
|
8
|
+
from wind_up.result_manager import result_manager
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def with_parquet_cache(fp: Path, *, use_cache: bool = True) -> Callable:
|
|
12
|
+
def wrap(func: Callable[..., pd.DataFrame]) -> Callable[..., pd.DataFrame]:
|
|
13
|
+
def wrapped_f(*a: Any, **kw: Any) -> pd.DataFrame: # noqa
|
|
14
|
+
if not Path(fp).is_file() or not use_cache:
|
|
15
|
+
func(*a, **kw).to_parquet(fp)
|
|
16
|
+
return pd.read_parquet(fp)
|
|
17
|
+
|
|
18
|
+
return wrapped_f
|
|
19
|
+
|
|
20
|
+
return wrap
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def with_pickle_cache(fp: Path, *, use_cache: bool = True) -> Callable:
|
|
24
|
+
def wrap(func: Callable[..., Any]) -> Callable[..., Any]:
|
|
25
|
+
def wrapped_f(*a: Any, **kw: Any) -> Any: # noqa
|
|
26
|
+
if not Path(fp).is_file() or not use_cache or Path(fp).stat().st_size == 0:
|
|
27
|
+
with Path.open(fp, "wb") as f:
|
|
28
|
+
pickle.dump(func(*a, **kw), f)
|
|
29
|
+
with Path.open(fp, "rb") as f:
|
|
30
|
+
result_manager.warning(f"loading cached pickle {fp}")
|
|
31
|
+
return pickle.load(f)
|
|
32
|
+
|
|
33
|
+
return wrapped_f
|
|
34
|
+
|
|
35
|
+
return wrap
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import itertools
|
|
2
|
+
import logging
|
|
3
|
+
import math
|
|
4
|
+
|
|
5
|
+
import numpy as np
|
|
6
|
+
import pandas as pd
|
|
7
|
+
from scipy.stats import norm
|
|
8
|
+
|
|
9
|
+
from wind_up.models import PlotConfig
|
|
10
|
+
from wind_up.plots.combine_results_plots import plot_combine_results
|
|
11
|
+
from wind_up.result_manager import result_manager
|
|
12
|
+
|
|
13
|
+
logger = logging.getLogger(__name__)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def calc_sigma_ref(rdf: pd.DataFrame, ref_list: list[str]) -> float:
|
|
17
|
+
# calculate the weighted absolute average reference uplift as a lower bound on uncertainty
|
|
18
|
+
ref_uplifts = rdf.loc[(rdf["test_wtg"].isin(ref_list)), "p50_uplift"]
|
|
19
|
+
ref_sigmas = rdf.loc[(rdf["test_wtg"].isin(ref_list)), "sigma_test"]
|
|
20
|
+
weights = 1 / (ref_sigmas**2)
|
|
21
|
+
return (abs(ref_uplifts) * weights).sum() / weights.sum() if weights.sum() > 0 else np.nan
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def calc_tdf(trdf: pd.DataFrame, ref_list: list[str], weight_col: str = "unc_weight") -> pd.DataFrame:
|
|
25
|
+
tdf = trdf.groupby("test_wtg").agg(
|
|
26
|
+
p50_uplift=pd.NamedAgg(
|
|
27
|
+
column="uplift_frc",
|
|
28
|
+
aggfunc=lambda x: (x * trdf.loc[x.index, weight_col]).sum() / trdf.loc[x.index, weight_col].sum(),
|
|
29
|
+
),
|
|
30
|
+
sigma_uncorr=pd.NamedAgg(
|
|
31
|
+
column="unc_one_sigma_frc",
|
|
32
|
+
aggfunc=lambda x: np.sqrt(
|
|
33
|
+
((x * trdf.loc[x.index, weight_col] / trdf.loc[x.index, weight_col].sum()) ** 2).sum(),
|
|
34
|
+
),
|
|
35
|
+
),
|
|
36
|
+
sigma_corr=pd.NamedAgg(
|
|
37
|
+
column="unc_one_sigma_frc",
|
|
38
|
+
aggfunc=lambda x: (x * trdf.loc[x.index, weight_col]).sum() / trdf.loc[x.index, weight_col].sum(),
|
|
39
|
+
),
|
|
40
|
+
ref_count=pd.NamedAgg(column="uplift_frc", aggfunc=len),
|
|
41
|
+
is_ref=pd.NamedAgg(column="test_wtg", aggfunc=lambda x: x.isin(ref_list).any()),
|
|
42
|
+
)
|
|
43
|
+
tdf["sigma_test"] = (tdf["sigma_uncorr"] + tdf["sigma_corr"]) / 2
|
|
44
|
+
tdf = tdf.sort_values(by=["ref_count", "test_wtg"], ascending=[False, True])
|
|
45
|
+
tdf = tdf.reset_index()
|
|
46
|
+
sigma_ref = calc_sigma_ref(tdf, ref_list)
|
|
47
|
+
tdf["sigma"] = tdf["sigma_test"].clip(lower=sigma_ref)
|
|
48
|
+
tdf["p95_uplift"] = tdf["p50_uplift"] + norm.ppf(0.05) * tdf["sigma"]
|
|
49
|
+
tdf["p5_uplift"] = tdf["p50_uplift"] + norm.ppf(0.95) * tdf["sigma"]
|
|
50
|
+
return tdf
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def choose_best_refs(trdf: pd.DataFrame, ref_list: list[str], min_refs: int = 3) -> list[str]:
|
|
54
|
+
ref_count = len(ref_list)
|
|
55
|
+
if ref_count < min_refs:
|
|
56
|
+
msg = "ref_list must have at least min_refs elements"
|
|
57
|
+
raise ValueError(msg)
|
|
58
|
+
|
|
59
|
+
rdf = calc_tdf(trdf, ref_list)
|
|
60
|
+
best_sigma_ref = calc_sigma_ref(rdf, ref_list)
|
|
61
|
+
best_ref_list = ref_list.copy()
|
|
62
|
+
ref_count -= 1
|
|
63
|
+
while ref_count >= min_refs:
|
|
64
|
+
for c in itertools.combinations(ref_list, ref_count):
|
|
65
|
+
this_ref_list = list(c)
|
|
66
|
+
this_sigma_ref = calc_sigma_ref(rdf, this_ref_list)
|
|
67
|
+
if this_sigma_ref < best_sigma_ref:
|
|
68
|
+
best_sigma_ref = this_sigma_ref
|
|
69
|
+
best_ref_list = this_ref_list.copy()
|
|
70
|
+
ref_count -= 1
|
|
71
|
+
return best_ref_list
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def combine_results(
|
|
75
|
+
trdf: pd.DataFrame,
|
|
76
|
+
*,
|
|
77
|
+
auto_choose_refs: bool = True,
|
|
78
|
+
exclude_refs: list[str] | None = None,
|
|
79
|
+
plot_config: PlotConfig | None = None,
|
|
80
|
+
) -> pd.DataFrame:
|
|
81
|
+
if exclude_refs is None:
|
|
82
|
+
exclude_refs = []
|
|
83
|
+
|
|
84
|
+
msg = "#" * 78 + "\n# combine results per test turbine\n" + "#" * 78
|
|
85
|
+
logger.info(msg)
|
|
86
|
+
|
|
87
|
+
trdf = trdf.copy()
|
|
88
|
+
|
|
89
|
+
if trdf.groupby(["test_wtg", "ref"]).size().max() > 1:
|
|
90
|
+
msg = "trdf must have no more than one row per test-ref pair"
|
|
91
|
+
raise ValueError(msg)
|
|
92
|
+
|
|
93
|
+
# remove reference predictions of themselves
|
|
94
|
+
trdf = trdf.loc[trdf["test_wtg"] != trdf["ref"], :]
|
|
95
|
+
|
|
96
|
+
if len(exclude_refs) > 0:
|
|
97
|
+
logger.info(f"excluding refs {exclude_refs}")
|
|
98
|
+
trdf = trdf.loc[~trdf["test_wtg"].isin(exclude_refs), :]
|
|
99
|
+
trdf = trdf.loc[~trdf["ref"].isin(exclude_refs), :]
|
|
100
|
+
|
|
101
|
+
if (trdf["unc_one_sigma_frc"] <= 0).any() or trdf["unc_one_sigma_frc"].isna().any():
|
|
102
|
+
msg = "unc_one_sigma_frc must be positive and non-NaN"
|
|
103
|
+
raise ValueError(msg)
|
|
104
|
+
|
|
105
|
+
weight_col = "unc_weight"
|
|
106
|
+
trdf[weight_col] = 1 / (trdf["unc_one_sigma_frc"] ** 2)
|
|
107
|
+
|
|
108
|
+
ref_list = sorted(trdf["ref"].unique())
|
|
109
|
+
|
|
110
|
+
min_refs = 3
|
|
111
|
+
if auto_choose_refs:
|
|
112
|
+
if len(ref_list) >= min_refs:
|
|
113
|
+
best_ref_list = choose_best_refs(trdf, ref_list, min_refs=min_refs)
|
|
114
|
+
refs_to_remove = [x for x in ref_list if x not in best_ref_list]
|
|
115
|
+
trdf = trdf.loc[~trdf["test_wtg"].isin(refs_to_remove), :]
|
|
116
|
+
trdf = trdf.loc[~trdf["ref"].isin(refs_to_remove), :]
|
|
117
|
+
ref_list = sorted(trdf["ref"].unique())
|
|
118
|
+
else:
|
|
119
|
+
result_manager.warning(f"len(ref_list) < {min_refs}, skipping auto_choose_refs")
|
|
120
|
+
|
|
121
|
+
logger.info(f"ref_list = {ref_list}")
|
|
122
|
+
tdf = calc_tdf(trdf, ref_list, weight_col)
|
|
123
|
+
|
|
124
|
+
# change column order for readability
|
|
125
|
+
cols = list(tdf.columns)
|
|
126
|
+
first_cols = ["test_wtg", "p50_uplift", "p95_uplift", "p5_uplift", "sigma"]
|
|
127
|
+
cols = first_cols + [x for x in cols if x not in first_cols]
|
|
128
|
+
tdf = tdf[cols]
|
|
129
|
+
|
|
130
|
+
if plot_config is not None:
|
|
131
|
+
plot_combine_results(trdf=trdf, tdf=tdf, plot_cfg=plot_config)
|
|
132
|
+
|
|
133
|
+
return tdf
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def calc_net_uplift(results_per_test_df: pd.DataFrame, *, confidence: float) -> tuple[float, float, float]:
|
|
137
|
+
if results_per_test_df.groupby("test_wtg").size().max() > 1:
|
|
138
|
+
msg = "results_per_test_df must have only one row per test turbine"
|
|
139
|
+
raise ValueError(msg)
|
|
140
|
+
net_p50 = (results_per_test_df["uplift_frc"] * results_per_test_df["mean_power_pre"]).sum() / results_per_test_df[
|
|
141
|
+
"mean_power_pre"
|
|
142
|
+
].sum()
|
|
143
|
+
net_unc = (
|
|
144
|
+
math.sqrt(((results_per_test_df["unc_one_sigma_frc"] * results_per_test_df["mean_power_pre"]) ** 2).sum())
|
|
145
|
+
/ results_per_test_df["mean_power_pre"].sum()
|
|
146
|
+
)
|
|
147
|
+
p_low = (1 - confidence) / 2
|
|
148
|
+
net_p_low = net_p50 + norm.ppf(p_low) * net_unc
|
|
149
|
+
p_high = 1 - p_low
|
|
150
|
+
net_p_high = net_p50 + norm.ppf(p_high) * net_unc
|
|
151
|
+
return net_p50, net_p_low, net_p_high
|
wind_up/constants.py
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
PROJECTROOT_DIR = Path(__file__).parents[1]
|
|
4
|
+
CONFIG_DIR = Path(__file__).parents[1] / "config"
|
|
5
|
+
TURBINE_DATA_DIR = Path(__file__).parents[1] / "input_data/turbine_data"
|
|
6
|
+
REANALYSIS_DIR = Path(__file__).parents[1] / "input_data/reanalysis"
|
|
7
|
+
TOGGLE_DIR = Path(__file__).parents[1] / "input_data/toggle"
|
|
8
|
+
OUTPUT_DIR = Path(__file__).parents[1] / "output"
|
|
9
|
+
|
|
10
|
+
RANDOM_SEED = 0
|
|
11
|
+
SCATTER_S = 1
|
|
12
|
+
SCATTER_ALPHA = 0.2
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class DataColumns:
|
|
16
|
+
turbine_name = "TurbineName"
|
|
17
|
+
active_power_mean = "ActivePowerMean"
|
|
18
|
+
active_power_sd = "ActivePowerSD"
|
|
19
|
+
wind_speed_mean = "WindSpeedMean"
|
|
20
|
+
wind_speed_sd = "WindSpeedSD"
|
|
21
|
+
yaw_angle_mean = "YawAngleMean"
|
|
22
|
+
yaw_angle_min = "YawAngleMin"
|
|
23
|
+
yaw_angle_max = "YawAngleMax"
|
|
24
|
+
pitch_angle_mean = "PitchAngleMean"
|
|
25
|
+
gen_rpm_mean = "GenRpmMean"
|
|
26
|
+
ambient_temp = "AmbientTemp"
|
|
27
|
+
shutdown_duration = "ShutdownDuration"
|
|
28
|
+
|
|
29
|
+
@classmethod
|
|
30
|
+
def all(cls: type["DataColumns"]) -> list[str]:
|
|
31
|
+
return [v for k, v in vars(cls).items() if not k.startswith("_") and k != "all"]
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
HOURS_PER_YEAR = 8766
|
|
35
|
+
DEFAULT_AIR_DENSITY = 1.22
|
|
36
|
+
|
|
37
|
+
TIMESTAMP_COL = "TimeStamp_StartFormat"
|
|
38
|
+
RAW_WINDSPEED_COL = "raw_WindSpeedMean"
|
|
39
|
+
RAW_POWER_COL = "raw_ActivePowerMean"
|
|
40
|
+
RAW_DOWNTIME_S_COL = "raw_ShutdownDuration"
|
|
41
|
+
RAW_YAWDIR_COL = "raw_YawAngleMean"
|
|
42
|
+
|
|
43
|
+
REANALYSIS_WS_COL = "reanalysis_ws"
|
|
44
|
+
REANALYSIS_WD_COL = "reanalysis_wd"
|
|
45
|
+
WINDFARM_YAWDIR_COL = "wf_yawdir"
|