File size: 5,223 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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# -*- coding: utf-8 -*-
"""
Created on Fri Mar 10 15:10:36 2023

@author: BorowyP
"""

import os

import matplotlib.pyplot as plt

import numpy as np
import pandas as pd

import hvplot.pandas

import holoviews as hv

from holoviews.operation.timeseries import rolling, rolling_outlier_std

import xarray as xr
import panel as pn

import panel.widgets as pnw



import hvplot.xarray

cwd = os.getcwd()
print(cwd)
print(os.listdir(cwd))
os.chdir('hemi_fotos')
pic_cwd = os.getcwd()
print(pic_cwd)
os.listdir(pic_cwd)

os.chdir(pic_cwd)
#os.listdir()
list_pictures_files = os.listdir()

rgb_list = []

for i in range(len(list_pictures_files)):
    im = plt.imread(list_pictures_files[i])
    x = np.arange(len(im[0]))
    y = np.arange(len(im))
    channel = np.arange(3)
    im_xr = xr.DataArray(im,coords={'y': y,'x': x,'channel': channel},dims=["y", "x", "channel"])
    rgb_list.append(im_xr)
    #print(str(list_pictures_files[i]) + ' ' + 
    #      'y-Achse: ' + ' ' + str(len(im)) + ', ' + 
    #      'x-Achse: ' + ' ' + str(len(im[0])) + ', ' + 'channel: ' + ' ' + str(len(im[0][0])))
    #print(' ')

x = np.arange(len(rgb_list[0][0]))
y = np.arange(len(rgb_list[0]))
channel = np.arange(3)

Stndrt = np.array([
    'Krausnick K',
    'Glienig K',
    'Glienig nK',
    'Halbe K',
    'Halbe nK',
    'Hangelsberg K',
    'Hangelsberg nK',
    'Spreeau K',
    'Spreeau nK',
    'Groß Liebitz K',
    'Groß Liebitz nK'
])




xar = xr.DataArray(rgb_list, 
                   dims=(
                       
                       'Standort',
                       "y", 
                       "x", 
                       "channel")
                   , 
                   coords={
                       "x": x,
                       "y": y,
                       "channel": channel,
                       'Standort' : Stndrt,
                       
                   },
                  name="rgb")




fisheye = xar.hvplot.rgb(x='x', y='y', bands='channel', data_aspect=1, flip_yaxis=True, xaxis=False, yaxis=None, width=500)


os.chdir(cwd)


df = pd.read_csv(
        'Hemisphere_totals_holzdeko.csv' ,
        encoding_errors='ignore', 
        sep=';', 
        #skiprows=[5,10], 
        header=0, 
        decimal=','
           )

df['transmission'] = df['transmission'].str.strip('%') #  entfernt Character '%'
df['transm_gaps'] = df['transm_gaps'].str.strip('%')
df['openness'] = df['openness'].str.strip('%')
df['openn_gaps'] = df['openn_gaps'].str.strip('%')

df['transmission'] = df['transmission'].replace(',', '.', regex=True) # wandelt , in . um
df['transm_gaps'] = df['transm_gaps'].replace(',', '.', regex=True)
df['openness'] = df['openness'].replace(',', '.', regex=True)
df['openn_gaps'] = df['openn_gaps'].replace(',', '.', regex=True)

df['transmission'] = df['transmission'].astype('float64', copy=False)
df['transm_gaps'] = df['transm_gaps'].astype('float64', copy=False)
df['openness'] = df['openness'].astype('float64', copy=False)
df['openn_gaps'] = df['openn_gaps'].astype('float64', copy=False)



params = pn.widgets.RadioButtonGroup(
    name='param',
    options=['white',
             'black',
             'transmission',
             'transm_gaps',
             'openness',
             'openn_gaps'
             ], 
    button_type='success')

data_inter = df.interactive()

mean_param = (
    data_inter
    .groupby(['Standort', 'k_nk']).mean()
    
)

mean_param_plot = mean_param[params].hvplot(x='Standort', y=params, by='k_nk', kind='bar', 
                        title=params, xlabel='Standort')





param_discription = pd.DataFrame({'white': ['white pixels (sky)'],
                                 'black' : ['black pixels (canopy)'],
                                 'transmission' : ['light transmission in 2D (azimutal equidistant projection of the hemisphere)'],
                                 'transm_gaps' : ['large gaps of transmission'],
                                 'openness' : ['canopy openness in 3D, also called sky view factor (solid angles of the hemisphere)'],
                                 'openn_gaps' : ['large gaps of openness']})

param_discription = param_discription.interactive()

param_discription = param_discription[params].values[0]



os.chdir(cwd)
hd_logo = pn.pane.PNG('HD_Logo.png', width=100)
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='Auswertung Hemisfere', 
    sidebar=[hd_logo,
             pn.pane.Markdown("## Einstellungen"),
             #'Standort',Stndrt,
             #'gekalkt/ungekalkt', yaxis,
             lfe_logo,
             fnr_logo
             #'Boden',
             #'Gekalkt/ungekalkt', yaxis,
            ], 
    main=[pn.pane.Markdown("## Hemisfere"),
          fisheye,#.panel(),
          #params,
          param_discription,
          mean_param_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\hemisfer

# panel serve 2023_02_10_hemi_dashboard.ipynb --autoreload