Completed
Pull Request — master (#2)
by Uwe
03:50
created

scenario_builder.storages.scenario_storages()   A

Complexity

Conditions 1

Size

Total Lines 27
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nop 3
dl 0
loc 27
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
    >>> regions=geometries.deflex_regions(rmap="de17")
29
    >>> deflex_storages=scenario_storages(regions, 2012, "de17")
30
    >>> list(deflex_storages.index.get_level_values(0))
31
    ['DE01', 'DE03', 'DE05', 'DE06', 'DE08', 'DE09', 'DE14', 'DE15', 'DE16']
32
    >>> int(deflex_storages.loc[("DE03", "phes"), "turbine"])
33
    220
34
    >>> int(deflex_storages.loc[("DE16", "phes"), "energy"])
35
    12115
36
    """
37
    stor = storages.pumped_hydroelectric_storage_by_region(regions, year, name)
38
    return pd.concat([stor], keys=["phes"]).swaplevel(0, 1)
39