-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.py
More file actions
108 lines (97 loc) · 3.29 KB
/
functions.py
File metadata and controls
108 lines (97 loc) · 3.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import streamlit as st
import altair as alt
import config as cfg
alt.renderers.set_embed_options(format_locale="de-DE", time_format_locale="de-DE")
###### FUNCTIONS ######
def eigenverbrauch(capacity_kWp, power_consumption):
# Polynom EV, abgeleitet aus HTW-Rechner:
# v01
# y = 0.1411x6 - 1.0872x5 + 3.3682x4 - 5.4162x3 + 4.9424x2 - 2.7492x + 1.1003 / R^2 = 1
# y = Eigenverbrauchsanteil / x = Größe PV-Anlage relativ zu Anlagengröße [Wp/kWh] / Polynom nur definiert für x = 0 bis 2
# v02
# y = 0.0085x6 - 0.1175x5 + 0.6429x4 - 1.7748x3 + 2.6424x2 - 2.171x + 1.0695 / R^2 = 0.9988
# y = Eigenverbrauchsanteil / x = Größe PV-Anlage relativ zu Anlagengröße [Wp/kWh] / Polynom nur definiert für x = 0 bis 4
c6 = 0.0085
c5 = -0.1175
c4 = 0.6429
c3 = -1.7748
c2 = 2.6424
c1 = -2.171
c0 = 1.0695
x = capacity_kWp * 10**3 / power_consumption
if (x == 0):
y = 0
elif (x > 4):
y = 0.10
elif (x < 0.1):
y = 0.89
else:
y = c6*x**6 + c5*x**5 + c4*x**4 + c3*x**3 + c2*x**2 + c1*x + c0
return y
def warnung(text):
st.warning('_:warning: **HINWEIS:** ' + text + '_')
def zahlenformat(zahl, nks):
# return locale.format("%.0f", zahl, grouping=True)
return str("{:,." + str(nks) + "f}").format(zahl)
def calc_einspeiseverguetung(modus, capacity_kWp):
if modus == "UE":
ev1 = 7.94
ev2 = 6.88
ev3 = 5.62
if capacity_kWp <= 10:
ev = ev1
elif capacity_kWp <= 40:
ev = (10 * ev1 + (capacity_kWp - 10) * ev2) / capacity_kWp
elif capacity_kWp <= 100:
ev = (10 * ev1 + (40 - 10) * ev2 + (capacity_kWp - 40) * ev3) / capacity_kWp
else:
ev = 0
raise Exception("Max capacity of 100 kW exceeded.")
elif modus == "VE":
ev1 = 12.6
ev2 = 10.56
if capacity_kWp <= 10:
ev = ev1
elif capacity_kWp <= 100:
ev = (10 * ev1 + (capacity_kWp - 10) * ev2) / capacity_kWp
else:
ev = 0
raise Exception("Max capacity of 100 kW exceeded.")
else:
ev = 0
raise Exception("EV Mode unknown")
return ev / 100
def transpose_list(matrix):
return [[row[i] for row in matrix] for i in range(len(matrix[0]))]
def one_dim_list(two_dim):
one_dim_list = [n for one_dim in two_dim for n in one_dim]
return one_dim_list
def create_chart(data, metric, color, ylabel, height, show):
chart = (
alt.Chart(data)
.mark_bar()
.encode(
x=alt.X('Konzept:N', sort=[]),
y=alt.Y(metric + ':Q', sort=[], title=ylabel),
color=alt.Color(color + ":N", legend=alt.Legend(orient='bottom')).scale(range=cfg.color_range)
)
).configure_axisX(
labelAngle=0,
labelLimit=200,
labelFontSize=12,
labelColor='black',
titleColor='black'
).configure_axisY(
labelColor='black',
titleColor='black'
).properties(
height=height
).configure_legend(
columns=2,
labelColor='black',
titleColor='black',
disable=show
)
#if (color != None):
# chart = alt.Chart(data).mark_bar().encode(color=alt.Color("Kategorie:N", legend=alt.Legend(orient='bottom')))
st.altair_chart(chart)