Passed
Pull Request — dev (#1226)
by Uwe
01:53
created

cost_data   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 100
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 71
dl 0
loc 100
rs 10
c 0
b 0
f 0

3 Functions

Rating   Name   Duplication   Size   Complexity  
A energy_prices() 0 28 1
A discounted_average_price() 0 18 1
A investment_costs() 0 44 1
1
import pandas as pd
2
import numpy as np
3
from oemof.tools.economics import annuity
4
5
6
def discounted_average_price(
7
    price_series, interest_rate, observation_period, year_of_investment
8
):
9
    discount_factors = 1 / (1 + interest_rate) ** np.arange(observation_period)
10
11
    # Formel:
12
    # p* = Sum( p_t / (1+r)^(t-1) ) / Sum( 1/(1+r)^(t-1) )
13
14
    numerator = price_series.loc[
15
            year_of_investment : year_of_investment + observation_period - 1
16
        ].mul(discount_factors, axis=0).sum()
17
18
    denominator = discount_factors.sum()
19
20
    print(annuity(numerator, observation_period, interest_rate))
21
    print(numerator / denominator)
22
23
    return numerator / denominator
24
25
26
def energy_prices() -> pd.DataFrame:
27
    print("Data is taken from at doi: https://doi.org/10.52202/077185-0033")
28
29
    years = [2025, 2030, 2035, 2040, 2045]
30
    # years = [2025, 2026, 2027, 2028, 2029]
31
    var_cost = pd.DataFrame(
32
        {
33
            "gas_prices [Eur/kWh]": [
34
                0.116,
35
                0.106,
36
                0.133,
37
                0.116,
38
                0.118,
39
            ],
40
            "electricity_prices [Eur/kWh]": [
41
                0.386,
42
                0.303,
43
                0.290,
44
                0.294,
45
                0.286,
46
            ],
47
            "pv_feed_in [Eur/kWh]": [-0.081] * 5,
48
        },
49
        index=pd.Index(years, name="year"),
50
    )
51
    return pd.concat(
52
        [pd.DataFrame(index=range(2025, 2065)), var_cost], axis=1
53
    ).interpolate()
54
55
56
def investment_costs() -> pd.DataFrame:
57
    print("Data is taken from doi: https://doi.org/10.52202/077185-0033")
58
59
    years = [2025, 2030, 2035, 2040, 2045]
60
    # years = [2025, 2026, 2027, 2028, 2029]
61
    idx = pd.Index(years, name="year")
62
63
    df = pd.DataFrame(
64
        {
65
            ("gas boiler", "specific_costs [Eur/kW]"): [61] * 5,
66
            ("gas boiler", "fixed_costs [Eur]"): [4794] * 5,
67
            ("heat pump", "specific_costs [Eur/kW]"): [
68
                1680,
69
                1318,
70
                1182,
71
                1101,
72
                1048,
73
            ],
74
            ("heat pump", "fixed_costs [Eur]"): [3860, 3030, 2716, 2530, 2410],
75
            ("heat storage", "specific_costs [Eur/m3]"): [1120] * 5,
76
            ("heat storage", "fixed_costs [Eur]"): [806] * 5,
77
            ("pv", "specific_costs [Eur/kW]"): [
78
                1200,
79
                1017,
80
                927,
81
                864,
82
                828,
83
            ],
84
            ("pv", "fixed_costs [Eur]"): [3038, 2575, 2347, 2188, 2096],
85
            ("battery", "specific_costs [Eur/kWh]"): [
86
                850,
87
                544,
88
                453,
89
                420,
90
                409,
91
            ],
92
            ("battery", "fixed_costs [Eur]"): [0] * 5,
93
        },
94
        index=idx,
95
    )
96
97
    return pd.concat(
98
        [pd.DataFrame(index=range(2025, 2065)), df], axis=1
99
    ).interpolate()
100