Passed
Pull Request — master (#2)
by Uwe
02:16
created

scenario_builder.storages   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 40
rs 10
c 0
b 0
f 0
wmc 1

1 Function

Rating   Name   Duplication   Size   Complexity  
A scenario_storages() 0 28 1
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
    ['DE01', 'DE03', 'DE05', 'DE06', 'DE08', 'DE09', 'DE14', 'DE15', 'DE16']
33
    >>> int(deflex_storages.loc[("DE03", "phes"), "turbine"])
34
    220
35
    >>> int(deflex_storages.loc[("DE16", "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