File size: 4,252 Bytes
fd0472a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# -*- coding: utf-8 -*-
"""
Created on Fri Mar  3 12:57:34 2023

@author: BorowyP
"""

import pandas as pd
import hvplot.pandas # Adds .hvplot and .interactive methods to Pandas dataframes
import panel as pn # Panel is a simple, flexible and enterprise-ready data app framework
import holoviews as hv
from holoviews.operation.timeseries import rolling, rolling_outlier_std


hv.extension('bokeh')
#pn.extension('tabulator')

pn.extension(sizing_mode="stretch_width")
#pd.set_option("precision", 0)

PALETTE = ["#ff6f69", "#ffcc5c", "#88d8b0", ]
import numpy as np
from bokeh.models.formatters import DatetimeTickFormatter
formatter = DatetimeTickFormatter(months='%b %Y') # wird in .hvplot benötigt für x-achse!

soil_temp = pd.read_csv('df_soil_temp.csv',header=0,sep=',')

soil_temp.index = pd.to_datetime(soil_temp['Date'], format='%Y.%m.%d %H:%M:%S')
soil_temp.index.names = ['Date']
soil_temp = soil_temp.drop(['Date'], axis=1)
soil_temp = soil_temp.drop(['Unnamed: 0'], axis=1)


soil_hum = pd.read_csv('df_soil_hum.csv',header=0,sep=',')
soil_hum.index = pd.to_datetime(soil_hum['Date'], format='%Y.%m.%d %H:%M:%S')
soil_hum.index.names = ['Date']
soil_hum = soil_hum.drop(['Date'], axis=1)
soil_hum = soil_hum.drop(['Unnamed: 0'], axis=1)

Stndrt = pn.widgets.RadioButtonGroup(name='Standort', options=['Glienig', 'Groß Liebitz', 'Krausnick', 'Halbe', 'Spreeau', 'Hangelsberg'],button_type='success')

soilhumbtn = pn.widgets.ToggleGroup(
    name='soilhumidity',
    options=['Prof100', 'Prof200', 'Prof300', 'Prof400', 'Prof600', 'Prof1000'], 
    value=['Prof100'],
    button_type='success')


soiltempbtn = pn.widgets.ToggleGroup(
    name='soiltemperature',
    options=['Temp05', 'Temp10', 'Temp20', 'Temp30', 'Temp50', 'Temp100'], 
    value=['Temp05'],
    button_type='success')
soil_date_slider = pn.widgets.DateRangeSlider(name='Date', start=soil_temp.index.min(), end=soil_temp.index.max())

soil_temp_i= soil_temp.interactive()

soil_temp_i = ( 
    soil_temp_i[
        (soil_temp_i.Standort == Stndrt) &
    (soil_temp_i.index >= soil_date_slider.param.value_start) &
    (soil_temp_i.index <= soil_date_slider.param.value_end)
                      ]
           )



soil_hum_i = soil_hum.interactive()

soil_hum_i = ( soil_hum_i[
    (soil_hum_i.Standort == Stndrt) & 
    (soil_hum_i.index >= soil_date_slider.param.value_start) &
    (soil_hum_i.index <= soil_date_slider.param.value_end) ])

soiltempplot = soil_temp_i.hvplot(x='Date',xlabel='Datum',title=Stndrt, y=soiltempbtn, color=PALETTE, line_width=1, xformatter=formatter, ylabel='Bodentemperatur [°C]')


soilhumplot = soil_hum_i.hvplot(x='Date',xlabel='Datum',title=Stndrt, y=soilhumbtn, color=PALETTE, line_width=1, xformatter=formatter, ylabel='Bodenfeuchte[%]')

soiltemp_box = soil_temp_i[['Temp05', 'Temp10', 'Temp20', 'Temp30', 'Temp50', 'Temp100']].fillna(0)
soiltemp_box_plot = soiltemp_box.hvplot(kind='box', legend=False, xlabel=Stndrt, ylabel='Bodentemperatur [°C]')


soilhum_box = soil_hum_i[['Prof100', 'Prof200', 'Prof300', 'Prof400', 'Prof600', 'Prof1000']].fillna(0)
soilhum_box_plot = soilhum_box.hvplot(kind='box', legend=False, xlabel=Stndrt, ylabel='Bodenfeuchte [%]')



hd_logo = pn.pane.PNG('HD_Logo.png', width=100)
hd_logo

lfe_logo = pn.pane.PNG('LFE_Logo.png', width=100)

fnr_logo = pn.pane.PNG('fnr_logo.png', width=100)

template = pn.template.FastListTemplate(
    title='Holzdeko Dashboard', 
    sidebar=[hd_logo,
             pn.pane.Markdown("## Einstellungen"),
             'Standort',Stndrt,
             lfe_logo,
             fnr_logo
             #'Boden',
             #'Gekalkt/ungekalkt', yaxis,
            ], 
    main=[pn.pane.Markdown("## Boden"),
          soiltempbtn,
          soil_date_slider,
          soiltempplot.panel(), 
          soiltemp_box_plot.panel(),
          soilhumbtn,
          soil_date_slider,
          soilhumplot.panel(), 
          soilhum_box_plot.panel()       
          
    #accent_base_color="#88d8b0",
    #header_background="#88d8b0",
         ])




template.servable();

#print('fertig!')
# To launch this dashboard as a web server, we can simply run 
# cd C:\Users\BorowyP\Desktop\Dashboard-Preasi\soil_air\
# panel serve 20230303_soil_temp_hum_docker.ipynb --autoreload