Spaces:
Running
Running
File size: 7,333 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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 7 12:04:33 2023
@author: BorowyP
"""
import pandas as pd
import hvplot.pandas # Adds .hvplot and .interactive methods to Pandas dataframes
from hvplot.plotting import scatter_matrix
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_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)
soil_hum[soil_hum.columns[list(range(6))]] = soil_hum[soil_hum.columns[list(range(6))]].round(1)
soil_hum = soil_hum.rename(columns={'Prof100' : '100',
'Prof200' : '200',
'Prof300' : '300',
'Prof400' : '400',
'Prof600' : '600' ,
'Prof1000' : '1000',
'Standort' : 'Standort'})
Stndrt = pn.widgets.RadioButtonGroup(name='Standort', options=['Glienig', 'Groß Liebitz', 'Krausnick', 'Halbe', 'Spreeau', 'Hangelsberg'],button_type='success')
soilhumbtn = pn.widgets.ToggleGroup(
name='soilhumidity',
options=['100', '200', '300', '400', '600', '1000'],
value=['100'],
button_type='success')
soil_date_slider = pn.widgets.DateRangeSlider(name='Date', start=soil_hum.index.min(), end=soil_hum.index.max())
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) ])
soilhumplot = soil_hum_i.hvplot(x='Date',xlabel='Datum',title=Stndrt, y=soilhumbtn, color=PALETTE, line_width=1, xformatter=formatter, ylabel='Bodenfeuchte[%]')
def callback_hum(soil_hum_i):
df = soil_hum_i
monitor = pd.DataFrame({#'Standort' : [Stndrt.value, Stndrt.value],
#'von' : soil_temp_i.index.min(),
#'bis' : soil_temp_i.index.max(),
'Mittelwert' : [df['100'].mean(),
df['200'].mean(),
df['300'].mean(),
df['400'].mean(),
df['600'].mean(),
df['1000'].mean(),
] ,
'Median' : [df['100'].median(),
df['200'].median(),
df['300'].median(),
df['400'].median(),
df['600'].median(),
df['1000'].median(),
] ,
'Maximum' : [df['100'].max(),
df['200'].max(),
df['300'].max(),
df['400'].max(),
df['600'].max(),
df['1000'].max()],
'Minimum' : [df['100'].min(),
df['200'].min(),
df['300'].min(),
df['400'].min(),
df['600'].min(),
df['1000'].min()],
'Anzahl' : [df['100'].count(),
df['200'].count(),
df['300'].count(),
df['400'].count(),
df['600'].count(),
df['1000'].count()]
}, index=['100',
'200',
'300',
'400',
'600',
'1000',
])
monitor.index.name='Profiltiefe'
#soiltemp_scatter = scatter_matrix(soil_temp, alpha=0.2) #Scattermatrix zum Vergleich der einzelnen Profiltiefen???
soiltemp_scatter_df = soil_hum[soil_hum['Standort'] == Stndrt.value]#.iloc[df.index.min(): df.index.max()]
soiltemp_scatter = scatter_matrix(soiltemp_scatter_df, alpha=0.2)
scatter_headline = pn.pane.Markdown(f"## Scattermatrix Bodenfeuchte **{Stndrt.value}**")
scatter_discription = pn.pane.Markdown('scatter_matrix shows all the pairwise relationships between the columns of your data. Each non-diagonal entry plots the corresponding columns against another, while the diagonal plot shows the distribution of the data within each individual column.'
)
monitor_gesamt = pd.DataFrame({'Standort' : [Stndrt.value],
'von' : df.index.min(),
'bis' : df.index.max(),
'Mittelwert' : df.mean(numeric_only=True).mean(),
'Median' : df.median(numeric_only=True).median(),
'Maximum' : df.max(numeric_only=True).max(),
'Minimum' : df.min(numeric_only=True).min()
}, index=['Gesamt'])
return pn.Column(monitor_gesamt, monitor,scatter_headline, soiltemp_scatter, scatter_discription)
callback = soil_hum_i.pipe(callback_hum)
callback
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("## Bodenfeuchte"),
soilhumbtn,
soil_date_slider,
soilhumplot.panel(),
callback
#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 20230307_soil_hum_docker.ipynb --autoreload |