Passed
Push — master ( 3b218c...39186e )
by Uwe
03:42 queued 02:28
created

scenario_builder.feedin.scenario_feedin()   A

Complexity

Conditions 2

Size

Total Lines 38
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 8
nop 4
dl 0
loc 38
rs 10
c 0
b 0
f 0
1
"""Create a basic scenario from the internal data structure.
2
3
SPDX-FileCopyrightText: 2016-2021 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
    >>> from reegis import geometries  # doctest: +SKIP
27
    >>> fs=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