scenario_builder.storages   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 52
rs 10
c 0
b 0
f 0
wmc 1

1 Function

Rating   Name   Duplication   Size   Complexity  
A scenario_storages() 0 30 1
1
"""Create a basic scenario from the internal data structure.
2
3
SPDX-FileCopyrightText: 2016-2021 Uwe Krien <[email protected]>
4
5
SPDX-License-Identifier: MIT
6
"""
7
8
import pandas as pd
9
from reegis import storages
10
11
12
PARAMETER_RENAME = {
13
    "energy": "energy content",
14
    "energy_inflow": "energy inflow",
15
    "pump": "charge capacity",
16
    "turbine": "discharge capacity",
17
    "pump_eff": "charge efficiency",
18
    "turbine_eff": "discharge efficiency",
19
}
20
21
22
def scenario_storages(regions, year, name):
23
    """
24
    Fetch storage, pump and turbine capacity and their efficiency of
25
    hydroelectric storages for each deflex region.
26
27
    Parameters
28
    ----------
29
    regions
30
    year
31
    name
32
33
    Returns
34
    -------
35
36
    Examples
37
    --------
38
    >>> from reegis import geometries
39
    >>> fs=geometries.get_federal_states_polygon()
40
    >>> deflex_storages=scenario_storages(fs, 2012, "de17")
41
    >>> list(deflex_storages.index.get_level_values(0))
42
    ['BW', 'BY', 'HE', 'NI', 'NW', 'SH', 'SN', 'ST', 'TH']
43
    >>> int(deflex_storages.loc[("TH", "phes"), "turbine"])
44
    1522
45
    >>> int(deflex_storages.loc[("TH", "phes"), "energy"])
46
    12115
47
    """
48
    stor = storages.pumped_hydroelectric_storage_by_region(regions, year, name)
49
    stor = pd.concat([stor], keys=["phes"]).swaplevel(0, 1)
50
    stor["loss rate"] = 0
51
    return stor.rename(columns=PARAMETER_RENAME)
52