eptr2 1.1.4.dev0__tar.gz → 1.2.1.dev0__tar.gz
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.
- eptr2-1.2.1.dev0/.gitignore +167 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.1.dev0}/PKG-INFO +39 -20
- {eptr2-1.1.4.dev0 → eptr2-1.2.1.dev0}/README.md +24 -2
- eptr2-1.2.1.dev0/creds/eptr_credentials.json +9 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.1.dev0}/eptr2/composite/__init__.py +1 -0
- eptr2-1.2.1.dev0/eptr2/composite/plant_costs.py +142 -0
- eptr2-1.2.1.dev0/eptr2/composite/production.py +376 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.1.dev0}/eptr2/mapping/help.py +12 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.1.dev0}/eptr2/mapping/parameters.py +1 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.1.dev0}/eptr2/mapping/path.py +7 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.1.dev0}/eptr2/mapping/processing.py +1 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.1.dev0}/eptr2/tutorials/composite/pages/1_/360/237/221/251/342/200/215/360/237/222/273_Demo.py +4 -4
- {eptr2-1.1.4.dev0 → eptr2-1.2.1.dev0}/eptr2/tutorials/composite/pages/2_/360/237/224/256_Pozisyonlar.py +1 -1
- {eptr2-1.1.4.dev0 → eptr2-1.2.1.dev0}/eptr2/tutorials/composite/pages/3_/342/232/241/357/270/217_/303/234retim_Planlama.py +1 -3
- eptr2-1.2.1.dev0/eptr2/tutorials/composite/pages/4_/360/237/222/260_Fiyat_ve_Maliyetler.py +145 -0
- eptr2-1.2.1.dev0/eptr2/tutorials/composite/pages/5_/360/237/222/270_Santral_Dengesizlik.py +514 -0
- eptr2-1.2.1.dev0/eptr2/tutorials/composite/pages/6_/360/237/221/250/342/200/215/360/237/222/273_Yeni_Dengesizlik_Hesab/304/261.py +69 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.1.dev0}/eptr2/tutorials/composite//342/255/220/357/270/217_Ana_Sayfa.py +38 -1
- {eptr2-1.1.4.dev0 → eptr2-1.2.1.dev0}/eptr2/tutorials/demo.py +4 -4
- {eptr2-1.1.4.dev0 → eptr2-1.2.1.dev0}/eptr2/util/costs.py +92 -1
- {eptr2-1.1.4.dev0 → eptr2-1.2.1.dev0}/eptr2/util/time.py +86 -9
- eptr2-1.2.1.dev0/pyproject.toml +42 -0
- eptr2-1.2.1.dev0/tests/__init__.py +5 -0
- eptr2-1.2.1.dev0/tests/composite/__init__.py +0 -0
- eptr2-1.2.1.dev0/tests/composite/test_consumption.py +32 -0
- eptr2-1.2.1.dev0/tests/composite/test_mms.py +37 -0
- eptr2-1.2.1.dev0/tests/composite/test_price_and_cost.py +57 -0
- eptr2-1.2.1.dev0/tests/composite/test_production.py +34 -0
- eptr2-1.2.1.dev0/uv.lock +1291 -0
- eptr2-1.1.4.dev0/eptr2/composite/production.py +0 -236
- eptr2-1.1.4.dev0/pyproject.toml +0 -30
- {eptr2-1.1.4.dev0 → eptr2-1.2.1.dev0}/LICENSE +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.1.dev0}/eptr2/__init__.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.1.dev0}/eptr2/composite/bpm.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.1.dev0}/eptr2/composite/consumption.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.1.dev0}/eptr2/composite/dabi_idm.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.1.dev0}/eptr2/composite/idm_log.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.1.dev0}/eptr2/composite/mms.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.1.dev0}/eptr2/composite/price_and_cost.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.1.dev0}/eptr2/main.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.1.dev0}/eptr2/mapping/__init__.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.1.dev0}/eptr2/mapping/checks.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.1.dev0}/eptr2/processing/__init__.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.1.dev0}/eptr2/processing/postprocess/__init__.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.1.dev0}/eptr2/processing/postprocess/items.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.1.dev0}/eptr2/processing/preprocess/__init__.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.1.dev0}/eptr2/processing/preprocess/calls.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.1.dev0}/eptr2/processing/preprocess/params.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.1.dev0}/eptr2/tutorials/__init__.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.1.dev0}/eptr2/tutorials/calc.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.1.dev0}/eptr2/tutorials/composite/__init__.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.1.dev0}/eptr2/tutorials/composite/common.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.1.dev0}/eptr2/tutorials/main.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.1.dev0}/eptr2/util/__init__.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.1.dev0}/eptr2/util/certificate.py +0 -0
- {eptr2-1.1.4.dev0 → eptr2-1.2.1.dev0}/eptr2/util/evaluation.py +0 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py,cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# poetry
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
102
|
+
#poetry.lock
|
|
103
|
+
|
|
104
|
+
# pdm
|
|
105
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
106
|
+
#pdm.lock
|
|
107
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
108
|
+
# in version control.
|
|
109
|
+
# https://pdm.fming.dev/#use-with-ide
|
|
110
|
+
.pdm.toml
|
|
111
|
+
|
|
112
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
113
|
+
__pypackages__/
|
|
114
|
+
|
|
115
|
+
# Celery stuff
|
|
116
|
+
celerybeat-schedule
|
|
117
|
+
celerybeat.pid
|
|
118
|
+
|
|
119
|
+
# SageMath parsed files
|
|
120
|
+
*.sage.py
|
|
121
|
+
|
|
122
|
+
# Environments
|
|
123
|
+
.env
|
|
124
|
+
.venv
|
|
125
|
+
env/
|
|
126
|
+
venv/
|
|
127
|
+
ENV/
|
|
128
|
+
env.bak/
|
|
129
|
+
venv.bak/
|
|
130
|
+
|
|
131
|
+
# Spyder project settings
|
|
132
|
+
.spyderproject
|
|
133
|
+
.spyproject
|
|
134
|
+
|
|
135
|
+
# Rope project settings
|
|
136
|
+
.ropeproject
|
|
137
|
+
|
|
138
|
+
# mkdocs documentation
|
|
139
|
+
/site
|
|
140
|
+
|
|
141
|
+
# mypy
|
|
142
|
+
.mypy_cache/
|
|
143
|
+
.dmypy.json
|
|
144
|
+
dmypy.json
|
|
145
|
+
|
|
146
|
+
# Pyre type checker
|
|
147
|
+
.pyre/
|
|
148
|
+
|
|
149
|
+
# pytype static type analyzer
|
|
150
|
+
.pytype/
|
|
151
|
+
|
|
152
|
+
# Cython debug symbols
|
|
153
|
+
cython_debug/
|
|
154
|
+
|
|
155
|
+
# PyCharm
|
|
156
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
157
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
158
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
159
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
160
|
+
#.idea/
|
|
161
|
+
|
|
162
|
+
**/.DS_Store
|
|
163
|
+
data/
|
|
164
|
+
runs/
|
|
165
|
+
.vscode/
|
|
166
|
+
helpdocs/
|
|
167
|
+
creds/.env
|
|
@@ -1,25 +1,23 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: eptr2
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.2.1.dev0
|
|
4
4
|
Summary: EPIAS Transparency Platform v2.0 Python client by Robokami Data
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Requires-Python:
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
5
|
+
Author-email: Tideseed <info@tideseed.com>
|
|
6
|
+
License: Apache License 2.0
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Requires-Python: !=3.9.7,>=3.9.6
|
|
9
|
+
Requires-Dist: pytz>=2024.1
|
|
10
|
+
Requires-Dist: urllib3==2.5.0
|
|
15
11
|
Provides-Extra: allextras
|
|
12
|
+
Requires-Dist: pandas>=2.1.3; extra == 'allextras'
|
|
13
|
+
Requires-Dist: requests>=2.32.4; extra == 'allextras'
|
|
14
|
+
Requires-Dist: streamlit>=1.48.0; extra == 'allextras'
|
|
15
|
+
Requires-Dist: tornado>=6.5.0; extra == 'allextras'
|
|
16
16
|
Provides-Extra: dataframe
|
|
17
|
-
Requires-Dist: pandas
|
|
18
|
-
|
|
19
|
-
Requires-Dist:
|
|
20
|
-
Requires-Dist:
|
|
21
|
-
Requires-Dist: tornado (>=6.5.0) ; extra == "allextras"
|
|
22
|
-
Requires-Dist: urllib3 (==2.5.0)
|
|
17
|
+
Requires-Dist: pandas>=2.1.3; extra == 'dataframe'
|
|
18
|
+
Provides-Extra: dev
|
|
19
|
+
Requires-Dist: pytest>=7.4.0; extra == 'dev'
|
|
20
|
+
Requires-Dist: python-dotenv>=0.19.1; extra == 'dev'
|
|
23
21
|
Description-Content-Type: text/markdown
|
|
24
22
|
|
|
25
23
|
 
