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

scenario_builder.feedin.scenario_feedin()   A

Complexity

Conditions 2

Size

Total Lines 37
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 8
nop 4
dl 0
loc 37
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
from reegis import coastdat
9
from reegis import geometries
10
11
12
def scenario_feedin(regions, year, name, weather_year=None):
13
    """
14
15
    Parameters
16
    ----------
17
    regions
18
    year
19
    name
20
    weather_year
21
22
    Returns
23
    -------
24
25
    Examples
26
    --------
27
    >>> regions = geometries.get_federal_states_polygon()  # doctest: +SKIP
28
    >>> f = scenario_feedin(regions, 2014, "fs")  # doctest: +SKIP
29
    >>> f["NI"].sum()  # doctest: +SKIP
30
    geothermal    4380.000000
31
    hydro         2242.134748
32
    solar          831.424963
33
    wind          2602.090478
34
    dtype: float64
35
    >>> f["BY"].sum()  # doctest: +SKIP
36
    geothermal    4380.000000
37
    hydro         2242.134748
38
    solar          849.019372
39
    wind          1279.604124
40
    dtype: float64
41
    """
42
    wy = weather_year
43
    try:
44
        feedin = coastdat.scenario_feedin(year, name, weather_year=wy)
45
    except FileNotFoundError:
46
        coastdat.get_feedin_per_region(year, regions, name, weather_year=wy)
47
        feedin = coastdat.scenario_feedin(year, name, weather_year=wy)
48
    return feedin
49