BorowyP commited on
Commit
369abf3
·
1 Parent(s): 3716fbd

panel app

Browse files
Files changed (7) hide show
  1. Dockerfile +11 -0
  2. HD_Logo.png +0 -0
  3. LFE_Logo.png +0 -0
  4. Luftfeuchte.py +202 -0
  5. df_air_hum.csv +0 -0
  6. fnr_logo.png +0 -0
  7. requirements.txt +9 -0
Dockerfile ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.9
2
+
3
+ WORKDIR /code
4
+
5
+ COPY ./requirements.txt /code/requirements.txt
6
+
7
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
8
+
9
+ COPY . .
10
+
11
+ CMD ["panel", "serve", "/code/Luftfeuchte.py", "--address", "0.0.0.0", "--port", "7860", "--allow-websocket-origin", "*"]
HD_Logo.png ADDED
LFE_Logo.png ADDED
Luftfeuchte.py ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Created on Tue Mar 21 11:06:37 2023
4
+
5
+ @author: BorowyP
6
+ """
7
+
8
+ import pandas as pd
9
+ import numpy as np
10
+ import hvplot.pandas # Adds .hvplot and .interactive methods to Pandas dataframes
11
+ import panel as pn # Panel is a simple, flexible and enterprise-ready data app framework
12
+ import holoviews as hv
13
+
14
+ pn.extension(sizing_mode="stretch_width")
15
+
16
+ PALETTE = ["#ff6f69", "#ffcc5c", "#88d8b0", ]
17
+ from bokeh.models.formatters import DatetimeTickFormatter
18
+ formatter = DatetimeTickFormatter(months='%b %Y') # wird in .hvplot benötigt für x-achse!
19
+
20
+ air_hum = pd.read_csv(r'df_air_hum.csv', sep=',',
21
+ header=0,
22
+ #skiprows=[1],
23
+ decimal=',',
24
+ na_values=('#-INF', '#NAN'))
25
+
26
+ air_hum.index = pd.to_datetime(air_hum['Date'], format='%Y.%m.%d %H:%M:%S')
27
+ #air_hum.index.names = ['Date']
28
+ air_hum = air_hum.drop(['Date'], axis=1)
29
+ air_hum['hum'] = air_hum['hum'].astype(np.float64, copy=True, errors='ignore')
30
+
31
+ air_hum = air_hum.round(1)
32
+
33
+
34
+
35
+ air_date_slider = pn.widgets.DateRangeSlider(name='Date', start=air_hum.index.min(), end=air_hum.index.max())
36
+ Stndrt = pn.widgets.RadioButtonGroup(name='Standort', options=['Glienig', 'Groß Liebitz', 'Krausnick', 'Halbe', 'Spreeau', 'Hangelsberg'],button_type='success')
37
+ air_date_slider
38
+
39
+ air_hum_inter = air_hum.interactive()
40
+
41
+ air_hum_inter = (
42
+ air_hum_inter[
43
+ (air_hum_inter.Standort == Stndrt) &
44
+ (air_hum_inter.index >= air_date_slider.param.value_start) &
45
+ (air_hum_inter.index <= air_date_slider.param.value_end)
46
+
47
+ ])
48
+
49
+ def lin_reg_hum(dfx,dfy, date):
50
+ # Formel für regres-gerade: y= alpha + b * x
51
+ # https://www.crashkurs-statistik.de/einfache-lineare-regression/
52
+
53
+ lin_df = pd.DataFrame({'Date' : date,
54
+ 'Luftfeuchte' : dfy,
55
+ 'x-x.mean' : dfx-dfx.mean(),
56
+ 'y-y.mean' : dfy-dfy.mean(),
57
+ '(x-x.mean) * (y-y.mean)': (dfx-dfx.mean()) * (dfy-dfy.mean()),
58
+ '(x-x.mean)²' : (dfx-dfx.mean()) * (dfx-dfx.mean())
59
+ })
60
+
61
+ b = lin_df['(x-x.mean) * (y-y.mean)'].sum()/ lin_df['(x-x.mean)²'].sum()
62
+
63
+ alpha = dfy.mean() - b * dfx.mean()
64
+
65
+ lin_df['Lineare Regression'] = round(alpha + b * dfx,2)
66
+
67
+ lin_plot = lin_df.hvplot(x='Date',
68
+ xlabel='Datum',
69
+ title=Stndrt,
70
+ y=['Luftfeuchte', 'Lineare Regression'],
71
+ ylabel='rel Luftfeuchte [%]',
72
+ color=PALETTE,
73
+ line_width=0.5,
74
+ xformatter=formatter)
75
+
76
+ SQE = ((lin_df['Lineare Regression']-dfy.mean())*(lin_df['Lineare Regression']-dfy.mean())).sum()
77
+
78
+ SQT = (lin_df['y-y.mean'] * lin_df['y-y.mean']).sum()
79
+
80
+ R_Wert = round(SQE/SQT,2)
81
+
82
+
83
+ mean = round(dfy.mean(),2)
84
+ median = dfy.median()
85
+ maxm = dfy.max()
86
+ minm = dfy.min()
87
+ anz = dfy.count()
88
+
89
+ monitor_df = pd.DataFrame({'Standort' : [Stndrt.value],
90
+ 'von' : [air_date_slider.value[0]],
91
+ 'bis' : [air_date_slider.value[1]],
92
+ 'Mittelwert' : [mean],
93
+ 'Median' : [median],
94
+ 'Maximum' : [maxm],
95
+ 'Minimum' : [minm],
96
+ 'Anzahl' : [anz],
97
+ 'R²' : [R_Wert]
98
+
99
+ })
100
+
101
+ return pn.Column(lin_plot, monitor_df)
102
+
103
+
104
+
105
+ def callback_hum(air_hum_inter):
106
+ y = air_hum_inter.hum
107
+ x = air_hum_inter['Unnamed: 0']
108
+ return pn.Column(lin_reg_hum(x,y, air_hum_inter.index))
109
+
110
+
111
+ airhumplot = air_hum_inter.pipe(callback_hum)
112
+
113
+ airhumplot
114
+
115
+
116
+ hum_glienig = pd.DataFrame({'Glienig': air_hum.loc[air_hum['Standort'] == 'Glienig']['hum']},
117
+ index = air_hum.loc[air_hum['Standort'] == 'Glienig'].index)
118
+ hum_grlieb = pd.DataFrame({'Groß Liebitz': air_hum.loc[air_hum['Standort'] == 'Groß Liebitz']['hum']},
119
+ index = air_hum.loc[air_hum['Standort'] == 'Groß Liebitz'].index)
120
+ hum_halbe = pd.DataFrame({'Halbe' : air_hum.loc[air_hum['Standort'] == 'Halbe']['hum']},
121
+ index= air_hum.loc[air_hum['Standort'] == 'Halbe'].index)
122
+ hum_hberg = pd.DataFrame({'Hangelsberg' : air_hum.loc[air_hum['Standort'] == 'Hangelsberg']['hum']},
123
+ index= air_hum.loc[air_hum['Standort'] == 'Hangelsberg'].index)
124
+ hum_kraunick = pd.DataFrame({'Krausnick' : air_hum.loc[air_hum['Standort'] == 'Krausnick']['hum']},
125
+ index= air_hum.loc[air_hum['Standort'] == 'Krausnick'].index)
126
+ hum_spreeau = pd.DataFrame({'Spreeau' : air_hum.loc[air_hum['Standort'] == 'Spreeau']['hum']},
127
+ index= air_hum.loc[air_hum['Standort'] == 'Spreeau'].index)
128
+ air_hum_hist = pd.concat([hum_glienig,hum_grlieb,hum_halbe,hum_hberg,hum_kraunick,hum_spreeau])
129
+
130
+
131
+
132
+
133
+ dfi_hum = air_hum_hist.interactive()
134
+
135
+ filtered = dfi_hum[
136
+ (dfi_hum.index >= air_date_slider.param.value_start) &
137
+ (dfi_hum.index <= air_date_slider.param.value_end)]
138
+
139
+ plot_air_humhist = filtered.hvplot(y=['Glienig',
140
+ 'Groß Liebitz',
141
+ 'Halbe',
142
+ 'Hangelsberg',
143
+ 'Krausnick',
144
+ 'Spreeau'],
145
+ kind='hist',
146
+ responsive=True,
147
+ min_height=300,
148
+ xlabel='rel Luftfeuchte[%]',
149
+ alpha=0.5)
150
+
151
+ plot_air_humhist
152
+
153
+ hd_logo = pn.pane.PNG('HD_Logo.png', width=100)
154
+ hd_logo
155
+
156
+ lfe_logo = pn.pane.PNG('LFE_Logo.png', width=100)
157
+
158
+ fnr_logo = pn.pane.PNG('fnr_logo.png', width=100)
159
+
160
+
161
+
162
+ sidebar_link_list = pn.pane.HTML(
163
+ '''
164
+ <div class="bk" style="position: relative; display: block; left: 0px; top: 0px; width: 314px; height: 522px; margin: 0px;"><div class="bk markdown" style="position: absolute; display: block; left: 5px; top: 5px; width: 304px; height: 48px;"><div class="bk bk-clearfix" style="display: inline-block; width: 100%;"><p><a href="https://paulborowy-20230303-multiple-panel.hf.space" target="_blank">Startseite</a></p></div></div><div class="bk markdown" style="position: absolute; display: block; left: 5px; top: 63px; width: 304px; height: 48px;"><div class="bk bk-clearfix" style="display: inline-block; width: 100%;"><p><a href="https://paulborowy-holzdeko.hf.space/Lufttemperatur" target="_blank">Lufttemperatur</a></p></div></div><div class="bk markdown" style="position: absolute; display: block; left: 5px; top: 121px; width: 304px; height: 48px;"><div class="bk bk-clearfix" style="display: inline-block; width: 100%;"><p><a href="https://paulborowy-holzdeko.hf.space/Luftfeuchte" target="_blank">Luftfeuchte</a></p></div></div><div class="bk markdown" style="position: absolute; display: block; left: 5px; top: 179px; width: 304px; height: 48px;"><div class="bk bk-clearfix" style="display: inline-block; width: 100%;"><p><a href="https://paulborowy-holzdeko.hf.space/Niederschlag" target="_blank">Niederschlag</a></p></div></div><div class="bk markdown" style="position: absolute; display: block; left: 5px; top: 237px; width: 304px; height: 48px;"><div class="bk bk-clearfix" style="display: inline-block; width: 100%;"><p><a href="https://paulborowy-holzdeko.hf.space/Bodentemperatur" target="_blank">Bodentemperatur</a></p></div></div><div class="bk markdown" style="position: absolute; display: block; left: 5px; top: 295px; width: 304px; height: 48px;"><div class="bk bk-clearfix" style="display: inline-block; width: 100%;"><p><a href="https://paulborowy-holzdeko.hf.space/Bodenfeuchte" target="_blank">Bodenfeuchte</a></p></div></div><div class="bk markdown" style="position: absolute; display: block; left: 5px; top: 353px; width: 304px; height: 48px;"><div class="bk bk-clearfix" style="display: inline-block; width: 100%;"><p><a href="https://paulborowy-holzdeko.hf.space/Hemisfere" target="_blank">Hemisfere</a></p></div></div><div class="bk markdown" style="position: absolute; display: block; left: 5px; top: 411px; width: 304px; height: 48px;"><div class="bk bk-clearfix" style="display: inline-block; width: 100%;"><p><a href="https://paulborowy-holzdeko.hf.space/Stahlrahmen" target="_blank">Streufall</a></p></div></div><div class="bk markdown" style="position: absolute; display: block; left: 5px; top: 469px; width: 304px; height: 48px;"><div class="bk bk-clearfix" style="display: inline-block; width: 100%;"><p><a href="https://paulborowy-holzdeko.hf.space/Masseverlust" target="_blank">Masseverlust</a></p></div></div></div>
165
+
166
+ ''')
167
+
168
+ sidebar_menu = pn.Column(hd_logo,
169
+ pn.pane.Markdown("## Menu"),
170
+ sidebar_link_list,
171
+ lfe_logo,
172
+ fnr_logo )
173
+
174
+ standort_label = pn.pane.Markdown('### Standort')
175
+
176
+ standort_col = pn.Column(standort_label, Stndrt)
177
+
178
+ template = pn.template.FastListTemplate(
179
+ title='Holzdeko Luftfeuchte',
180
+ sidebar=[sidebar_menu
181
+ ],
182
+ main=[pn.pane.Markdown("## Relative Luftfeuchte"),
183
+ standort_col,
184
+ air_date_slider,
185
+ airhumplot.panel(),
186
+ plot_air_humhist # LUFT
187
+
188
+ ]
189
+ ,accent_base_color="#00613a",
190
+ header_background="#00613a",
191
+ )
192
+
193
+
194
+
195
+
196
+ template.servable();
197
+
198
+ #print('fertig!')
199
+ # To launch this dashboard as a web server, we can simply run
200
+ # cd C:\Users\BorowyP\Desktop\Dashboard-Preasi\soil_air\
201
+ # panel serve 20230303_air_hum_docker.ipynb --autoreload
202
+
df_air_hum.csv ADDED
The diff for this file is too large to render. See raw diff
 
fnr_logo.png ADDED
requirements.txt ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ panel
2
+ hvplot
3
+ numpy
4
+ pandas
5
+ holoviews
6
+ bokeh
7
+ openpyxl
8
+ matplotlib
9
+ xarray