|
|
@@ -28,6 +26,9 @@ Description-Content-Type: text/markdown
|
|
|
28
26
|
|
|
29
27
|
This document is a quickstart guide for `eptr2` package. It is a Python client for [EPIAS Transparency Platform v2.0](https://seffaflik.epias.com.tr/home) API. It is an unofficial package with Apache License 2.0.
|
|
30
28
|
|
|
29
|
+
+ For live demo, please visit <https://eptr2demo.streamlit.app/>
|
|
30
|
+
+ For local demo, you can run `eptr2demo` at terminal after installing the library.
|
|
31
|
+
|
|
31
32
|
## Installation
|
|
32
33
|
|
|
33
34
|
You can easily install it from PyPI with the following commmand.
|
|
@@ -252,10 +253,8 @@ df = get_day_ahead_and_bilateral_matches(eptr=eptr,start_date="2023-01-01", end_
|
|
|
252
253
|
df2 = get_day_ahead_detail_info(
|
|
253
254
|
eptr=eptr, start_date="2023-01-01", end_date="2023-01-31", verbose=True
|
|
254
255
|
)
|
|
255
|
-
|
|
256
256
|
```
|
|
257
257
|
|
|
258
|
-
|
|
259
258
|
#### Balancing Power Market Data
|
|
260
259
|
|
|
261
260
|
```python
|
|
@@ -275,4 +274,24 @@ df2 = get_bpm_period(
|
|
|
275
274
|
)
|
|
276
275
|
```
|
|
277
276
|
|
|
277
|
+
#### Plant Costs
|
|
278
|
+
|
|
279
|
+
```python
|
|
280
|
+
from eptr2 import EPTR2
|
|
281
|
+
from eptr2.composite import gather_and_calculate_plant_costs
|
|
278
282
|
|
|
283
|
+
eptr = EPTR2(credentials_file_path="creds/eptr_credentials.json")
|
|
284
|
+
|
|
285
|
+
df = gather_and_calculate_plant_costs(
|
|
286
|
+
eptr=eptr,
|
|
287
|
+
start_date="2023-01-01",
|
|
288
|
+
end_date="2023-01-31",
|
|
289
|
+
pp_id=120, ## BOZCAADA RES
|
|
290
|
+
org_id=195, ## EÜAŞ
|
|
291
|
+
uevcb_id=3204384, ## BOZCAADA RES
|
|
292
|
+
plant_type="wind",
|
|
293
|
+
verbose=True,
|
|
294
|
+
forecast_source = "kgup",
|
|
295
|
+
actual_source = "uevm"
|
|
296
|
+
)
|
|
297
|
+
```
|
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
This document is a quickstart guide for `eptr2` package. It is a Python client for [EPIAS Transparency Platform v2.0](https://seffaflik.epias.com.tr/home) API. It is an unofficial package with Apache License 2.0.
|
|
6
6
|
|
|
7
|
+
+ For live demo, please visit <https://eptr2demo.streamlit.app/>
|
|
8
|
+
+ For local demo, you can run `eptr2demo` at terminal after installing the library.
|
|
9
|
+
|
|
7
10
|
## Installation
|
|
8
11
|
|
|
9
12
|
You can easily install it from PyPI with the following commmand.
|
|
@@ -228,10 +231,8 @@ df = get_day_ahead_and_bilateral_matches(eptr=eptr,start_date="2023-01-01", end_
|
|
|
228
231
|
df2 = get_day_ahead_detail_info(
|
|
229
232
|
eptr=eptr, start_date="2023-01-01", end_date="2023-01-31", verbose=True
|
|
230
233
|
)
|
|
231
|
-
|
|
232
234
|
```
|
|
233
235
|
|
|
234
|
-
|
|
235
236
|
#### Balancing Power Market Data
|
|
236
237
|
|
|
237
238
|
```python
|
|
@@ -251,3 +252,24 @@ df2 = get_bpm_period(
|
|
|
251
252
|
)
|
|
252
253
|
```
|
|
253
254
|
|
|
255
|
+
#### Plant Costs
|
|
256
|
+
|
|
257
|
+
```python
|
|
258
|
+
from eptr2 import EPTR2
|
|
259
|
+
from eptr2.composite import gather_and_calculate_plant_costs
|
|
260
|
+
|
|
261
|
+
eptr = EPTR2(credentials_file_path="creds/eptr_credentials.json")
|
|
262
|
+
|
|
263
|
+
df = gather_and_calculate_plant_costs(
|
|
264
|
+
eptr=eptr,
|
|
265
|
+
start_date="2023-01-01",
|
|
266
|
+
end_date="2023-01-31",
|
|
267
|
+
pp_id=120, ## BOZCAADA RES
|
|
268
|
+
org_id=195, ## EÜAŞ
|
|
269
|
+
uevcb_id=3204384, ## BOZCAADA RES
|
|
270
|
+
plant_type="wind",
|
|
271
|
+
verbose=True,
|
|
272
|
+
forecast_source = "kgup",
|
|
273
|
+
actual_source = "uevm"
|
|
274
|
+
)
|
|
275
|
+
```
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"EPTR_USERNAME": "berk.orbay@tideseed.com",
|
|
3
|
+
"EPTR_PASSWORD": "TDSD!S3ffaf2",
|
|
4
|
+
"tgt_d": {
|
|
5
|
+
"tgt": "TGT-2550194--Z6WQIsu7keXmLbbKdIspChHBqJprLfR-dcCthsnUJGBaVO-p-XM3E0W1eNiPfjYdyM-cas-7dc76c888-gmdxk",
|
|
6
|
+
"tgt_exp": 1753043389.532092,
|
|
7
|
+
"tgt_exp_0": 1753043389.532092
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
from eptr2 import EPTR2
|
|
2
|
+
import pandas as pd
|
|
3
|
+
from eptr2.composite.production import wrapper_hourly_production_plan_and_realized
|
|
4
|
+
from eptr2.composite.price_and_cost import get_hourly_price_and_cost_data
|
|
5
|
+
from eptr2.util.costs import calculate_kupsm, get_kupst_tolerance
|
|
6
|
+
from typing import Literal
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def postprocess_plant_cost_df(df: pd.DataFrame):
|
|
10
|
+
df["cumulative_kupst_cost"] = df["total_kupst_cost"].cumsum()
|
|
11
|
+
df["cumulative_imb_cost"] = df["total_imb_cost"].cumsum()
|
|
12
|
+
df["cumulative_total_cost"] = df["total_cost"].cumsum()
|
|
13
|
+
|
|
14
|
+
d = {
|
|
15
|
+
"total_forecast": df["forecast"].sum(),
|
|
16
|
+
"total_actual": df["actual"].sum(),
|
|
17
|
+
"total_kupsm": df["kupsm"].sum(),
|
|
18
|
+
"total_bias": df["diff"].sum(),
|
|
19
|
+
"total_mae": df["diff"].abs().sum(),
|
|
20
|
+
"total_kupst_cost": df["total_kupst_cost"].sum(),
|
|
21
|
+
"total_imb_cost": df["total_imb_cost"].sum(),
|
|
22
|
+
"total_cost": df["total_cost"].sum(),
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return {"summary": d, "data": df}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def gather_and_calculate_plant_costs(
|
|
29
|
+
eptr: EPTR2,
|
|
30
|
+
start_date: str,
|
|
31
|
+
end_date: str,
|
|
32
|
+
pp_id: int | str,
|
|
33
|
+
org_id: int | str,
|
|
34
|
+
uevcb_id: int | str,
|
|
35
|
+
plant_type: str,
|
|
36
|
+
forecast_source: Literal["kgup_v1", "kgup", "kudup"] = "kudup",
|
|
37
|
+
actual_source: Literal["rt", "uevm"] = "uevm",
|
|
38
|
+
verbose=False,
|
|
39
|
+
timeout=5,
|
|
40
|
+
postprocess: bool = False,
|
|
41
|
+
**kwargs,
|
|
42
|
+
):
|
|
43
|
+
"""
|
|
44
|
+
For a given power plant and selected forecast and actual production sources, this function gathers data and calculates imbalance and kupst costs.
|
|
45
|
+
|
|
46
|
+
Example usage:
|
|
47
|
+
pp_id=120, ## BOZCAADA RES
|
|
48
|
+
org_id=195, ## EÜAŞ
|
|
49
|
+
uevcb_id=3204384, ## BOZCAADA RES
|
|
50
|
+
plant_type="wind",
|
|
51
|
+
"""
|
|
52
|
+
|
|
53
|
+
### Regulate skips
|
|
54
|
+
params = dict(
|
|
55
|
+
skip_kgup=True,
|
|
56
|
+
skip_kgup_v1=True,
|
|
57
|
+
skip_kudup=True,
|
|
58
|
+
skip_uevm=True,
|
|
59
|
+
skip_rt=True,
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
params[f"skip_{forecast_source}"] = False
|
|
63
|
+
params[f"skip_{actual_source}"] = False
|
|
64
|
+
|
|
65
|
+
### Regulate ids
|
|
66
|
+
if actual_source == "rt":
|
|
67
|
+
params["rt_pp_id"] = pp_id
|
|
68
|
+
params["uevm_pp_id"] = None
|
|
69
|
+
else:
|
|
70
|
+
params["rt_pp_id"] = None
|
|
71
|
+
params["uevm_pp_id"] = pp_id
|
|
72
|
+
|
|
73
|
+
df = wrapper_hourly_production_plan_and_realized(
|
|
74
|
+
eptr=eptr,
|
|
75
|
+
start_date=start_date,
|
|
76
|
+
end_date=end_date,
|
|
77
|
+
verbose=verbose,
|
|
78
|
+
include_contract_symbol=True,
|
|
79
|
+
org_id=org_id,
|
|
80
|
+
uevcb_id=uevcb_id,
|
|
81
|
+
timeout=timeout,
|
|
82
|
+
**params,
|
|
83
|
+
**kwargs,
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
cost_df = get_hourly_price_and_cost_data(
|
|
87
|
+
eptr=eptr,
|
|
88
|
+
start_date=start_date,
|
|
89
|
+
end_date=end_date,
|
|
90
|
+
verbose=verbose,
|
|
91
|
+
include_contract_symbol=True,
|
|
92
|
+
include_wap=False,
|
|
93
|
+
timeout=timeout,
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
#### Merge and calculate costs
|
|
97
|
+
prod_df = (
|
|
98
|
+
df[["dt", "contract", f"toplam_{forecast_source}", f"total_{actual_source}"]]
|
|
99
|
+
.rename(
|
|
100
|
+
columns={
|
|
101
|
+
f"toplam_{forecast_source}": "forecast",
|
|
102
|
+
f"total_{actual_source}": "actual",
|
|
103
|
+
}
|
|
104
|
+
)
|
|
105
|
+
.copy()
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
prod_df["diff"] = prod_df["forecast"] - prod_df["actual"]
|
|
109
|
+
|
|
110
|
+
merged_df = prod_df.merge(
|
|
111
|
+
cost_df.rename(columns={"date": "dt"})[
|
|
112
|
+
["dt", "pos_imb_cost", "neg_imb_cost", "kupst_cost"]
|
|
113
|
+
],
|
|
114
|
+
on="dt",
|
|
115
|
+
how="inner",
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
## Calculate kupsm and costs
|
|
119
|
+
kupst_tolerance = get_kupst_tolerance(plant_type)
|
|
120
|
+
merged_df["kupsm"] = merged_df.apply(
|
|
121
|
+
lambda row: calculate_kupsm(
|
|
122
|
+
actual=row["actual"], forecast=row["forecast"], tol=kupst_tolerance
|
|
123
|
+
),
|
|
124
|
+
axis=1,
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
### Calculate total costs
|
|
128
|
+
merged_df["total_kupst_cost"] = merged_df["kupsm"] * merged_df["kupst_cost"]
|
|
129
|
+
merged_df["total_imb_cost"] = merged_df.apply(
|
|
130
|
+
lambda row: (row["pos_imb_cost"] if row["diff"] < 0 else row["neg_imb_cost"])
|
|
131
|
+
* abs(row["diff"]),
|
|
132
|
+
axis=1,
|
|
133
|
+
)
|
|
134
|
+
merged_df["total_cost"] = (
|
|
135
|
+
merged_df["total_kupst_cost"] + merged_df["total_imb_cost"]
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
if postprocess:
|
|
139
|
+
d = postprocess_plant_cost_df(merged_df)
|
|
140
|
+
return d
|
|
141
|
+
|
|
142
|
+
return merged_df
|