Passed
Pull Request — master (#2)
by Uwe
01:04
created

scenario_builder.feedin   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 10
dl 0
loc 48
rs 10
c 0
b 0
f 0

1 Function

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