Passed
Pull Request — master (#2)
by Uwe
03:17
created

scenario_builder.storages.scenario_storages()   A

Complexity

Conditions 1

Size

Total Lines 28
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nop 3
dl 0
loc 28
rs 10
c 0
b 0
f 0
1
"""Create a basic scenario from the internal data structure.
2
3
SPDX-FileCopyrightText: 2016-2019 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
def scenario_storages(regions, year, name):
13
    """
14
    Fetch storage, pump and turbine capacity and their efficiency of
15
    hydroelectric storages for each deflex region.
16
17
    Parameters
18
    ----------
19
    regions
20
    year
21
    name
22
23
    Returns
24
    -------
25
26
    Examples
27
    --------
28
    >>> from reegis import geometries
29
    >>> fs=geometries.get_federal_states_polygon()
30
    >>> deflex_storages=scenario_storages(fs, 2012, "de17")
31
    >>> list(deflex_storages.index.get_level_values(0))
32
    ['BW', 'BY', 'HE', 'NI', 'NW', 'SH', 'SN', 'ST', 'TH']
33
    >>> int(deflex_storages.loc[("TH", "phes"), "turbine"])
34
    1522
35
    >>> int(deflex_storages.loc[("TH", "phes"), "energy"])
36
    12115
37
    """
38
    stor = storages.pumped_hydroelectric_storage_by_region(regions, year, name)
39
    return pd.concat([stor], keys=["phes"]).swaplevel(0, 1)
40