Spaces:
Sleeping
Sleeping
BorowyP
commited on
Commit
•
fcdd00e
1
Parent(s):
5fae950
panel app
Browse files- Dockerfile +11 -0
- HD_Logo.png +0 -0
- LFE_Logo.png +0 -0
- Lufttemperatur.py +217 -0
- df_air_temp.csv +0 -0
- fnr_logo.png +0 -0
- 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/Lufttemperatur.py", "--address", "0.0.0.0", "--port", "7860", "--allow-websocket-origin", "*"]
|
HD_Logo.png
ADDED
LFE_Logo.png
ADDED
Lufttemperatur.py
ADDED
@@ -0,0 +1,217 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- coding: utf-8 -*-
|
2 |
+
"""
|
3 |
+
Created on Tue Mar 21 10:44:01 2023
|
4 |
+
|
5 |
+
@author: BorowyP
|
6 |
+
"""
|
7 |
+
|
8 |
+
import pandas as pd
|
9 |
+
import hvplot.pandas # Adds .hvplot and .interactive methods to Pandas dataframes
|
10 |
+
import panel as pn # Panel is a simple, flexible and enterprise-ready data app framework
|
11 |
+
import holoviews as hv
|
12 |
+
from holoviews.operation.timeseries import rolling, rolling_outlier_std
|
13 |
+
|
14 |
+
|
15 |
+
hv.extension('bokeh')
|
16 |
+
#pn.extension('tabulator')
|
17 |
+
|
18 |
+
pn.extension(sizing_mode="stretch_width")
|
19 |
+
#pd.set_option("precision", 0)
|
20 |
+
|
21 |
+
PALETTE = ["#ff6f69", "#ffcc5c", "#88d8b0", ]
|
22 |
+
ACCENT_BASE_COLOR = PALETTE[0]
|
23 |
+
|
24 |
+
#import time
|
25 |
+
#start = time.time()
|
26 |
+
#print('load data')
|
27 |
+
|
28 |
+
import numpy as np
|
29 |
+
|
30 |
+
from math import pi
|
31 |
+
|
32 |
+
from bokeh.palettes import Category20c, Category20
|
33 |
+
from bokeh.plotting import figure
|
34 |
+
from bokeh.transform import cumsum
|
35 |
+
from bokeh.layouts import row
|
36 |
+
from bokeh.models.formatters import DatetimeTickFormatter
|
37 |
+
formatter = DatetimeTickFormatter(months='%b %Y') # wird in .hvplot benötigt für x-achse!
|
38 |
+
|
39 |
+
|
40 |
+
air_temp = pd.read_csv(r'df_air_temp.csv', sep=',',
|
41 |
+
header=0,
|
42 |
+
#skiprows=[1],
|
43 |
+
decimal=',',
|
44 |
+
#dtype={'temp': np.float64},
|
45 |
+
na_values=('#-INF', '#NAN'))
|
46 |
+
|
47 |
+
air_temp.index = pd.to_datetime(air_temp['Date'], format='%Y.%m.%d %H:%M:%S')
|
48 |
+
|
49 |
+
air_temp = air_temp.drop(['Date'], axis=1)
|
50 |
+
air_temp['temp'] = air_temp['temp'].astype(np.float64, copy=True, errors='ignore')
|
51 |
+
air_temp = air_temp.round(1)
|
52 |
+
|
53 |
+
|
54 |
+
air_date_slider = pn.widgets.DateRangeSlider(name='Date', start=air_temp.index.min(), end=air_temp.index.max())
|
55 |
+
|
56 |
+
Stndrt = pn.widgets.RadioButtonGroup(name='Standort', options=['Glienig', 'Groß Liebitz', 'Krausnick', 'Halbe', 'Spreeau', 'Hangelsberg'],button_type='success')
|
57 |
+
|
58 |
+
air_temp_inter = air_temp.interactive()
|
59 |
+
|
60 |
+
air_temp_inter = (
|
61 |
+
air_temp_inter[
|
62 |
+
(air_temp_inter.Standort == Stndrt) &
|
63 |
+
(air_temp_inter.index >= air_date_slider.param.value_start) &
|
64 |
+
(air_temp_inter.index <= air_date_slider.param.value_end)
|
65 |
+
|
66 |
+
])
|
67 |
+
|
68 |
+
|
69 |
+
def lin_reg(dfx,dfy, date):
|
70 |
+
# Formel für regres-gerade: y= alpha + b * x
|
71 |
+
# https://www.crashkurs-statistik.de/einfache-lineare-regression/
|
72 |
+
|
73 |
+
lin_df = pd.DataFrame({'Date' : date,
|
74 |
+
'Temperatur' : dfy,
|
75 |
+
'x-x.mean' : dfx-dfx.mean(),
|
76 |
+
'y-y.mean' : dfy-dfy.mean(),
|
77 |
+
'(x-x.mean) * (y-y.mean)': (dfx-dfx.mean()) * (dfy-dfy.mean()),
|
78 |
+
'(x-x.mean)²' : (dfx-dfx.mean()) * (dfx-dfx.mean()),})
|
79 |
+
|
80 |
+
b = lin_df['(x-x.mean) * (y-y.mean)'].sum()/ lin_df['(x-x.mean)²'].sum()
|
81 |
+
|
82 |
+
alpha = dfy.mean() - b * dfx.mean()
|
83 |
+
|
84 |
+
lin_df['Lineare Regression'] = round(alpha + b * dfx,2)
|
85 |
+
|
86 |
+
lin_plot = lin_df.hvplot(x='Date',
|
87 |
+
xlabel='Datum',
|
88 |
+
title=Stndrt,
|
89 |
+
y=['Temperatur', 'Lineare Regression'],
|
90 |
+
ylabel='Lufttemperatur [°C]',
|
91 |
+
color=PALETTE,
|
92 |
+
line_width=0.5,
|
93 |
+
xformatter=formatter)
|
94 |
+
|
95 |
+
SQE = ((lin_df['Lineare Regression']-dfy.mean())*(lin_df['Lineare Regression']-dfy.mean())).sum()
|
96 |
+
|
97 |
+
SQT = (lin_df['y-y.mean'] * lin_df['y-y.mean']).sum()
|
98 |
+
|
99 |
+
R_Wert = round(SQE/SQT,2)
|
100 |
+
|
101 |
+
|
102 |
+
mean = round(dfy.mean(),2)
|
103 |
+
median = dfy.median()
|
104 |
+
maxm = dfy.max()
|
105 |
+
minm = dfy.min()
|
106 |
+
anz = dfy.count()
|
107 |
+
|
108 |
+
monitor_df = pd.DataFrame({'Standort' : [Stndrt.value],
|
109 |
+
'von' : [air_date_slider.value[0]],
|
110 |
+
'bis' : [air_date_slider.value[1]],
|
111 |
+
'Mittelwert' : [mean],
|
112 |
+
'Median' : [median],
|
113 |
+
'Maximum' : [maxm],
|
114 |
+
'Minimum' : [minm],
|
115 |
+
'Anzahl' : [anz],
|
116 |
+
'R²' : [R_Wert]
|
117 |
+
|
118 |
+
})
|
119 |
+
|
120 |
+
return pn.Column(lin_plot, monitor_df)
|
121 |
+
|
122 |
+
|
123 |
+
|
124 |
+
def callback(air_temp_inter):
|
125 |
+
y = air_temp_inter.temp
|
126 |
+
x = air_temp_inter['Unnamed: 0']
|
127 |
+
return pn.Column(lin_reg(x,y, air_temp_inter.index))
|
128 |
+
|
129 |
+
|
130 |
+
airtempplot = air_temp_inter.pipe(callback)
|
131 |
+
|
132 |
+
|
133 |
+
|
134 |
+
|
135 |
+
temp_glienig = pd.DataFrame({'Glienig': air_temp.loc[air_temp['Standort'] == 'Glienig']['temp']},
|
136 |
+
index = air_temp.loc[air_temp['Standort'] == 'Glienig'].index)
|
137 |
+
temp_grlieb = pd.DataFrame({'Groß Liebitz': air_temp.loc[air_temp['Standort'] == 'Groß Liebitz']['temp']},
|
138 |
+
index = air_temp.loc[air_temp['Standort'] == 'Groß Liebitz'].index)
|
139 |
+
temp_halbe = pd.DataFrame({'Halbe' : air_temp.loc[air_temp['Standort'] == 'Halbe']['temp']},
|
140 |
+
index= air_temp.loc[air_temp['Standort'] == 'Halbe'].index)
|
141 |
+
temp_hberg = pd.DataFrame({'Hangelsberg' : air_temp.loc[air_temp['Standort'] == 'Hangelsberg']['temp']},
|
142 |
+
index= air_temp.loc[air_temp['Standort'] == 'Hangelsberg'].index)
|
143 |
+
temp_krausnick = pd.DataFrame({'Krausnick' : air_temp.loc[air_temp['Standort'] == 'Krausnick']['temp']},
|
144 |
+
index= air_temp.loc[air_temp['Standort'] == 'Krausnick'].index)
|
145 |
+
temp_spreeau = pd.DataFrame({'Spreeau' : air_temp.loc[air_temp['Standort'] == 'Spreeau']['temp']},
|
146 |
+
index= air_temp.loc[air_temp['Standort'] == 'Spreeau'].index)
|
147 |
+
|
148 |
+
air_temp_hist = pd.concat([temp_glienig,temp_grlieb,temp_halbe,temp_hberg,temp_krausnick,temp_spreeau])
|
149 |
+
|
150 |
+
dfi_temp = air_temp_hist.interactive()
|
151 |
+
|
152 |
+
filtered = dfi_temp[
|
153 |
+
(dfi_temp.index >= air_date_slider.param.value_start) &
|
154 |
+
(dfi_temp.index <= air_date_slider.param.value_end)]
|
155 |
+
|
156 |
+
plot_air_temphist = filtered.hvplot(y=['Glienig',
|
157 |
+
'Groß Liebitz',
|
158 |
+
'Halbe',
|
159 |
+
'Hangelsberg',
|
160 |
+
'Krausnick',
|
161 |
+
'Spreeau'], kind='hist', responsive=True, min_height=300, xlabel='Lufttemperatur [°C]', alpha=0.5)
|
162 |
+
|
163 |
+
standort_label = pn.pane.Markdown('### Standort')
|
164 |
+
standort_col = pn.Column(standort_label, Stndrt)
|
165 |
+
|
166 |
+
|
167 |
+
import os
|
168 |
+
|
169 |
+
|
170 |
+
hd_logo = pn.pane.PNG('HD_Logo.png', width=100)
|
171 |
+
hd_logo
|
172 |
+
|
173 |
+
lfe_logo = pn.pane.PNG('LFE_Logo.png', width=100)
|
174 |
+
|
175 |
+
fnr_logo = pn.pane.PNG('fnr_logo.png', width=100)
|
176 |
+
|
177 |
+
sidebar_link_list = pn.pane.HTML(
|
178 |
+
'''
|
179 |
+
<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>
|
180 |
+
|
181 |
+
''')
|
182 |
+
|
183 |
+
sidebar_menu = pn.Column(hd_logo,
|
184 |
+
pn.pane.Markdown("## Menu"),
|
185 |
+
sidebar_link_list,
|
186 |
+
lfe_logo,
|
187 |
+
fnr_logo )
|
188 |
+
|
189 |
+
template = pn.template.FastListTemplate(
|
190 |
+
title='Holzdeko Lufttemperatur',
|
191 |
+
sidebar=[sidebar_menu
|
192 |
+
],
|
193 |
+
main=[pn.pane.Markdown("## Luft Temperaturdaten"),
|
194 |
+
standort_col,
|
195 |
+
air_date_slider,
|
196 |
+
airtempplot.panel(),
|
197 |
+
plot_air_temphist,
|
198 |
+
|
199 |
+
|
200 |
+
|
201 |
+
|
202 |
+
|
203 |
+
|
204 |
+
],
|
205 |
+
accent_base_color="#00613a",
|
206 |
+
header_background="#00613a"
|
207 |
+
)
|
208 |
+
|
209 |
+
|
210 |
+
|
211 |
+
|
212 |
+
template.servable();
|
213 |
+
|
214 |
+
#print('fertig!')
|
215 |
+
# To launch this dashboard as a web server, we can simply run
|
216 |
+
# cd C:\Users\BorowyP\Desktop\Dashboard-Preasi\soil_air\
|
217 |
+
# panel serve 20230224_air_temp_docker.ipynb --autoreload
|
df_air_temp.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
|