Waermebilanz_1

Bibliotheken importieren

# Name des aktuellen Notebooks für die exportierten Datein
file_name = "Waermebilanz_1" 
# Ordner auf dem Server (nach files/)
ftp_folder = 'Notebooks/Auswertung'
## Bibliotheken, Module und Text- bzw- Grafikformatierungen aus zentraler Datei laden
%run ../Template/libraries_and_styles.ipynb 
## Warum auch immer muss rcParams.update() in eine eigene Zelle...
mpl.rcParams.update(params)
from bokeh.io import output_file, output_notebook, show 
from bokeh.layouts import column
from bokeh.plotting import figure, ColumnDataSource, Figure,curdoc 
from bokeh.models import LinearAxis, Range1d, BoxSelectTool, DatetimeTickFormatter, RangeTool, HoverTool
output_notebook()  
Loading BokehJS ...

Daten Import

daten = pd.read_csv('../1_Daten/Arbeitsdaten/Daten_15s.csv')
daten['Zeit'] = pd.to_datetime(daten["Zeit"],dayfirst=True,)
daten.set_index(["Zeit"], inplace=True)

#daten = daten.loc['2017-06-01 00:00:00':'2017-06-20 23:59:45']


## Luftdruck
## topo: http://media.heimatundwelt.de/omeda/501/100264_009_3.jpg -> 139m ü.n.N 101.325 
## barometrische Höhenformel: http://wetter.andreae-gymnasium.de/interaktives/Druck/barometrische.htm bei 5°C -> 995,9 hPa
daten['W_Luftdruck'] =   daten['W_Luftdruck'] /10 + 5.1 ## 40 Hohenmeter Differenz zw Wetterstation und Bootshaus

daten['L_Zuluft_VPunkt'] = daten['L_Zuluft_1_VPunkt']  + daten['L_Zuluft_2_VPunkt'] + daten['L_Zuluft_3_VPunkt'] 

## DataFrame für den Zeitraum der Kalibrierung
# daten_kal = daten.loc['2018-02-22 16:40:00':'2018-02-23 14:38:00'].copy()
# daten_kal_selbst = daten_kal.copy()
# daten_kal_T480   = daten_kal.copy()

## ungenaue Enden abschneiden
# datena = daten.loc['2017-12-06 00:00:00':'2017-12-11 23:59:45']
# datenb = daten.loc['2018-01-31 00:00:00':'2018-02-11 23:59:45'] 
# datenc = daten.loc['2018-02-16 00:00:00':'2018-02-20 23:59:45'] 
# daten = pd.concat([datena, datenb, datenc])
# # del [[datena, datenb, datenc]] gc.collect()
# daten.dropna(inplace=True)
# ## wurde da noch mal kalibriert?
# datena = daten.loc['2017-12-06 00:00:00':'2018-02-04 23:59:45']
# datenb = daten.loc['2018-02-06 00:00:00':'2018-02-20 23:59:45'] 
# daten = pd.concat([datena, datenb])
# daten.dropna(inplace=True)

# daten = daten.replace(0, np.nan)
# daten = daten.dropna(how='all', axis=0)
# daten = daten.replace(np.nan, 0)


## Subsets für alles weitere
daten_sub    = daten.copy()
daten_sub1   = daten.copy() 
daten_tgl    = pd.DataFrame()  

## gesamter Zeitraum
anfang = '2017-05-01 00:00:00'
ende   = '2018-04-30 23:59:45'
von = '2017-12-06 00:00:00'
bis = '2018-02-20 23:59:45'
eins  = pd.to_datetime("2017-12-06 00:00", infer_datetime_format=True).to_pydatetime()
zwei  = pd.to_datetime("2017-12-11 23:59", infer_datetime_format=True).to_pydatetime()
drei  = pd.to_datetime("2018-01-31 00:00", infer_datetime_format=True).to_pydatetime()
vier  = pd.to_datetime("2018-02-11 23:59", infer_datetime_format=True).to_pydatetime()
fünf  = pd.to_datetime("2018-02-16 00:00", infer_datetime_format=True).to_pydatetime()
sechs = pd.to_datetime("2018-02-20 23:59", infer_datetime_format=True).to_pydatetime()

# daten.isna().sum()

WRG Kalibrierung

Berechnungen

WGR_kal = daten.copy() #.loc[kal_von : kal_bis].resample("min").mean().copy()

def kalibrieren(X,Y):
    polyfit = np.polyfit(X,Y,deg=1)
    schaetzer = np.poly1d(polyfit) 
    print('WGR_kal[\''+X.name+'\'] = WGR_kal[\''+X.name+'\'] * ' +str(schaetzer[1]) +   ' + ' +str(schaetzer[0])    )
    return schaetzer(X)




## Kalibrierung gegen Testo
# WGR_kal['L_Aussenlufttemperatur_1_korr'] = WGR_kal['L_Aussenlufttemperatur_1'] * 0.9484142817603088 + 1.3850418938877918
# WGR_kal['L_Ablufttemperatur_korr']       = WGR_kal['L_Ablufttemperatur']       * 0.6230286392802793 + 7.2158386479613945
# WGR_kal['L_Fortlufttemperatur_korr']     = WGR_kal['L_Fortlufttemperatur']     * 0.9210001407556405 + 0.6246083693217548

## Kalibrierung gegen sich selbst
WGR_kal['L_Aussenlufttemperatur_1_korr'] = WGR_kal['L_Aussenlufttemperatur_1'] * 1.0662108187573032 + -0.5309722751765433
WGR_kal['L_Ablufttemperatur_korr']       = WGR_kal['L_Ablufttemperatur']       * 0.6360939326833698 + 6.952747187665505
WGR_kal['L_Fortlufttemperatur_korr']     = WGR_kal['L_Fortlufttemperatur']     * 0.8885155788864784 + 1.3007615291616732



## Kalibrierung gegen Testo
## werden für Zu und Fortluftfeuchte Berechnung benötigt 
# WGR_kal['W_Luftfeuchtigkeit_korr']       = WGR_kal['W_Luftfeuchtigkeit']       * 0.6222764631729626 + 19.995788042129863
# WGR_kal['L_Duschen_Ablufttfeuchte_korr'] = WGR_kal['L_Duschen_Ablufttfeuchte'] * 0.9087940037415406 + 1.7023841729299454


## Kalibrierung gegen sich selbst
## werden für Zu und Fortluftfeuchte Berechnung benötigt 
WGR_kal['W_Luftfeuchtigkeit_korr']       = WGR_kal['W_Luftfeuchtigkeit']       * 0.497955695370158 + 21.232584095701597
WGR_kal['L_Duschen_Ablufttfeuchte_korr'] = WGR_kal['L_Duschen_Ablufttfeuchte'] * 0.753384388346958 + 8.212720855605578


## Zuluftfeuchte
WGR_kal['Außenluft_WG']                  = psy.Hum_rat2(WGR_kal['L_Aussenlufttemperatur_1_korr'],  WGR_kal['W_Luftfeuchtigkeit_korr']/100,        WGR_kal['W_Luftdruck'])
## Fortluftfeuchte
WGR_kal['Abluft_WG']                     = psy.Hum_rat2(WGR_kal['L_Ablufttemperatur_korr'],        WGR_kal['L_Duschen_Ablufttfeuchte_korr']/100,  WGR_kal['W_Luftdruck'])
WGR_kal['Fortluft_relF']                 = psy.Rel_hum2(WGR_kal['L_Fortlufttemperatur_korr'],      WGR_kal['Abluft_WG']*100,                      WGR_kal['W_Luftdruck'])
## Kalibrierung gegen Testo
# WGR_kal['Fortluft_relF_korr']            = WGR_kal['Fortluft_relF'] * 1.1068598214352194 + 15.022176484002609

## Kalibrierung gegen sich selbst
WGR_kal['Fortluft_relF_korr']            = WGR_kal['Fortluft_relF'] * 0.9097473445331166 + 21.584933586922048


## Gewicht der Luft in kg/m³
WGR_kal['Außenluft_Masse']               = psy.Dry_Air_Density(WGR_kal['W_Luftdruck'], WGR_kal['L_Zulufttemperatur'], WGR_kal['Außenluft_WG']) * (1 + WGR_kal['Außenluft_WG'])

## abgegebene Energie des Nacherhitzers in kWh
WGR_kal['Nacherhitzer_Energie']          = energie(WGR_kal['L_Nacherhitzer_VL'], WGR_kal['L_Nacherhitzer_RL'], WGR_kal['S_Heizung_Vpunkt'])
# WGR_kal['Nacherhitzer_Energie']          = energie(WGR_kal['S_Heizung_VL'], WGR_kal['S_Heizung_RL'], WGR_kal['S_Heizung_Vpunkt'])

## 2 Enthalpie der Luft nach dem Nacherhitzer in kJ/kg
WGR_kal['Zuluft_nach_NE_h']              = psy.Enthalpy_Air_H2O(WGR_kal['L_Zulufttemperatur'],    WGR_kal['Außenluft_WG'])

## 3 Energie der Luft nach dem Nacherhitzer in kWh
WGR_kal['Zuluft_nach_NE_Energie']        = WGR_kal['Zuluft_nach_NE_h'] *  WGR_kal['Außenluft_Masse'] * WGR_kal['L_Zuluft_VPunkt'] * (1/3600) ## kJ in kWh

## 4 Energie der Luft vor dem Nacherhitzer in kWh
WGR_kal['Zuluft_vor_NE_Energie']         = WGR_kal['Zuluft_nach_NE_Energie'] - WGR_kal['Nacherhitzer_Energie']

## 5 Enthalpie der Luft vor dem Nacherhitzer in kJ/kg 
WGR_kal['Zuluft_vor_NE_h']               = WGR_kal['Zuluft_vor_NE_Energie'] / (WGR_kal['Außenluft_Masse'] * WGR_kal['L_Zuluft_VPunkt'] * (1/3600) ) 

## 6 Temperatur der Luft vor dem Nacherhitzer 
WGR_kal['Zuluft_vor_NE_C']               = 500 * (WGR_kal['Zuluft_vor_NE_h'] - 2510 * WGR_kal['Außenluft_WG'])  /  (930 * WGR_kal['Außenluft_WG'] + 503)
WGR_kal['Zuluft_vor_NE_C_rol']           = WGR_kal['Zuluft_vor_NE_C'].rolling(50, center=True, min_periods=1).mean()  
## Kalibrierung gegen Testo
# WGR_kal['Zuluft_vor_NE_C_kal']           = WGR_kal['Zuluft_vor_NE_C_rol'] * 0.5451990647591651 + 6.21643968818451

## Kalibrierung gegen sich selbst
WGR_kal['Zuluft_vor_NE_C_kal']           = WGR_kal['Zuluft_vor_NE_C_rol'] * 0.5400708260425677 + 6.32626784800344


## Zuluftfeuchte
WGR_kal['Zuluft_relF']                   = psy.Rel_hum2(WGR_kal['Zuluft_vor_NE_C_kal'], WGR_kal['Außenluft_WG']*100, WGR_kal['W_Luftdruck'])
## Kalibrierung gegen Testo
# WGR_kal['Zuluft_relF_korr']              = WGR_kal['Zuluft_relF'] * 1.7409299757824528 + -1.8069762484038947
## Kalibrierung gegen sich selbst
WGR_kal['Zuluft_relF_korr']              = WGR_kal['Zuluft_relF'] * 1.5250106200211264 + 7.00765048600429

## Kalibrierungswerte aus http://localhost:8888/notebooks/WRG/Lueftung_kalibrieren_11.ipynb
## Kalibrierung gegen sich selbst
# WGR_kal['L_Aussenlufttemperatur_1']  = WGR_kal['L_Aussenlufttemperatur_1'] * 1.0662108187573032 + -0.5309722751765433
# WGR_kal['L_Ablufttemperatur']        = WGR_kal['L_Ablufttemperatur'] * 0.6360939326833698 + 6.952747187665505
# WGR_kal['L_Fortlufttemperatur']      = WGR_kal['L_Fortlufttemperatur'] * 0.8885155788864784 + 1.3007615291616732
# WGR_kal['W_Luftfeuchtigkeit']        = WGR_kal['W_Luftfeuchtigkeit'] * 0.497955695370158 + 21.232584095701597
# WGR_kal['L_Duschen_Ablufttfeuchte']  = WGR_kal['L_Duschen_Ablufttfeuchte'] * 0.753384388346958 + 8.212720855605578
# WGR_kal['Fortluft_relF']             = WGR_kal['Fortluft_relF'] * 0.9097473445331166 + 21.584933586922048
# WGR_kal['Zuluft_vor_NE_C_rol']       = WGR_kal['Zuluft_vor_NE_C_rol'] * 0.5400708260425677 + 6.32626784800344
# WGR_kal['Zuluft_relF']               = WGR_kal['Zuluft_relF'] * 1.5250106200211264 + 7.00765048600429


## Kalibrierung gegen Testo
# WGR_kal['L_Aussenlufttemperatur_1']  = WGR_kal['L_Aussenlufttemperatur_1'] * 0.9484142817603088 + 1.3850418938877918
# WGR_kal['L_Ablufttemperatur']        = WGR_kal['L_Ablufttemperatur'] * 0.6230286392802793 + 7.2158386479613945
# WGR_kal['L_Fortlufttemperatur']      = WGR_kal['L_Fortlufttemperatur'] * 0.9210001407556405 + 0.6246083693217548
# WGR_kal['W_Luftfeuchtigkeit']        = WGR_kal['W_Luftfeuchtigkeit'] * 0.6222764631729626 + 19.995788042129863
# WGR_kal['L_Duschen_Ablufttfeuchte']  = WGR_kal['L_Duschen_Ablufttfeuchte'] * 0.9087940037415406 + 1.7023841729299454
# WGR_kal['Fortluft_relF']             = WGR_kal['Fortluft_relF'] * 1.1068598214352194 + 15.022176484002609
# WGR_kal['Zuluft_vor_NE_C_rol']       = WGR_kal['Zuluft_vor_NE_C_rol'] * 0.5451990647591651 + 6.21643968818451
# WGR_kal['Zuluft_relF']               = WGR_kal['Zuluft_relF'] * 1.7409299757824528 + -1.8069762484038947

Plots

kal_von = "2018-02-01 12:00:00"
kal_bis = "2018-02-11 19:59:00"

Zuluft vor dem Nacherhitzer

fig, ax = plt.subplots() 
WGR_kal['Zuluft_vor_NE_C'].plot(ax=ax,color=colo('violet',1), linewidth=1, label = 'Zulufttemperatur_berechnet')  
WGR_kal['Zuluft_vor_NE_C_rol'].plot(ax=ax,color=colo('violet',1.5), linewidth=1, label = 'Zulufttemperatur_berechnet_rol')  
WGR_kal['Zuluft_vor_NE_C_kal'].plot(ax=ax,color=colo('violet',2.9), linewidth=1, label = 'Zulufttemperatur_berechnet_kal')      
# WGR_kal['Zuluft_C'].plot(ax=ax,color=colo('grau',1.5), linewidth=.5, label = 'Zulufttemperatur_Testo')      
ax.set_ylabel(r'\textbf{Temperatur}')  
ax.set_xlabel('')   
ax.set_ylim(-10,35)  
h0, l0 = ax.get_legend_handles_labels() 
legend = plt.legend(h0, l0, ncol=2, loc=1)
set_legend_linewidth(legend) 
ax.set(xlim=[pd.to_datetime(kal_von),pd.to_datetime(kal_bis)])  
[(736726.5, 736736.8326388889)]

rel. LF

fig, axes = plt.subplots(nrows=4, ncols=1, sharex=True , constrained_layout=False,figsize=(5.8,8.05)) 

axes[0].plot(WGR_kal['W_Luftfeuchtigkeit'],color=colo('orange',1),  linewidth=0.8,  label='gemessen')
axes[0].plot(WGR_kal['W_Luftfeuchtigkeit_korr'],color=colo('grün',1),  linewidth=0.8,  label='korrigiert') 
# axes[0].plot(WGR_kal['Außenluft_rF'],color=colo('blau',1),  linewidth=0.8,  label='Testo') 
axes[0].set(ylabel=r"\textbf{Außenluft}") 
axes[0].set_ylim(20,100)  

axes[1].plot(WGR_kal['Zuluft_relF'],color=colo('orange',1),  linewidth=0.8,  label='gemessen')
axes[1].plot(WGR_kal['Zuluft_relF_korr'],color=colo('grün',1),  linewidth=0.8,  label='korrigiert') 
# axes[1].plot(WGR_kal['Zuluft_rF'],color=colo('blau',1),  linewidth=0.8,  label='Testo') 
axes[1].set(ylabel=r"\textbf{Zuluft}") 
axes[1].set_ylim(20,100)  

axes[2].plot(WGR_kal['L_Duschen_Ablufttfeuchte'],color=colo('orange',1),  linewidth=0.8,  label='gemessen')
axes[2].plot(WGR_kal['L_Duschen_Ablufttfeuchte_korr'],color=colo('grün',1),  linewidth=0.8,  label='korrigiert') 
# axes[2].plot(WGR_kal['Abluft_rF'],color=colo('blau',1),  linewidth=0.8,  label='Testo') 
axes[2].set(ylabel=r"\textbf{Abluft}") 
axes[2].set_ylim(20,100)  

axes[3].plot(WGR_kal['Fortluft_relF'],color=colo('orange',1),  linewidth=0.8,  label='gemessen')
axes[3].plot(WGR_kal['Fortluft_relF_korr'],color=colo('grün',1),  linewidth=0.8,  label='korrigiert') 
# axes[3].plot(WGR_kal['Fortluft_rF'],color=colo('blau',1),  linewidth=0.8,  label='Testo') 
axes[3].set(ylabel=r"\textbf{Fortluft}") 
axes[3].set_ylim(20,100)  

axes[0].set_title('rel. Luftfeuchtigkeit')
axes[0].set(xlim=[pd.to_datetime(kal_von),pd.to_datetime(kal_bis)]) 
axes[0].xaxis.set_major_formatter(mdates.DateFormatter('%D')) 

fig.autofmt_xdate(rotation=0,ha='center')
for ax in axes:
    ax.legend( ncol=6, loc=1,  bbox_to_anchor=(1., 1)) 
    ax.yaxis.get_label().set_fontsize(8)
plt.subplots_adjust(hspace=.1)  
plt.show()

Temperatur

fig, axes = plt.subplots(nrows=4, ncols=1, sharex=True , constrained_layout=False,figsize=(5.8,8.05)) 

axes[0].plot(WGR_kal['L_Aussenlufttemperatur_1'], color=colo('orange',1),  linewidth=0.8,  label='gemessen')
axes[0].plot(WGR_kal['L_Aussenlufttemperatur_1_korr'],color=colo('grün',1),  linewidth=0.8,  label='korrigiert') 
# axes[0].plot(WGR_kal['Außenluft_C'],color=colo('blau',1),  linewidth=0.8,  label='Testo') 
axes[0].set(ylabel=r"\textbf{Außenluft}") 
axes[0].set_ylim(-5,10)  

axes[1].plot(WGR_kal['L_Zulufttemperatur'],color=colo('orange',1),  linewidth=0.8,  label='gemessen')
axes[1].plot(WGR_kal['Zuluft_vor_NE_C_kal'],color=colo('grün',1),  linewidth=0.8,  label='korrigiert') 
# axes[1].plot(WGR_kal['Zuluft_C'],color=colo('blau',1),  linewidth=0.8,  label='Testo') 
axes[1].set(ylabel=r"\textbf{Zuluft}") 
axes[1].set_ylim(10,35)  

axes[2].plot(WGR_kal['L_Ablufttemperatur'],color=colo('orange',1),  linewidth=0.8,  label='gemessen')
axes[2].plot(WGR_kal['L_Ablufttemperatur_korr'],color=colo('grün',1),  linewidth=0.8,  label='korrigiert') 
# axes[2].plot(WGR_kal['Abluft_C'],color=colo('blau',1),  linewidth=0.8,  label='Testo') 
axes[2].set(ylabel=r"\textbf{Abluft}") 
axes[2].set_ylim(15,25)  

axes[3].plot(WGR_kal['L_Fortlufttemperatur'],color=colo('orange',1),  linewidth=0.8,  label='gemessen')
axes[3].plot(WGR_kal['L_Fortlufttemperatur_korr'],color=colo('grün',1),  linewidth=0.8,  label='korrigiert') 
# axes[3].plot(WGR_kal['Fortluft_C'],color=colo('blau',1),  linewidth=0.8,  label='Testo') 
axes[3].set(ylabel=r"\textbf{Fortluft}") 
axes[3].set_ylim(5,15)  

axes[0].set_title('Temperatur')
axes[0].set(xlim=[pd.to_datetime(kal_von),pd.to_datetime(kal_bis)]) 
axes[0].xaxis.set_major_formatter(mdates.DateFormatter('%D')) 

fig.autofmt_xdate(rotation=0,ha='center')
for ax in axes:
    ax.legend( ncol=6, loc=1,  bbox_to_anchor=(1., 1)) 
    ax.yaxis.get_label().set_fontsize(8)
plt.subplots_adjust(hspace=.1)  
plt.show()  


Zuweisungen

# print_md('Mittelwerte und Standardabweichungen VOR der Kalibrierung')
# print('Außenluft C  '+str(daten_sub['Außenluft_C'].mean()) +' std ' + str(daten_sub['Außenluft_C'].std()) )
# print('Zuluft C    '+str(daten_sub['Zuluft_C'].mean())     +'  std ' + str(daten_sub['Zuluft_C'].std()) )
# print('Abluft C    '+str(daten_sub['Abluft_C'].mean())     +'   std ' + str(daten_sub['Abluft_C'].std()) )
# print('Fortluft C   '+str(daten_sub['Fortluft_C'].mean())  +'  std ' + str(daten_sub['Fortluft_C'].std()) )
# print('')
# print('Außenluft F '+str(daten_sub['Außenluft_rF'].mean()) +'    std ' + str(daten_sub['Außenluft_rF'].std()) )
# print('Zuluft F    '+str(daten_sub['Zuluft_rF'].mean())    +'   std ' + str(daten_sub['Zuluft_rF'].std()) )
# print('Abluft F    '+str(daten_sub['Abluft_rF'].mean())    +'  std ' + str(daten_sub['Abluft_rF'].std()) )
# print('Fortluft F  '+str(daten_sub['Fortluft_rF'].mean())  +'   std ' + str(daten_sub['Fortluft_rF'].std()) )
# print('')
def zuweisungen():
    global daten_sub 
    ## Zuweisung der kalibrierten Werte 
    daten_sub['Außenluft_C']  = WGR_kal['L_Aussenlufttemperatur_1_korr']
    daten_sub['Zuluft_C']     = WGR_kal['Zuluft_vor_NE_C_kal']    
    daten_sub['Abluft_C']     = WGR_kal['L_Ablufttemperatur_korr']   
    daten_sub['Fortluft_C']   = WGR_kal['L_Fortlufttemperatur_korr']

    daten_sub['Außenluft_rF'] = WGR_kal['W_Luftfeuchtigkeit_korr']
    daten_sub['Zuluft_rF']    = WGR_kal['Zuluft_relF_korr']
    daten_sub['Abluft_rF']    = WGR_kal['L_Duschen_Ablufttfeuchte_korr']
    daten_sub['Fortluft_rF']  = WGR_kal['Fortluft_relF_korr']
    ## Zuweisung der kalibrierten Werte 
zuweisungen()
print_md('Mittelwerte und Standardabweichungen NACH der Kalibrierung')
print('Außenluft C  '+str(daten_sub['Außenluft_C'].mean()) +' std ' + str(daten_sub['Außenluft_C'].std()) ) 
print('Zuluft C    '+str(daten_sub['Zuluft_C'].mean())     +'   std ' + str(daten_sub['Zuluft_C'].std()) ) 
print('Abluft C    '+str(daten_sub['Abluft_C'].mean())     +'    std ' + str(daten_sub['Abluft_C'].std()) ) 
print('Fortluft C   '+str(daten_sub['Fortluft_C'].mean())  +'  std ' + str(daten_sub['Fortluft_C'].std()) )
print('')
print('Außenluft F '+str(daten_sub['Außenluft_rF'].mean()) +'   std ' + str(daten_sub['Außenluft_rF'].std()) ) 
print('Zuluft F    '+str(daten_sub['Zuluft_rF'].mean())    +'   std ' + str(daten_sub['Zuluft_rF'].std()) ) 
print('Abluft F    '+str(daten_sub['Abluft_rF'].mean())    +'  std ' + str(daten_sub['Abluft_rF'].std()) ) 
print('Fortluft F  '+str(daten_sub['Fortluft_rF'].mean())  +'   std ' + str(daten_sub['Fortluft_rF'].std()) ) 
#Mittelwerte und Standardabweichungen NACH der Kalibrierung

Mittelwerte und Standardabweichungen NACH der Kalibrierung

Außenluft C  16.150723225157897 std 12.487777657801631
Zuluft C    18.179380405448505   std 3.4219773497691612
Abluft C    22.015837119428785    std 3.1168901247157943
Fortluft C   17.802910280139663  std 6.728776829123577

Außenluft F 60.59302858172845   std 8.67919134579323
Zuluft F    44.23161385848683   std 7.090091765820183
Abluft F    37.50630371587165  std 7.759169347463126
Fortluft F  45.15829730985226   std 6.2060387225596765

Effizienz berechnen

## findet Werte (x) zwischen low und high mit der länge thresh
def sequence(x, low, high, thresh):
    ind                 = np.flatnonzero(np.diff(np.r_[False, ((x >= low) & (x <= high)), False]))
    start               = ind[::2]
    end                 = ind[1::2]
    mask                = end - start >= thresh
    result              = np.zeros(x.size, dtype=np.int8)
    result[start[mask]] = + 1
    mask[-1]            = False
    result[end[mask]]   = - 1
    return np.cumsum(result, out=result).view(bool) 

def effizienz(by=0, außen_C=0, zu_C=0, ab_C=0, fort_C=0, außen_rF=0, zu_rf=0, ab_rF=0, fort_rf=0, zu_Vp=0):
    by = (45+by)/100
    global daten_sub  
    zuweisungen()
    ## Schwellenwerte im Zuluftdruck für Bypass
    schwelle_oben  = 1000
    schwelle_unten = 85.5
    ## Anteil an Luft durch den Bypass:
    Anteil_Bypass  = by

    ## MIN MAX
    daten_sub['Außenluft_C']     = daten_sub['Außenluft_C']      + außen_C
    daten_sub['Zuluft_C']        = daten_sub['Zuluft_C']         + zu_C
    daten_sub['Abluft_C']        = daten_sub['Abluft_C']         + ab_C
    daten_sub['Fortluft_C']      = daten_sub['Fortluft_C']       + fort_C
    daten_sub['Außenluft_rF']    = daten_sub['Außenluft_rF']     + außen_rF
    daten_sub['Zuluft_rF']       = daten_sub['Zuluft_rF']        + zu_rf
    daten_sub['Abluft_rF']       = daten_sub['Abluft_rF']        + ab_rF
    daten_sub['Fortluft_rF']     = daten_sub['Fortluft_rF']      + fort_rf
    daten_sub['L_Zuluft_VPunkt'] = daten_sub['L_Zuluft_VPunkt']  * (1+zu_Vp/100) 

    ## abgegebene Energie des Nacherhitzers in kWh
    daten_sub['Nacherhitzer_Energie']          = energie(daten_sub['L_Nacherhitzer_VL'], daten_sub['L_Nacherhitzer_RL'], daten_sub['S_Heizung_Vpunkt'])
#     daten_sub['Nacherhitzer_Energie']          = energie(daten_sub['S_Heizung_VL'], daten_sub['S_Heizung_RL'], daten_sub['S_Heizung_Vpunkt'])


    ## Wassergehalte (WG) in den  Luftströmen daten
    daten_sub['Außenluft_WG']         = psy.Hum_rat2(daten_sub['Außenluft_C'],     daten_sub['Außenluft_rF'] /100,   daten_sub['W_Luftdruck'])
    daten_sub['Zuluft_WG']            = psy.Hum_rat2(daten_sub['Zuluft_C'],        daten_sub['Zuluft_rF']    /100,   daten_sub['W_Luftdruck'])
    daten_sub['Abluft_WG']            = psy.Hum_rat2(daten_sub['Abluft_C'],        daten_sub['Abluft_rF']    /100,   daten_sub['W_Luftdruck'])
    daten_sub['Fortluft_WG']          = psy.Hum_rat2(daten_sub['Fortluft_C'],      daten_sub['Fortluft_rF']  /100,   daten_sub['W_Luftdruck']) 
#     daten_sub['Zuluft_WG']            = daten_sub['Außenluft_WG'] 

    ## Enthalpien in den  Luftströmen daten
    daten_sub['h21_Außenluft']        = psy.Enthalpy_Air_H2O(daten_sub['Außenluft_C'], daten_sub['Außenluft_WG'])
    daten_sub['h22_Zuluft']           = psy.Enthalpy_Air_H2O(daten_sub['Zuluft_C'],    daten_sub['Zuluft_WG'])
    daten_sub['h11_Abluft']           = psy.Enthalpy_Air_H2O(daten_sub['Abluft_C'],    daten_sub['Abluft_WG'])
    daten_sub['h12_Fortluft']         = psy.Enthalpy_Air_H2O(daten_sub['Fortluft_C'],  daten_sub['Fortluft_WG'])

    ## Enthalpien im Bypassbetrieb
    daten_sub['h21_Außenluft_by']     = daten_sub['h21_Außenluft'] * (1-Anteil_Bypass) + daten_sub['h11_Abluft'] * Anteil_Bypass 
    daten_sub['h21_Außenluft_bypass'] = np.where((daten_sub['L_Zuluft_Druck'] < schwelle_oben) & (daten_sub['L_Zuluft_Druck'] > schwelle_unten),  daten_sub['h21_Außenluft'],  daten_sub['h21_Außenluft_by'])
    daten_sub['h21_Außenluft_pure']   = daten_sub['h21_Außenluft']

    ## Effizienz der Wärmerückgewinnung
    daten_sub['EÜG_Außenluft_vorl']   = (daten_sub['h22_Zuluft'] - daten_sub['h21_Außenluft_bypass']) / (daten_sub['h11_Abluft'] - daten_sub['h21_Außenluft_bypass']) * 100
    daten_sub['EÜG_Fortluft_vorl']    = (daten_sub['h11_Abluft'] - daten_sub['h12_Fortluft'])         / (daten_sub['h11_Abluft'] - daten_sub['h21_Außenluft_bypass']) * 100
    ## EÜG bereinigen
    daten_sub['zähler']               = daten_sub['h22_Zuluft'] - daten_sub['h21_Außenluft_bypass']
    daten_sub['nenner']               = daten_sub['h11_Abluft'] - daten_sub['h21_Außenluft_bypass']
    daten_sub['EÜG_Außenluft_vorl']   = np.where(daten_sub['S_Heizung_Vpunkt']               > 50.0,                     daten_sub['EÜG_Außenluft_vorl'],     np.NaN)
    daten_sub['EÜG_Außenluft_vorl']   = np.where(daten_sub['Außenluft_C']                    < daten_sub['Abluft_C'],    daten_sub['EÜG_Außenluft_vorl'],     np.NaN)
    daten_sub['EÜG_Außenluft_vorl']   = np.where(daten_sub['h21_Außenluft']                  < daten_sub['h11_Abluft'],  daten_sub['EÜG_Außenluft_vorl'],     np.NaN)
    daten_sub['EÜG_Außenluft_vorl']   = np.where(daten_sub['zähler']                         > 0,                        daten_sub['EÜG_Außenluft_vorl'],     np.NaN)
    daten_sub['EÜG_Außenluft_vorl']   = np.where(daten_sub['nenner']                         > 1,                        daten_sub['EÜG_Außenluft_vorl'],     np.NaN)
    daten_sub['EÜG_Außenluft_vorl']   = np.where((daten_sub['nenner'] - daten_sub['zähler']) > 1,                        daten_sub['EÜG_Außenluft_vorl'],     np.NaN) 


    ## Rückwärmezahl 
    daten_sub['RWZ_Außenluft_vorl']   = (daten_sub['Zuluft_C']   - daten_sub['Außenluft_C'])   / (daten_sub['Abluft_C'] - daten_sub['Außenluft_C']) * 100 
#     daten_sub['RWZ_Außenluft_vorl']   = np.where(daten_sub['EÜG_Außenluft_vorl'] == np.NaN,                        daten_sub['RWZ_Außenluft_vorl'],     np.NaN) 
    daten_sub['zähler_RWZ']           = daten_sub['Zuluft_C'] - daten_sub['Außenluft_C']
    daten_sub['nenner_RWZ']           = daten_sub['Abluft_C'] - daten_sub['Außenluft_C']
    daten_sub['RWZ_Außenluft_vorl']   = np.where(daten_sub['S_Heizung_Vpunkt']                   > 50.0,                     daten_sub['RWZ_Außenluft_vorl'],     np.NaN)
    daten_sub['RWZ_Außenluft_vorl']   = np.where(daten_sub['Außenluft_C']                        < daten_sub['Abluft_C'],    daten_sub['RWZ_Außenluft_vorl'],     np.NaN)
    daten_sub['RWZ_Außenluft_vorl']   = np.where(daten_sub['Außenluft_C']                        < daten_sub['Abluft_C'],    daten_sub['RWZ_Außenluft_vorl'],     np.NaN)
    daten_sub['RWZ_Außenluft_vorl']   = np.where(daten_sub['zähler_RWZ']                         > 0,                        daten_sub['RWZ_Außenluft_vorl'],     np.NaN)
    daten_sub['RWZ_Außenluft_vorl']   = np.where(daten_sub['nenner_RWZ']                         > 1,                        daten_sub['RWZ_Außenluft_vorl'],     np.NaN)
    daten_sub['RWZ_Außenluft_vorl']   = np.where((daten_sub['nenner'] - daten_sub['zähler'])     > 1,                        daten_sub['RWZ_Außenluft_vorl'],     np.NaN) 

    daten_sub['RWZ_Fortluft_vorl']    = (daten_sub['Abluft_C']   - daten_sub['Fortluft_C'])    / (daten_sub['Abluft_C'] - daten_sub['Außenluft_C']) * 100 

    ## Gewicht der feuchten Luft
    daten_sub['Außenluft_Masse']      = psy.Dry_Air_Density(daten_sub['W_Luftdruck'], daten_sub['Außenluft_C'], daten_sub['Außenluft_WG']) * (1 + daten_sub['Außenluft_WG'])
    daten_sub['Zuluft_Masse']         = psy.Dry_Air_Density(daten_sub['W_Luftdruck'], daten_sub['Zuluft_C'],    daten_sub['Zuluft_WG'])    * (1 + daten_sub['Zuluft_WG'])
    daten_sub['Abluft_Masse']         = psy.Dry_Air_Density(daten_sub['W_Luftdruck'], daten_sub['Abluft_C'],    daten_sub['Abluft_WG'])    * (1 + daten_sub['Abluft_WG'])
    daten_sub['Fortluft_Masse']       = psy.Dry_Air_Density(daten_sub['W_Luftdruck'], daten_sub['Fortluft_C'],  daten_sub['Fortluft_WG'])  * (1 + daten_sub['Fortluft_WG'])  

    ## Luftströme definieren, für die Unterscheidung des Bypass Betriebes
    daten_sub['Vpunkt_intern']        = daten_sub['L_Zuluft_VPunkt']
    daten_sub['Vpunkt_extern']        = daten_sub['L_Zuluft_VPunkt']

    ## Luftstrom im Bypassfall
    daten_sub['Vpunkt_extern']        = daten_sub['L_Zuluft_VPunkt'] * (1-Anteil_Bypass) 
    daten_sub['Vpunkt_extern']        = np.where((daten_sub['L_Zuluft_Druck'] < schwelle_oben) & (daten_sub['L_Zuluft_Druck'] > schwelle_unten),  daten_sub['L_Zuluft_VPunkt'],  daten_sub['Vpunkt_extern'])


    ## Energie der Luftmassenströme
    daten_sub['Außenluft_Energie']    = daten_sub['h21_Außenluft_pure']    *  daten_sub['Außenluft_Masse'] * daten_sub['Vpunkt_extern'] * (1/3600) ## kJ in kWh
    daten_sub['Zuluft_Energie']       = daten_sub['h22_Zuluft']            *  daten_sub['Zuluft_Masse']    * daten_sub['Vpunkt_intern'] * (1/3600) ## kJ in kWh
    daten_sub['Abluft_Energie']       = daten_sub['h11_Abluft']            *  daten_sub['Abluft_Masse']    * daten_sub['Vpunkt_intern'] * (1/3600) ## kJ in kWh
    daten_sub['Fortluft_Energie']     = daten_sub['h12_Fortluft']          *  daten_sub['Fortluft_Masse']  * daten_sub['Vpunkt_extern'] * (1/3600) ## kJ in kWh

    daten_sub['verlorene_Energie']        = daten_sub['Außenluft_Energie']     +  daten_sub['Zuluft_Energie']  - daten_sub['Abluft_Energie'] - daten_sub['Fortluft_Energie']
    daten_sub['verlorene_Energie_A+Z']    = daten_sub['Außenluft_Energie']     +  daten_sub['Zuluft_Energie']  
    daten_sub['verlorene_Energie_A+F']    = daten_sub['Abluft_Energie']        +  daten_sub['Fortluft_Energie']
    daten_sub['verlorene_Energie_A-F']    = daten_sub['Außenluft_Energie']     -  daten_sub['Fortluft_Energie']


    ## Schwellen wann die WRG zu 100% läuft, Bypass ist zu
    daten_sub['between_p']            = sequence(daten_sub['L_Zuluft_Druck'], schwelle_unten, schwelle_oben, 1000) 
    daten_sub['EÜG_Außenluft']        = np.where(daten_sub['between_p'] ==  True ,daten_sub['EÜG_Außenluft_vorl'] ,np.NaN)
    daten_sub['between_p']            = sequence(daten_sub['L_Zuluft_Druck'], schwelle_unten, schwelle_oben, 1000) 
    daten_sub['RWZ_Außenluft']        = np.where(daten_sub['between_p'] ==  True ,daten_sub['RWZ_Außenluft_vorl'] ,np.NaN) 
    daten_sub['between_p']            = sequence(daten_sub['L_Zuluft_Druck'], schwelle_unten, schwelle_oben, 1000) 
    daten_sub['EÜG_Fortluft']         = np.where(daten_sub['between_p'] ==  True ,daten_sub['EÜG_Fortluft_vorl'] ,np.NaN)
    daten_sub['between_p']            = sequence(daten_sub['L_Zuluft_Druck'], schwelle_unten, schwelle_oben, 1000) 
    daten_sub['RWZ_Fortluft']         = np.where(daten_sub['between_p'] ==  True ,daten_sub['RWZ_Fortluft_vorl'] ,np.NaN) 
    ## Mittelwerte 
    daten_sub['EÜG_Außenluft_mean']   = daten_sub['EÜG_Außenluft'].mean()
    daten_sub['RWZ_Außenluft_mean']   = daten_sub['RWZ_Außenluft'].mean()
    daten_sub['EÜG_Fortluft_mean']    = daten_sub['EÜG_Fortluft'].mean()
    daten_sub['RWZ_Fortluft_mean']    = daten_sub['RWZ_Fortluft'].mean()

# effizienz()    

Fehlersuche _alt

# test                         = daten_sub.resample("15min").mean().copy()#.loc['2017-06-10 21:14:00': '2017-06-10 21:16:00'].copy()
# test['zähler']          = test['h22_Zuluft'] - test['h21_Außenluft_bypass']
# test['nenner']          = test['h11_Abluft'] - test['h21_Außenluft_bypass']
# test['EÜG_Außenluft']   = np.where(test['S_Heizung_Vpunkt']          > 50.0,                test['EÜG_Außenluft'],     np.NaN)
# test['EÜG_Außenluft']   = np.where(test['Außenluft_C']               < test['Abluft_C'],    test['EÜG_Außenluft'],     np.NaN)
# test['EÜG_Außenluft']   = np.where(test['h21_Außenluft']             < test['h11_Abluft'],  test['EÜG_Außenluft'],     np.NaN)
# test['EÜG_Außenluft']   = np.where(test['zähler']                    > 0,                   test['EÜG_Außenluft'],     np.NaN)
# test['EÜG_Außenluft']   = np.where(test['nenner']                    > 1,                   test['EÜG_Außenluft'],     np.NaN)
# test['EÜG_Außenluft']   = np.where((test['nenner'] - test['zähler']) > 1,                   test['EÜG_Außenluft'],     np.NaN)


# ##     daten_sub['EÜG_Außenluft_vorl']   = (daten_sub['h22_Zuluft'] - daten_sub['h21_Außenluft_bypass']) / (daten_sub['h11_Abluft'] - daten_sub['h21_Außenluft_bypass']) * 100


# fig, ax = plt.subplots(figsize=(8,2)) 
# test['EÜG_Außenluft_vorl'].plot(ax=ax,color=colo('grün',1),   linewidth=.5, label = 'EÜG_Außenluft')   
# test['EÜG_Außenluft'].plot(ax=ax,color=colo('rot',1),   linewidth=.5, label = 'EÜG_Außenluft')   
# ax.set(ylim=[-150,150])
# ax.set(ylabel="Energie(kWh)", xlabel="Zeit")#,ylim=[30,100])
# ax.set_xlabel('')
# h0, l0 = ax.get_legend_handles_labels() 
# legend = plt.legend(h0, l0, ncol=4, loc=1) 
# set_legend_linewidth(legend)  
# plt.setp(ax.get_xticklabels(), rotation=0, ha="center", rotation_mode="anchor") 
# ax.get_xaxis().set_major_formatter(mdates.DateFormatter(" %b %Y")) 

# display(test[['EÜG_Außenluft_vorl','Außenluft_C','Abluft_C','S_Heizung_Vpunkt','h21_Außenluft_bypass','L_Zuluft_Druck','EÜG_Außenluft','zähler','nenner']].head())


# # test['date'] = str(test.index)  
# tools_to_show     = 'box_zoom,reset,pan,undo,redo,xzoom_out,yzoom_out,hover'   ## box_zoom,pan,save,xpan,hover,reset,undo,redo,xzoom_out,yzoom_out,xzoom_in,yzoom_in
# p                 = figure(plot_width=1200, plot_height=600,sizing_mode="scale_width",x_axis_type="datetime",title=None, toolbar_sticky=False,  tools=tools_to_show,  active_drag="box_zoom", toolbar_location="left", output_backend="canvas")

# ## linke Achse
# p.y_range=Range1d(-150,150) 
# p.line(test.index, test['EÜG_Außenluft'],           line_width=2, color=colo('orange',1),     legend_label="EÜG_Außenluft",       visible = True) 

# ## rechte Achse 
# p.extra_y_ranges = {"zwei": Range1d(start=-10, end=30)}
# p.line(test.index, test['Außenluft_C'],       line_width=2, color=colo('blau',1),     legend_label="Außenluft_C",    y_range_name="zwei",      visible = False) 
# p.line(test.index, test['Abluft_C'],          line_width=2, color=colo('rot',1),      legend_label="Abluft_C",    y_range_name="zwei",         visible = False) 
# p.line(test.index, test['Fortluft_C'],        line_width=2, color=colo('grün',1),     legend_label="Fortluft_C",    y_range_name="zwei",      visible = False) 
# p.add_layout(LinearAxis(y_range_name="zwei"), 'right')

# ## 2. rechte Achse 
# p.extra_y_ranges['drei'] = Range1d(start=0, end=100)
# p.line(test.index, test['h21_Außenluft_bypass'], line_width=2, color=colo('blau',1.4),     legend_label="h21_Außenluft_bypass",    y_range_name="drei",      visible = False) 
# p.line(test.index, test['h11_Abluft'],           line_width=2, color=colo('rot',1.4),      legend_label="h11_Abluft",              y_range_name="drei",      visible = False) 
# p.line(test.index, test['h12_Fortluft'],         line_width=2, color=colo('grün',1.4),     legend_label="h12_Fortluft",            y_range_name="drei",      visible = False) 
# p.add_layout(LinearAxis(y_range_name="drei"), 'right')

# ## 2. rechte Achse 
# p.extra_y_ranges['vier'] = Range1d(start=-20, end=30)
# p.line(test.index, test['zähler'],     line_width=2, color=colo('grau',1.),     legend_label="zähler",    y_range_name="vier",      visible = True) 
# p.line(test.index, test['nenner'],           line_width=2, color=colo('violet',1.4),      legend_label="nenner",              y_range_name="vier",      visible = True)  
# p.add_layout(LinearAxis(y_range_name="vier"), 'left')




# ## hoverBox 
# hover                 = p.select(dict(type=HoverTool)) 
# hover.tooltips        = [("", "@y{0.0}")]  
# hover.mode            = 'vline'   
# p.legend.location     = "top_right"
# p.legend.click_policy = "hide"
# p.add_tools(BoxSelectTool(dimensions="width")) 
# p.xaxis.formatter=DatetimeTickFormatter(hours=["%d.%m. %H:%M"],days=["%d.%m. %H:%M"],months=["%d. %m. %Y"],years=["%d. %m. %Y"],)
# p.xaxis.axis_label_text_font_size  = "10pt"
# p.xaxis.major_label_text_font_size = "10pt"
# p.yaxis.axis_label_text_font_size  = "10pt"
# p.yaxis.major_label_text_font_size = "10pt"
# output_file('Effizinz.html')
# show(p)

Effizienz_plot

def effizienz_plot(title="Effizienz"):
    global daten_sub 
    fig, ax = plt.subplots(figsize=(8,2))
#     ax.fill_between(daten_sub.index, 0, 1, where=daten_sub['between_p']==1, color=colo('grau',1), alpha=1, transform=ax.get_xaxis_transform())

    # EÜG in Druckintervall
    daten_sub['RWZ_Außenluft_vorl'].plot(ax=ax,color=colo('blau',1),   linewidth=.5, label = 'RWZ_Außenluft') 
    daten_sub['EÜG_Außenluft_vorl'].plot(ax=ax,color=colo('grün',1),   linewidth=.5, label = 'EÜG_Außenluft')  
    daten_sub['Außenluft_C'].plot(ax=ax,color=colo('rot',1),           linewidth=.5, label = 'Außenluft_C') 
#     daten_sub['EÜG_Fortluft_vorl'].plot(ax=ax,color=colo('rot',1),     linewidth=.5, label = 'EÜG_Fortluft')  
#     daten_sub['RWZ_Fortluft_vorl'].plot(ax=ax,color=colo('orange',1),  linewidth=.5, label = 'RWZ_Fortluft') 
    # EÜG, EÜG fett, EÜG Durchschnitt
    daten_sub['EÜG_Außenluft'].plot(ax=ax,color=colo('grün',.1),    linewidth=1, label = '__nolable__')  
    daten_sub['RWZ_Außenluft'].plot(ax=ax,color=colo('blau',.1),    linewidth=1, label = '__nolable__') 
#     daten_sub['EÜG_Fortluft'].plot(ax=ax,color=colo('rot',.1),      linewidth=1, label = '__nolable__')  
#     daten_sub['RWZ_Fortluft'].plot(ax=ax,color=colo('orange',.1),   linewidth=1, label = '__nolable__') 
#     # EÜG Durchschnitt
    daten_sub['EÜG_Außenluft_mean'].plot(ax=ax,color=colo('grün',1.5),   linewidth=0.8, label = '__nolable__')  
    daten_sub['RWZ_Außenluft_mean'].plot(ax=ax,color=colo('blau',1.5),   linewidth=0.8, label = '__nolable__') 
#     daten_sub['EÜG_Fortluft_mean'].plot(ax=ax,color=colo('rot',1.5),     linewidth=0.8, label = '__nolable__')  
#     daten_sub['RWZ_Fortluft_mean'].plot(ax=ax,color=colo('orange',1.5),  linewidth=0.8, label = '__nolable__') 

    ax.text(0.05,  0.06, 'EÜG Außen: '+str(int(daten_sub['EÜG_Außenluft_mean'].mean()))+' \%', color=colo('grün',.8),   transform=ax.transAxes, fontsize=10, bbox=dict(facecolor='white', alpha=1)) 
    ax.text(0.3,   0.06, 'RWZ Außen: '+str(int(daten_sub['RWZ_Außenluft_mean'].mean()))+' \%', color=colo('blau',.8),   transform=ax.transAxes, fontsize=10, bbox=dict(facecolor='white', alpha=1)) 
#     ax.text(0.55,  0.06, 'EÜG Fort:  '+str(int(daten_sub['EÜG_Fortluft_mean'].mean()))+' \%',  color=colo('rot',.8),    transform=ax.transAxes, fontsize=10, bbox=dict(facecolor='white', alpha=1)) 
#     ax.text(0.8,   0.06, 'RWZ Fort:  '+str(int(daten_sub['RWZ_Fortluft_mean'].mean()))+' \%',  color=colo('orange',.8), transform=ax.transAxes, fontsize=10, bbox=dict(facecolor='white', alpha=1)) 

#     ax.set(xlim=[pd.to_datetime("2018-01-31 00:00:00"),pd.to_datetime("2018-02-12 11:00:00")])
#     ax.set(xlim=[pd.to_datetime("2017-06-10 21:14:00"),pd.to_datetime("2017-06-10 21:15:45")])
    ax.set(ylabel="Energie(kWh)", xlabel="Zeit")#,ylim=[30,100])
    ax.set_xlabel('')
    h0, l0 = ax.get_legend_handles_labels() 
    legend = plt.legend(h0, l0, ncol=4, loc=1) 
    set_legend_linewidth(legend) 
    plt.title('Effizienz '+title)
#     plt.xticks(rotation=0)
#     ax.xaxis.set_tick_params(rotation=0)
    plt.setp(ax.get_xticklabels(), rotation=0, ha="center", rotation_mode="anchor")
    ax.set(ylim=[0,120])
#    ax.get_xaxis().set_major_formatter(mdates.DateFormatter("%d.%m. %H:%M")) 
    ax.get_xaxis().set_major_formatter(mdates.DateFormatter(" %H:%M")) 
    # plt.savefig(output_folder + '/' + file_name + '_' +title + '.pdf') 
    plt.show()

# effizienz_plot()

Effizienz bax Plot

def effizienz_bax(title):
    global daten_sub
    fig = plt.figure(constrained_layout=False, figsize=(6.9,2))
    bax = brokenaxes(xlims=((eins, zwei), (drei, vier), (fünf,sechs)),  hspace=1.2) 
    bax.plot(daten_sub.index, daten_sub['Außenluft_C'],    color=colo('grün',1),   linewidth=0.5, label = r'Außen C')
    bax.plot(daten_sub.index, daten_sub['Außenluft_rF'],   color=colo('orange',1), linewidth=0.5, label = r'Außen rF')
    bax.plot(daten_sub.index, daten_sub['RWZ_Außenluft'],  color=colo('blau',1),   linewidth=1, label = r'RWZ_Außenluft')
    bax.plot(daten_sub.index, daten_sub['EÜG_Außenluft'],  color=colo('rot',1),    linewidth=1, label = r'EÜG_Außenluft') 
    fig.axes[0].get_xaxis().set_major_formatter(mdates.DateFormatter("%d.%m."))
    fig.axes[1].get_xaxis().set_major_formatter(mdates.DateFormatter("%d.%m."))
    fig.axes[2].get_xaxis().set_major_formatter(mdates.DateFormatter("%d.%m."))
    # bax.set_xlabel('')  
    bax.set(ylim=[-10,120])
    # bax.set_yticks([18.5,19,19.5])  
    # bax.set_ylabel(r'\textbf{Temperatur} ($^\circ$C)')  
    bax.legend(loc=1, ncol=4) 
    plt.title(title) 

Suche nach dem Druck

Tests

# # ## Fumktion um PLateau zu finden
# # ## x Series, high&low Grenzen, thresh Länge des Plateaus
# # def sequence(x, low, high, thresh):
# #     ind = np.flatnonzero(np.diff(np.r_[False, ((x >= low) & (x <= high)), False]))
# #     start = ind[::2]
# #     end = ind[1::2]
# #     mask = end - start >= thresh
# #     result = np.zeros(x.size, dtype=np.int8)
# #     result[start[mask]] = +1
# #     mask[-1] = False
# #     result[end[mask]] = -1
# #     return np.cumsum(result, out=result).view(bool)

# effizienz()


# fig, ax = plt.subplots(figsize=(6,2)) 
# # ax2 = ax.twinx()  
# # ax2.axhline(y=0, linewidth=0.4,   color=colo('black',1), xmin=0.0001, xmax=1)
# ax.axhline(y=73, linewidth=0.4,   color=colo('black',1), xmin=0.0001, xmax=1)
# ax.axhline(y=82, linewidth=0.4,   color=colo('black',1), xmin=0.0001, xmax=1)


# daten_sub['EÜG_Außenluft_vorl'].plot(ax=ax,color=colo('rot',1),    linewidth=.5, label = 'EÜG_Außenluft')    
# daten_sub['RWZ_Außenluft_vorl'].plot(ax=ax,color=colo('grün',1),   linewidth=.5, label = 'RWZ_Außenluft')  
# daten_sub['EÜG_Fortluft_vorl'].plot(ax=ax,color=colo('blau',1),    linewidth=.5, label = 'EÜG_Fortluft')    
# daten_sub['RWZ_Fortluft_vorl'].plot(ax=ax,color=colo('orange',1),  linewidth=.5, label = 'RWZ_Fortluft')  

# daten_sub['EÜG_Außenluft'].plot(ax=ax,color=colo('rot',1),    linewidth=.8, label = '__nolabel__')    
# daten_sub['RWZ_Außenluft'].plot(ax=ax,color=colo('grün',1),   linewidth=.8, label = '__nolabel__')  
# daten_sub['EÜG_Fortluft'].plot(ax=ax,color=colo('blau',1),    linewidth=.8, label = '__nolabel__')    
# daten_sub['RWZ_Fortluft'].plot(ax=ax,color=colo('orange',1),  linewidth=.8, label = '__nolabel__')  

# daten_sub['L_Zuluft_Druck'].plot(ax=ax,color=colo('grau',.8),   linewidth=.8, label = 'Druck')   

# ax.set(ylim=[40,150]) 
# # ax2.set(ylim=[-.025,.05]) 
# ax.set_xlabel('')
# plt.setp(ax.get_xticklabels(), rotation=0, ha="center", rotation_mode="anchor")
# ax.get_xaxis().set_major_formatter(mdates.DateFormatter("%d.%m."))
# ax.set(xlim=[pd.to_datetime("2018-01-31 00:00:00"),pd.to_datetime("2018-02-01 00:00:00")])
# h0, l0 = ax.get_legend_handles_labels() 
# legend = plt.legend(h0, l0, ncol=3, loc=1) 
# set_legend_linewidth(legend) 

# print(f'RWZ außen: {int(daten_sub.RWZ_Außenluft_mean.mean())}%')
# print(f'EÜG außen: {int(daten_sub.EÜG_Außenluft_mean.mean())}%')
## Ableitung
# diff = np.diff(a) 
# gradient = np.sign(diff)
## Werte in einem Bereich markieren
# daten_sub['between_p'] = 0 
# daten_sub['between_p'] = daten_sub[daten_sub['L_Zuluft_Druck'].between(73, 82)]
# daten_sub['between_p'] = np.where(daten_sub['between_p'] >  1 ,1,np.NaN)
## Rollender Durschnitt
# daten_sub['EÜG_Außenluft_roll'] = daten_sub['EÜG_Außenluft_roll'].rolling(500, center=True).mean()
## Ableitung
# daten_sub['plateau']  = (daten_sub['EÜG_Außenluft_roll'].diff() / daten_sub['EÜG_Außenluft_roll'].index.to_series().diff().dt.total_seconds())

Luftdruck

# ## Luftdruck der Wetterstation KAssel Mitte

# fig, ax = plt.subplots(figsize=(6,2)) 
# # ax2 = ax.twinx()  
# # ax2.axhline(y=0, linewidth=0.4,   color=colo('black',1), xmin=0.0001, xmax=1) 
# daten_sub['W_Luftdruck'].plot(ax=ax,color=colo('blau',1),  linewidth=.8, label = 'W_Luftdruck')  
# # ax.set(ylim=[40,150]) 
# # ax2.set(ylim=[-.025,.05]) 
# ax.set_xlabel('')
# plt.setp(ax.get_xticklabels(), rotation=0, ha="center", rotation_mode="anchor")
# ax.get_xaxis().set_major_formatter(mdates.DateFormatter("%d.%m."))
# # ax.set(xlim=[pd.to_datetime(von),pd.to_datetime(bis)])
# h0, l0 = ax.get_legend_handles_labels() 
# legend = plt.legend(h0, l0, ncol=3, loc=1) 
# set_legend_linewidth(legend) 

Druck Histogramm

# daten_std = daten_sub#.loc[eins : sechs]
# # daten_std.dropna(inplace= True)

# fig, ax = plt.subplots(figsize=(6,5))
# bins = 1000
# # .dropna()].isna().sum()
# ## Histogramme mit Rahmen
# plt.hist(daten_std['L_Zuluft_Druck'], bins=bins, orientation="horizontal", color=colo('grün',1),  linewidth=0.5, edgecolor='black', label = 'Druck Zuluft',     histtype='stepfilled')     

# ax.axhline(y=93,   linewidth=0.3,   color=colo('black',1), xmin=0.0001, xmax=1)
# ax.axhline(y=85.5, linewidth=0.3,   color=colo('black',1), xmin=0.0001, xmax=1)
# ax.axhline(y=81,   linewidth=0.3,   color=colo('black',1), xmin=0.0001, xmax=1)
# ax.axhline(y=72,   linewidth=0.3,   color=colo('black',1), xmin=0.0001, xmax=1)
# ax.axhline(y=65,   linewidth=0.3,   color=colo('black',1), xmin=0.0001, xmax=1)

# h0, l0 = ax.get_legend_handles_labels() 
# legend = plt.legend(h0, l0, ncol=1, loc=1)  
# set_legend_linewidth(legend)    

# ax.set_ylabel(r'\textbf{Druck} (Pa)')     
# ax.set_xlabel(r'\textbf{Zeit} (h)')    
# ax.set_yticks([93,85.5,81,72,65]) 
# ax.set(xlim=[0,50000])  
# ax.set(ylim=[70,100])  

# plt.tick_params(axis='x', which='minor', bottom=False)

# # plt.savefig(output_folder + '/' + file_name + '_Luftdruck_Histogramm.pdf') 

Druck Volumenstrom Linenplots

# def axformat():
#     ax.axhline(y=93, linewidth=0.4,   color=colo('black',1), xmin=0.0001, xmax=1)
#     ax.axhline(y=87, linewidth=0.4,   color=colo('black',1), xmin=0.0001, xmax=1)
#     ax.axhline(y=81, linewidth=0.4,   color=colo('black',1), xmin=0.0001, xmax=1)
#     ax.axhline(y=72, linewidth=0.4,   color=colo('black',1), xmin=0.0001, xmax=1)
#     ax.axhline(y=65, linewidth=0.4,   color=colo('black',1), xmin=0.0001, xmax=1)
#     ax.set_xlabel('')  
#     ax.set(ylim=[60,100]) 
#     ax.set_yticks([93,87,81,72,65]) 
#     h0, l0 = ax.get_legend_handles_labels()
#     h2, l2 = ax2.get_legend_handles_labels()
#     legend = plt.legend(h0+h2, l0+l2, ncol=2, loc=1) 
#     set_legend_linewidth(legend) 
#     ax.legend(loc=1, ncol=4)  
#     plt.setp(ax.get_xticklabels(), rotation=0, ha="center", rotation_mode="anchor")

# fig = plt.figure(constrained_layout=False, figsize=(6,2))
# bax = brokenaxes(xlims=((eins, zwei), (drei, vier), (fünf,sechs)),  hspace=1.2) 
# bax.plot(daten_sub.index, daten_sub['L_Zuluft_Druck'],    color=colo('grün',1),   linewidth=0.5, label = r'Zuluft_Druck')  
# fig.axes[0].get_xaxis().set_major_formatter(mdates.DateFormatter("%d.%m."))
# fig.axes[1].get_xaxis().set_major_formatter(mdates.DateFormatter("%d.%m."))
# fig.axes[2].get_xaxis().set_major_formatter(mdates.DateFormatter("%d.%m."))
# bax.axhline(y=93, linewidth=0.4,   color=colo('black',1), xmin=0.0001, xmax=1)
# bax.axhline(y=87, linewidth=0.4,   color=colo('black',1), xmin=0.0001, xmax=1)
# bax.axhline(y=81, linewidth=0.4,   color=colo('black',1), xmin=0.0001, xmax=1)
# bax.axhline(y=72, linewidth=0.4,   color=colo('black',1), xmin=0.0001, xmax=1)
# plt.title('gesamter Zeitraum')
# # bax.set_xlabel('')  
# # bax.set(ylim=[60,100])
# # bax.set_yticks([18.5,19,19.5])  
# # bax.set_ylabel(r'\textbf{Temperatur} ($^\circ$C)')  
# bax.legend(loc=1, ncol=4)  

# ## 12 Tage
# fig, ax = plt.subplots(figsize=(6,2))  
# daten_sub['L_Zuluft_Druck'].plot(ax=ax,color=colo('grün',1),   linewidth=.5, label = 'Druck')
# ax2 = ax.twinx()
# daten_sub['L_Zuluft_VPunkt'].plot(ax=ax2,color=colo('rot',1),   linewidth=.5, label = 'Volumenstrom')
# axformat()
# plt.title('12 Tage')
# ax.get_xaxis().set_major_formatter(mdates.DateFormatter("%d.%m.")) 
# ax.set(xlim=[pd.to_datetime("2018-02-01 00:00:00"),pd.to_datetime("2018-02-12 00:00:00")])


# ## 3.2
# fig, ax = plt.subplots(figsize=(6,2))  
# daten_sub['L_Zuluft_Druck'].plot(ax=ax,color=colo('grün',1),   linewidth=.5, label = 'L_Zuluft_Druck')
# ax2 = ax.twinx()
# daten_sub['L_Zuluft_VPunkt'].plot(ax=ax2,color=colo('rot',1),   linewidth=.5, label = 'Volumenstrom')
# axformat()
# plt.title('3.2.')
# ax.get_xaxis().set_major_formatter(mdates.DateFormatter("%H:%M")) 
# ax.set(xlim=[pd.to_datetime("2018-02-03 00:00:00"),pd.to_datetime("2018-02-03 23:59:00")])


# ## 7.2.
# fig, ax = plt.subplots(figsize=(6,2))  
# daten_sub['L_Zuluft_Druck'].plot(ax=ax,color=colo('grün',1),   linewidth=.5, label = 'L_Zuluft_Druck')
# ax2 = ax.twinx()
# daten_sub['L_Zuluft_VPunkt'].plot(ax=ax2,color=colo('rot',1),   linewidth=.5, label = 'Volumenstrom')
# axformat()
# plt.title('7.2.')
# ax.get_xaxis().set_major_formatter(mdates.DateFormatter("%H:%M")) 
# ax.set(xlim=[pd.to_datetime("2018-02-07 00:00:00"),pd.to_datetime("2018-02-07 23:59:00")])


# ## 10.2.
# fig, ax = plt.subplots(figsize=(6,2))  
# daten_sub['L_Zuluft_Druck'].plot(ax=ax,color=colo('grün',1),   linewidth=.5, label = 'L_Zuluft_Druck')
# ax2 = ax.twinx()
# daten_sub['L_Zuluft_VPunkt'].plot(ax=ax2,color=colo('rot',1),   linewidth=.5, label = 'Volumenstrom')
# axformat()
# plt.title('10.2.')
# ax.get_xaxis().set_major_formatter(mdates.DateFormatter("%H:%M")) 
# ax.set(xlim=[pd.to_datetime("2018-02-10 00:00:00"),pd.to_datetime("2018-02-10 23:59:00")])

Wärmefluss

Berechnungen

def wärmefluss(title='Wärmefluss'):
    global daten_sub

    ## Gas
    daten_sub['S_Gas_Energie_']         = daten_sub['S_Gas_Vpunkt'].div(1000).mul(11.276)
    ## Hydraulik
    daten_sub['S_FriWa_Energie_Sek']    = energie(daten_sub['S_FriWa_VL_Sek'],  daten_sub['S_FriWa_RL_Sek'],  daten_sub['S_FriWa_Vpunkt_Sek'])
    daten_sub['S_FriWa_Energie_Prim']   = energie(daten_sub['S_FriWa_VL_Prim'], daten_sub['S_FriWa_RL_Prim'], daten_sub['S_FriWa_Vpunkt_Prim'])
    daten_sub['S_Solar_Energie']        = energie(daten_sub['S_Solar_VL'],      daten_sub['S_Solar_RL'],      daten_sub['S_Solar_Vpunkt'])
    daten_sub['S_Heizung_Energie']      = energie(daten_sub['S_Heizung_VL'],    daten_sub['S_Heizung_RL'],    daten_sub['S_Heizung_Vpunkt'])
    daten_sub['S_Kessel_Energie']       = energie(daten_sub['S_Kessel_VL'],     daten_sub['S_Kessel_RL'],     daten_sub['S_Kessel_Vpunkt'])

    ## Transmissionswärmeverluste
    daten_sub['TMWV']                   = -110 * (daten_sub['Abluft_C'] - daten_sub['Außenluft_C'])/1000 ## H_T Wert: gemessen: ~110 W/K, berechnet: 105 W/K

    ## Wärmegewinne durch el Strom
    daten_sub['Strom']                  = .4

    ## Lüftung
    daten_sub['L_Zuluft_VPunkt']        = daten_sub['L_Zuluft_1_VPunkt']  + daten_sub['L_Zuluft_2_VPunkt'] + daten_sub['L_Zuluft_3_VPunkt'] 
    daten_sub['Lüftung_rein']           = daten_sub['Außenluft_Energie']    
    daten_sub['Lüftung_raus']           = daten_sub['Fortluft_Energie']       
    daten_sub['Lüftung']                = (daten_sub['Lüftung_rein']      - daten_sub['Lüftung_raus'])   

    ## interne Wärmegewinne durch Meschen (Anzahl über CO2 Konzentration bestimmt)
    ## CO2 Tagesdurchschnittswerte 
    daten_co2                           = daten_sub[['L_Seminarraum_1_CO2','L_Seminarraum_2_CO2']].resample("1D").mean()
    daten_co2                           = daten_co2.resample("15s").fillna(method='ffill').interpolate()

    V_1                                 = 330   ## Gesamtnettovolumen Sem1 + Sem2 = 440m³ # Flächen Sem1: 90m² und Sem2: 30m²
    V_2                                 = 110   ## Volumen anteilig nach Fläche
    daten_sub['LWR_1']                  = daten_sub['L_Zuluft_1_VPunkt'] / V_1
    daten_sub['LWR_2']                  = daten_sub['L_Zuluft_2_VPunkt'] / V_2 
    daten_sub['1CO2med']                = daten_co2['L_Seminarraum_1_CO2']  #daten_sub['L_Seminarraum_1_CO2'].median() 
    daten_sub['2CO2med']                = daten_co2['L_Seminarraum_2_CO2']  #daten_sub['L_Seminarraum_2_CO2'].median() 
    c02_außenluft                       = (daten_sub['1CO2med'] + daten_sub['2CO2med']) / 2
    co2_abgabe_ruhe                     = 20000 # CO2 Emmisionsrate pro Person in ml/h
    co2_abgabe_sport                    = 100000 # CO2 Emmisionsrate pro Person in ml/h
    daten_sub['co2_abgabe_angepasst']   = co2_abgabe_ruhe
    ## Annahme: Abends wird dort Yoga gemacht
    daten_sub['co2_abgabe_angepasst'].loc[(daten_sub.index.hour>=15) & (daten_sub.index.hour<=23)] = co2_abgabe_sport
    wärme_abgabe_ruhe                   = .12 # kW
    wärme_abgabe_sport                  = .27 # kW
    daten_sub['wärme_abgabe_angepasst'] = wärme_abgabe_ruhe
    daten_sub['wärme_abgabe_angepasst'].loc[(daten_sub.index.hour>=15) & (daten_sub.index.hour<=23)] = wärme_abgabe_sport
    daten_sub['Personen_1']             = (-daten_sub['LWR_1'] * V_1 * c02_außenluft + daten_sub['LWR_1'] * V_1 * daten_sub['L_Seminarraum_1_CO2']) / daten_sub['co2_abgabe_angepasst'] 
    daten_sub['Personen_2']             = (-daten_sub['LWR_2'] * V_2 * c02_außenluft + daten_sub['LWR_2'] * V_2 * daten_sub['L_Seminarraum_2_CO2']) / co2_abgabe_ruhe
    daten_sub['Personen_1']             = np.where(daten_sub['Personen_1'] < 5, 0, daten_sub['Personen_1'])
    daten_sub['Personen_2']             = np.where(daten_sub['Personen_2'] < 5, 0, daten_sub['Personen_2']) 
    daten_sub['Wärme_durch_Personen_1'] = daten_sub['Personen_1'] * daten_sub['wärme_abgabe_angepasst'] 
    daten_sub['Wärme_durch_Personen_2'] = daten_sub['Personen_2'] * wärme_abgabe_ruhe 
    daten_sub['Wärme_durch_Personen']   = daten_sub['Wärme_durch_Personen_2'] + daten_sub['Wärme_durch_Personen_1']

    ## wenn keine Heizung -> dann auch keine Bilanz (2h Zeit um die Wärme der Heizung aus dem Gebäude zu lassen)
    daten_sub["S_Heizung_Vpunkt_flag"]                                                  = 0
    daten_sub.loc[daten_sub["S_Heizung_Vpunkt"]      > 50,     "S_Heizung_Vpunkt_flag"] = 1
    daten_sub["S_Heizung_Vpunkt_flag"].fillna(value = 1,limit = 480,     inplace = True)
    daten_sub.loc[daten_sub["S_Heizung_Vpunkt_flag"] == 0,     "S_FriWa_Energie_Prim"]  = 0
    daten_sub.loc[daten_sub["S_Heizung_Vpunkt_flag"] == 0,     "Strom"]                 = 0
    daten_sub.loc[daten_sub["S_Heizung_Vpunkt_flag"] == 0,     "Wärme_durch_Personen"]  = 0
    daten_sub.loc[daten_sub["S_Heizung_Vpunkt_flag"] == 0,     "Lüftung"]               = 0
    daten_sub.loc[daten_sub["S_Heizung_Vpunkt_flag"] == 0,     "TMWV"]                  = 0

    ## Bilanzsumme
    daten_sub['Wärmebilanz']            = daten_sub.S_Heizung_Energie + daten_sub.S_FriWa_Energie_Prim + daten_sub.Strom  + daten_sub.Wärme_durch_Personen  + daten_sub.Lüftung + daten_sub.TMWV  
    ## für Balkendiagramm
    daten_sub['Wärmebilanz_po']         = np.where(daten_sub['Wärmebilanz'] > 0,  daten_sub['Wärmebilanz'], 0)
    daten_sub['Wärmebilanz_ne']         = np.where(daten_sub['Wärmebilanz'] < 0,  daten_sub['Wärmebilanz'], 0) 

    prozent_lüftung                    = (daten_sub.Lüftung.sum()/240)     / (daten_sub.S_Heizung_Energie.sum()/240) * 100
    prozent_TMWV                       = (daten_sub.TMWV.sum()/240)        / (daten_sub.S_Heizung_Energie.sum()/240) * 100
    prozent_bilanz                     = (daten_sub.Wärmebilanz.sum()/240) / (daten_sub.S_Heizung_Energie.sum()/240) * 100

    print_md(f' Heizung: {int(daten_sub.S_Heizung_Energie.sum()/240)} kWh <br>    Lüftungsverluste: {int(daten_sub.Lüftung.sum()/240)} kWh    ({int(prozent_lüftung)}%) <br> TMWV: {int(daten_sub.TMWV.sum()/240)} kWh    ({int(prozent_TMWV)}%) <br> Bilanzfehler: {int(daten_sub.Wärmebilanz.sum()/240)} kWh   ({int(prozent_bilanz)}%) ')

# wärmefluss()

Wärmespeicherkapazität berechnen

## War wicvhtig, um einen Feher zu Finden
## Ist jetzt aber nicht mehr notwendig

# # erster und letzter Wert am Tag
# res = daten_sub['Abluft_C'].groupby(daten_sub.index.date).apply(lambda x: x.iloc[[0, -1]])
# res.index = res.index.droplevel(0)
# print(res)

# # aus Abluft_delta_C -> Wärmespeicherkap
# df = pd.DataFrame() 
# df['Abluft_delta_C']         = daten_sub['Abluft_C'].groupby(daten_sub.index.date).apply(lambda x: x.iloc[-1] -x.iloc[0]) 
# df['Wärmespeicherkap'] = daten_sub['Abluft_C'].groupby(daten_sub.index.date).apply(lambda x: x.iloc[-1] -x.iloc[0]) * 8.837   
# print(df)

Wärmefluss Plot

# def daten_tgl_resample():
#     global daten_sub
#     daten_tgl = daten_sub.resample('D').sum().div(240).copy()    
#     daten_tgl = daten_tgl.replace(0, np.nan)
#     daten_tgl = daten_tgl.dropna(how='all', axis=0)
#     daten_tgl = daten_tgl.replace(np.nan, 0)
#     return daten_tgl




def wärmefluss_plot(i,title="Wärmefluss",nr=0, err=0): 

    asymmetric_error = []
    if err == 1:
        lower_error = minmax['Lüftung'] - minmax['Lüftung_min']
        upper_error = minmax['Lüftung'] + minmax['Lüftung_max']
        asymmetric_error = [lower_error, upper_error]
        error_kw_rein = dict(lw=0.5, capsize=1, capthick=0.5, ecolor=('black')) 

    ## Vorzeichen für den Plot umdrehen
    daten_tgl['Lüftung']         = daten_tgl['Lüftung'].mul(-1)
    daten_tgl['TMWV']            = daten_tgl['TMWV'].mul(-1)

    ## Farben Plot 
    Farben_Gas    = [colo('grau',1)]
    Farben_KeSo   = [colo('blau',1),   colo('gelb',1) ]
    Farben_rein   = [colo('blau',.5),  colo('rot',.5), colo('gelb',.5), colo('violet',1.5) ] 
    Farben_raus   = [colo('rot',1),  colo('grau',1.2) ]
    Farben_Bilanz = [colo('grün',1)]
    ## Farben und Label für die Legende
    L_Gas        = mpatches.Patch(facecolor=colo('grau',1),    label='Gas',             edgecolor='black', linewidth=0.3) 
    L_Kessel     = mpatches.Patch(facecolor=colo('blau',1),    label='Kessel',          edgecolor='black', linewidth=0.3) 
    L_Solar      = mpatches.Patch(facecolor=colo('gelb',1),    label='Solar',           edgecolor='black', linewidth=0.3) 
    L_Heizung    = mpatches.Patch(facecolor=colo('blau',.5),   label='Heizung',         edgecolor='black', linewidth=0.3) 
    L_FriWa      = mpatches.Patch(facecolor=colo('rot',.5),    label='FriWa',           edgecolor='black', linewidth=0.3) 
    L_Strom      = mpatches.Patch(facecolor=colo('gelb',.5),   label='Strom',           edgecolor='black', linewidth=0.3)  
    L_Personen   = mpatches.Patch(facecolor=colo('violet',1),  label='Personen',        edgecolor='black', linewidth=0.3) 
    L_Lüftung    = mpatches.Patch(facecolor=colo('grau',1),    label='Lüftung',         edgecolor='black', linewidth=0.3) 
    L_Trans      = mpatches.Patch(facecolor=colo('rot',1),     label='Transmission',    edgecolor='black', linewidth=0.3) 
    L_Bilanz     = mpatches.Patch(facecolor=colo('grün',1),    label='Bilanz',          edgecolor='black', linewidth=0.3) 
    L_Dummy      = mpatches.Patch(facecolor=colo('black',1),   label='Dummy',           edgecolor='black', linewidth=0.3) 

    handles  = [L_Gas,L_Dummy,L_Dummy,L_Dummy,
                L_Solar,L_Kessel,L_Dummy,L_Dummy,
                L_Personen,L_Strom,L_FriWa,L_Heizung,
                L_Lüftung,L_Trans,L_Dummy,L_Dummy,
                L_Bilanz,L_Dummy,L_Dummy,L_Dummy,]


    stacked = True
    width   = 0.2

    def plot_3(von,bis):
        Gas     = daten_tgl[['S_Gas_Energie_']].loc[von:bis] 
        KeSo    = daten_tgl[['S_Kessel_Energie', 'S_Solar_Energie']].loc[von:bis] 
        W_rein  = daten_tgl[['S_Heizung_Energie','S_FriWa_Energie_Prim', 'Strom','Wärme_durch_Personen']].loc[von:bis] 
        W_raus  = daten_tgl[['TMWV','Lüftung']].loc[von:bis] 
        bilanz  = daten_tgl[['Wärmebilanz']].loc[von:bis] * -1 

        fig, ax = plt.subplots(constrained_layout=True, figsize=(30,5)) 

        Gas.plot.bar(position   = 2,     color=(Farben_Gas),    edgecolor='black',linewidth = 0.3, width=width,ax=ax,stacked=stacked,alpha = 1)
        KeSo.plot.bar(position  = 1,     color=(Farben_KeSo),   edgecolor='black',linewidth = 0.3, width=width,ax=ax,stacked=stacked,alpha = 1)
        W_rein.plot.bar(position= 0,     color=(Farben_rein),   edgecolor='black',linewidth = 0.3, width=width,ax=ax,stacked=stacked,alpha = 1)
        W_raus.plot.bar(position=-1,     color=(Farben_raus),   edgecolor='black',linewidth = 0.3, width=width,ax=ax,stacked=stacked,alpha = 1) 

        ## Bilanzfehler in grün
        if err == 0:
            bilanz.plot.bar(position= -0.5, color=(Farben_Bilanz), edgecolor='black',linewidth = 0.3, width=width,ax=ax,stacked=stacked,alpha = 1) 

        ## Fehlerbalken auf Lüftung
        if err == 1:
            Lüftung_bottom =  daten_tgl['gesp_Wärme_neg'] + daten_tgl['TMWV']  
            daten_tgl.Lüftung.plot.bar(position= -1,bottom=Lüftung_bottom,  color=colo('grau',1), edgecolor='black',linewidth = 0.3, width=width,ax=ax,stacked=stacked,alpha = 1, yerr=asymmetric_error, error_kw=error_kw_rein)  

#         daten_tgl.Lüftung.plot.bar(position= -0.5,bottom=(15 ),  color=(Farben_Bilanz), edgecolor='black',linewidth = 0.3, width=width,ax=ax,stacked=stacked,alpha = 1, yerr=asymmetric_error, error_kw=error_kw_rein)  
#         bilanz.plot.bar(position= -0.5,  color=(Farben_Bilanz), edgecolor='black',linewidth = 0.3, width=width,ax=ax,stacked=stacked,alpha = 1, yerr=asymmetric_error, error_kw=error_kw_rein)  
#         daten_tgl.Lüftung.plot.bar(position= -0.5,  color=colo('grau',2), edgecolor='black',linewidth = 0.3, width=width,ax=ax,stacked=stacked,alpha = 1)  
#         daten_tgl.TMWV.plot.bar(position= -1.5,  color=colo('rot',2), edgecolor='black',linewidth = 0.3, width=width,ax=ax,stacked=stacked,alpha = 1)  

        ax.axhline(y=0, linewidth=0.4,   color=colo('black',1), xmin=0.0001, xmax=1)
        ticklabels = ['']*len(W_rein.index) 
        ticklabels[::1] = [item.strftime('%d. %b') for item in W_rein.index[::1]] 
#         plt.xticks(fontsize=4, rotation=0)
        ax.set_xlim(-0.5,len(W_rein.index))  
        ax.set_xticklabels(ticklabels, fontsize=4, rotation=270)
        ax.set_xticks(np.arange(width/2, len(W_rein.index), step = 1))
        ax.set_xlabel('')
        ax.set_ylim(-50,250)  
        ax.set_ylabel(r'\textbf{Energie} ($kWh$)')   
#         for p in ax.patches:
#             ax.annotate(str(p.get_height()), (p.get_x() * 1.005, p.get_height() * 1.005))

        # Legende 
        legend = plt.legend(handles=handles, loc=1, ncol=5 ) 
        legend.get_frame().set_linewidth(0.3)   
        ## Dummies löschen
        legend.legendHandles[1].set_visible(False) 
        legend.legendHandles[2].set_visible(False) 
        legend.legendHandles[3].set_visible(False) 
        legend.legendHandles[6].set_visible(False) 
        legend.legendHandles[7].set_visible(False) 
        legend.legendHandles[14].set_visible(False) 
        legend.legendHandles[15].set_visible(False) 
        legend.legendHandles[17].set_visible(False) 
        legend.legendHandles[18].set_visible(False) 
        legend.legendHandles[19].set_visible(False)             
        legend.texts[1].set_visible(False) 
        legend.texts[2].set_visible(False) 
        legend.texts[3].set_visible(False) 
        legend.texts[6].set_visible(False) 
        legend.texts[7].set_visible(False) 
        legend.texts[14].set_visible(False) 
        legend.texts[15].set_visible(False) 
        legend.texts[17].set_visible(False) 
        legend.texts[18].set_visible(False) 
        legend.texts[19].set_visible(False)  

        ax.set_xlabel('')
        plt.title('Bilanzsumme:'+str(int(daten_sub.Wärmebilanz.sum()/-240))+'kWh '+title)
#         plt.savefig(output_folder + '/' + file_name + '_' + title +'.pdf') 

    if nr == 0:
        plot_3(eins,sechs)     

    if nr == 1:
        plot_3(eins,zwei)    

    if nr == 2:   
        plot_3(drei,vier)    

    if nr == 3:  
        plot_3(fünf,sechs)

    if nr == 99:  
        plot_3(anfang,ende)

#     daten_tgl['Wärmebilanz_po']         = np.where(daten_tgl['Wärmebilanz'] < 0,  daten_tgl['Wärmebilanz'], 0)
#     daten_tgl['Wärmebilanz_ne']         = np.where(daten_tgl['Wärmebilanz'] > 0,  daten_tgl['Wärmebilanz'], 0) 
#     print_md(f'{title} täglich<br>Wärmebilanz Summe: {int(daten_tgl.Wärmebilanz.sum())} kWh<br> positiv: {int(daten_tgl.Wärmebilanz_po.sum())} negativ: {int(daten_tgl.Wärmebilanz_ne.sum())} ')

# daten_tgl = daten_sub.resample('D').sum().div(240).copy()    
# daten_tgl = daten_tgl.replace(0, np.nan)
# daten_tgl = daten_tgl.dropna(how='all', axis=0)
# daten_tgl = daten_tgl.replace(np.nan, 0)
# effizienz()
# wärmefluss_plot(1,'Standard',err=1,nr=99) 

Tagesansichten

Tageswerte

def tageswerte(t,m,y):
    tag   = str(t)
    monat = str(m)
    jahr  = str(y)

    daten_zw_feb = daten_sub.loc[str(jahr)+'-'+str(monat)+'-'+str(tag)+' 00:00' : str(jahr)+'-'+str(monat)+'-'+str(tag)+' 23:59'] 
    tagesbilanz = ''#str(round(float(bilanz_tgl[['Wärmebilanz']].loc[ str(jahr)+'-'+str(monat)+'-'+str(tag)+' 00:00' : str(jahr)+'-'+str(monat)+'-'+str(tag)+' 23:59'].values[0]),2))
    fig, axes = plt.subplots(nrows=8, ncols=1, sharex=True , constrained_layout=False,figsize=(5.8,8.05)) 

    axes[0].plot(daten_zw_feb['L_Zuluft_VPunkt'],color=colo('blau',1),  linewidth=0.8,  label='Zuluft')
    axes[0].plot(daten_zw_feb['L_Zuluft_Druck'].mul(10),color=colo('grün',1),  linewidth=0.8,  label='Druck')
    axes[0].axhline(y=820, linewidth=0.4,   color=colo('black',1), xmin=0.0001, xmax=1)    
    axes[0].set(ylabel=r"\textbf{VS} ($m\textsuperscript{3}$)") 
    axes[0].set_ylim(700,1550)  

    axes[1].plot(daten_zw_feb['Lüftung'].div(240),color=colo('rot',1), linewidth=0.8,  label='Lüftung Differenz')
    axes[1].set(ylabel=r"\textbf{Lei} ($kW$)") 
    axes[1].set_ylim(-0.03,0.03)  

    axes[2].plot(daten_zw_feb['L_Seminarraum_1_CO2'],color=colo('grün',1), linewidth=0.8,  label='Seminar 1')
    axes[2].plot(daten_zw_feb['L_Seminarraum_2_CO2'],color=colo('gelb',1), linewidth=0.8,  label='Seminar 2')
    axes[2].set(ylabel=r"\textbf{CO\textsubscript{2}} ($ppm$)") 
    axes[2].set_ylim(400,1000)  

    axes[3].plot(daten_zw_feb['S_FriWa_Vpunkt_Prim'],color=colo('orange',1), linewidth=0.8,  label='FriWa Prim')
    axes[3].plot(daten_zw_feb['S_FriWa_Vpunkt_Sek'],color=colo('rot',1), linewidth=0.8,  label='FriWa Sek')
    axes[3].set(ylabel=r"\textbf{VS} ($m\textsuperscript{3}/h$)") 
    axes[3].set_ylim(0,100)  

    axes[4].plot(daten_zw_feb['Außenluft_WG'],color=colo('orange',1), linewidth=0.8,  label='Außenluft')
    axes[4].plot(daten_zw_feb['Zuluft_WG'],color=colo('rot',1), linewidth=0.8,  label='Zuluft')
    axes[4].plot(daten_zw_feb['Abluft_WG'],color=colo('grün',1), linewidth=0.8,  label='Abluft')
    axes[4].plot(daten_zw_feb['Fortluft_WG'],color=colo('blau',1), linewidth=0.8,  label='Fortluft')
    axes[4].set(ylabel=r"\textbf{WG} ($g/m\textsuperscript{3}$)") 
    axes[4].set_ylim(0.003,0.006)  

    axes[5].plot(daten_zw_feb['S_Solarstrahlung'],color=colo('gelb',1), linewidth=0.8,  label='Solarstrahlung')
    axes[5].set(ylabel=r"\textbf{Lei} ($W/m^{2}$)") 
    axes[5].set_ylim(0,500)  

    axes[6].plot(daten_zw_feb['L_Aussenlufttemperatur_1'],color=colo('blau',1), linewidth=0.8,  label='Aussenluft')
    axes[6].set(ylabel=r"\textbf{Tem}  ($^\circ$C)") 
    axes[6].set_ylim(-5,5)  

    axes[7].plot(daten_zw_feb['Zuluft_C'],color=colo('grün',1), linewidth=0.8,  label='Zuluft')
    axes[7].plot(daten_zw_feb['Abluft_C'],color=colo('rot',1), linewidth=0.8,  label='Abluft')
    axes[7].set(ylabel=r"\textbf{Tem}  ($^\circ$C)")
    axes[7].set_ylim(10,25)  

    axes[0].set_title('Tageswerte: ' +str(tag)+'.'+str(monat)+'.'+str(jahr))
    axes[0].set(xlim=[pd.to_datetime(str(jahr)+'-'+str(monat)+'-'+str(tag)+' 00:00'),pd.to_datetime(str(jahr)+'-'+str(monat)+'-'+str(tag)+' 23:59')])
    axes[0].xaxis.set_major_formatter(mdates.DateFormatter('%H')) 

    fig.autofmt_xdate(rotation=0,ha='center')
    for ax in axes:
        ax.legend( ncol=6, loc=1,  bbox_to_anchor=(1., 1.3)) 
        ax.yaxis.get_label().set_fontsize(8)
    plt.subplots_adjust(hspace=.2) 
#     plt.tight_layout()
    plt.show()

Luftwerte

def luftwerte(t,m,y):
    tag   = str(t)
    monat = str(m)
    jahr  = str(y)

    daten_zw_feb = daten_sub.loc[str(jahr)+'-'+str(monat)+'-'+str(tag)+' 00:00' : str(jahr)+'-'+str(monat)+'-'+str(tag)+' 23:59'] 
    tagesbilanz = ''#str(round(float(bilanz_tgl[['Wärmebilanz']].loc[ str(jahr)+'-'+str(monat)+'-'+str(tag)+' 00:00' : str(jahr)+'-'+str(monat)+'-'+str(tag)+' 23:59'].values[0]),2))
    fig, axes = plt.subplots(nrows=9, ncols=1, sharex=True , constrained_layout=False,figsize=(5.8,8.05)) 

    axes[0].plot(daten_zw_feb['L_Zuluft_VPunkt'],color=colo('blau',1),  linewidth=0.8,  label='Zuluft')
    axes[0].plot(daten_zw_feb['L_Zuluft_Druck'].mul(10),color=colo('grün',1),  linewidth=0.8,  label='Druck')
    axes[0].axhline(y=820, linewidth=0.4,   color=colo('black',1), xmin=0.0001, xmax=1)
    axes[0].set(ylabel=r"\textbf{VS} ($m\textsuperscript{3}$)") 
    axes[0].set_ylim(700,1550)  

    axes[1].plot(daten_zw_feb['Lüftung'].div(240),color=colo('rot',1), linewidth=0.8,  label='Lüftung Differenz')
    axes[1].plot(daten_zw_feb['Lüftung_rein'].div(240),color=colo('blau',1), linewidth=0.8,  label='Lüftung rein')
    axes[1].plot(daten_zw_feb['Lüftung_raus'].div(240),color=colo('grün',1), linewidth=0.8,  label='Lüftung raus')
    axes[1].set(ylabel=r"\textbf{Lei} ($kW$)") 
    axes[1].set_ylim(-0.05,0.15)  

    axes[2].plot(daten_zw_feb['EÜG_Außenluft'],color=colo('grün',1), linewidth=0.8,  label='EÜG_Außenluft')
    axes[2].plot(daten_zw_feb['RWZ_Außenluft'],color=colo('gelb',1), linewidth=0.8,  label='RWZ_Außenluft')
    axes[2].set(ylabel=r"\textbf{Wirk} ($\%$)") 
    axes[2].set_ylim(0,100)  

    axes[3].plot(daten_zw_feb['Außenluft_Energie'],color=colo('blau',1), linewidth=0.8,  label='Außenluft')
    axes[3].plot(daten_zw_feb['Zuluft_Energie'],color=colo('orange',1), linewidth=0.8,  label='Zuluft')
    axes[3].plot(daten_zw_feb['Abluft_Energie'],color=colo('rot',1), linewidth=0.8,  label='Abluft')
    axes[3].plot(daten_zw_feb['Fortluft_Energie'],color=colo('grün',1), linewidth=0.8,  label='Fortluft')
    axes[3].set(ylabel=r"\textbf{En} ($kW/h$)") 
    axes[3].set_ylim(0,20)  

    axes[4].plot(daten_zw_feb['Außenluft_WG'],color=colo('blau',1), linewidth=0.8,  label='Außenluft')
    axes[4].plot(daten_zw_feb['Zuluft_WG'],color=colo('orange',1), linewidth=0.8,  label='Zuluft')
    axes[4].plot(daten_zw_feb['Abluft_WG'],color=colo('rot',1), linewidth=0.8,  label='Abluft')
    axes[4].plot(daten_zw_feb['Fortluft_WG'],color=colo('grün',1), linewidth=0.8,  label='Fortluft')
    axes[4].set(ylabel=r"\textbf{WG} ($g/m\textsuperscript{3}$)") 
    axes[4].set_ylim(0.002,0.006)  

    axes[5].plot(daten_zw_feb['Außenluft_C'],color=colo('blau',1), linewidth=0.8,  label='Außenluft')
    axes[5].plot(daten_zw_feb['Zuluft_C'],color=colo('orange',1), linewidth=0.8,  label='Zuluft')
    axes[5].plot(daten_zw_feb['Abluft_C'],color=colo('rot',1), linewidth=0.8,  label='Abluft')
    axes[5].plot(daten_zw_feb['Fortluft_C'],color=colo('grün',1), linewidth=0.8,  label='Fortluft')
    axes[5].set(ylabel=r"\textbf{Tem}  ($^\circ$C)")
    axes[5].set_ylim(-10,27)  

    axes[6].plot(daten_zw_feb['Außenluft_rF'],color=colo('blau',1), linewidth=0.8,  label='Außenluft')
    axes[6].plot(daten_zw_feb['Zuluft_rF'],color=colo('orange',1), linewidth=0.8,  label='Zuluft')
    axes[6].plot(daten_zw_feb['Abluft_rF'],color=colo('rot',1), linewidth=0.8,  label='Abluft')
    axes[6].plot(daten_zw_feb['Fortluft_rF'],color=colo('grün',1), linewidth=0.8,  label='Fortluft')
    axes[6].set(ylabel=r"\textbf{LF} ($\%$)") 
    axes[6].set_ylim(20,100)  

    axes[7].plot(daten_zw_feb['Wärmebilanz'],color=colo('grün',1), linewidth=0.8,  label='Wärmebilanz') 
    axes[7].set(ylabel=r"\textbf{En} ($kW/h$)") 
    axes[7].axhline(y=0, linewidth=0.4,   color=colo('black',1), xmin=0.0001, xmax=1)
    axes[7].set_ylim(-5,5)      

    axes[8].plot(daten_zw_feb['S_Heizung_Energie'],color=colo('grau',1), linewidth=0.8,  label='Heizung') 
    axes[8].plot(daten_zw_feb['Strom'],color=colo('gelb',1), linewidth=0.8,  label='Strom') 
    axes[8].plot(daten_zw_feb['Lüftung'],color=colo('grün',1), linewidth=0.8,  label='Lüftung') 
#     axes[8].plot(daten_zw_feb['Wärmespeicherkap'],color=colo('orange',1), linewidth=0.8,  label='Kap') 
    axes[8].plot(daten_zw_feb['Wärme_durch_Personen'],color=colo('violet',1), linewidth=0.8,  label='Pers') 
    axes[8].plot(daten_zw_feb['TMWV'],color=colo('rot',1), linewidth=0.8,  label='TMWV') 
    axes[8].set(ylabel=r"\textbf{En} ($kW/h$)") 
    axes[8].axhline(y=0, linewidth=0.4,   color=colo('black',1), xmin=0.0001, xmax=1)
#     axes[8].set_ylim(-5,5)  

    axes[0].set_title('Luftwerte: ' +str(tag)+'.'+str(monat)+'.'+str(jahr))
    axes[0].set(xlim=[pd.to_datetime(str(jahr)+'-'+str(monat)+'-'+str(tag)+' 00:00'),pd.to_datetime(str(jahr)+'-'+str(monat)+'-'+str(tag)+' 23:59')])
    axes[0].xaxis.set_major_formatter(mdates.DateFormatter('%H')) 


    fig.autofmt_xdate(rotation=0,ha='center')
    for ax in axes:
        ax.legend( ncol=6, loc=1,  bbox_to_anchor=(1., 1.3)) 
        ax.yaxis.get_label().set_fontsize(8)
    plt.subplots_adjust(hspace=.2) 
#     plt.tight_layout()
    plt.show()

Bilanzen

def bilanz(t,m,y):
    tag   = str(t)
    monat = str(m)
    jahr  = str(y)

    daten_zw_feb = daten_sub.loc[str(jahr)+'-'+str(monat)+'-'+str(tag)+' 00:00' : str(jahr)+'-'+str(monat)+'-'+str(tag)+' 23:59']  
    fig, axes = plt.subplots(nrows=4, ncols=1, sharex=True , constrained_layout=False,figsize=(5.8,8.05))     
    tagesbilanz = ''#str(round(float(bilanz_tgl[['Wärmebilanz']].loc[ str(jahr)+'-'+str(monat)+'-'+str(tag)+' 00:00' : str(jahr)+'-'+str(monat)+'-'+str(tag)+' 23:59'].values[0]),2))

#     axes[0].plot(daten_zw_feb['Wärmebilanz'],color=colo('black',1), linewidth=0.8,  label='Wärmebilanz') 
    axes[0].plot(daten_zw_feb['S_Heizung_Energie'],color=colo('grau',1), linewidth=0.8,  label='Heizung') 
#     axes[0].plot(daten_zw_feb['Strom'],color=colo('gelb',1), linewidth=0.8,  label='Strom') 
    axes[0].plot(daten_zw_feb['Lüftung'].mul(-1),color=colo('grün',1), linewidth=0.8,  label='Lüftung') 
#     axes[0].plot(daten_zw_feb['Wärmespeicherkap'],color=colo('orange',1), linewidth=0.8,  label='Kap') 
    axes[0].plot(daten_zw_feb['Wärme_durch_Personen'],color=colo('violet',1), linewidth=0.8,  label='Pers') 
    axes[0].plot(daten_zw_feb['TMWV'].mul(-1),color=colo('rot',1), linewidth=0.8,  label='TMWV') 
    axes[0].set(ylabel=r"\textbf{En} ($kW/h$)") 
    axes[0].axhline(y=0, linewidth=0.4,   color=colo('black',1), xmin=0.0001, xmax=1)
    axes[0].set_ylim(-5,10)  

    axes[1].plot(daten_zw_feb['L_Zuluft_Druck'],color=colo('grün',1), linewidth=0.8,  label='L_Zuluft_Druck') 
    axes[1].axhline(y=83, linewidth=0.4,   color=colo('black',1), xmin=0.0001, xmax=1)
    axes[1].axhline(y=76, linewidth=0.4,   color=colo('black',1), xmin=0.0001, xmax=1)
    axes[1].set(ylabel=r"\textbf{En} ($kW/h$)") 
    axes[1].axhline(y=0, linewidth=0.4,   color=colo('black',1), xmin=0.0001, xmax=1)
#     axes[1].set_ylim(-5,5)   

    axes[2].plot(daten_zw_feb['Außenluft_Energie'],color=colo('blau',1), linewidth=0.8,  label='Außenluft') 
    axes[2].plot(daten_zw_feb['Zuluft_Energie'],color=colo('orange',1), linewidth=0.8,  label='Zuluft') 
    axes[2].plot(daten_zw_feb['Abluft_Energie'],color=colo('rot',1), linewidth=0.8,  label='Abluft') 
    axes[2].plot(daten_zw_feb['Fortluft_Energie'],color=colo('grün',1), linewidth=0.8,  label='Fortluft') 
    axes[2].set(ylabel=r"\textbf{En} ($kW/h$)") 
    axes[2].axhline(y=0, linewidth=0.4,   color=colo('black',1), xmin=0.0001, xmax=1)
#     axes[2].set_ylim(-5,5)  

    axes[3].plot(daten_zw_feb['L_Zuluft_VPunkt'],color=colo('blau',1), linewidth=0.8,  label='L_Zuluft_Vpunkt') 
    axes[3].plot(daten_zw_feb['Vpunkt_extern'],color=colo('grün',1), linewidth=0.8,  label='Vpunkt_extern') 
    axes[3].set(ylabel=r"\textbf{En} ($kW/h$)") 
    axes[3].axhline(y=0, linewidth=0.4,   color=colo('black',1), xmin=0.0001, xmax=1)
#     axes[3].set_ylim(-5,5)  

    axes[0].set_title('Bilanzen: ' +str(tag)+'.'+str(monat)+'.'+str(jahr))
    axes[0].set(xlim=[pd.to_datetime(str(jahr)+'-'+str(monat)+'-'+str(tag)+' 00:00'),pd.to_datetime(str(jahr)+'-'+str(monat)+'-'+str(tag)+' 23:59')])
    axes[0].xaxis.set_major_formatter(mdates.DateFormatter('%H')) 
    fig.autofmt_xdate(rotation=0,ha='center')
    for ax in axes:
        ax.legend( ncol=6, loc=1,  bbox_to_anchor=(1., 1.1)) 
        ax.yaxis.get_label().set_fontsize(8)
    plt.subplots_adjust(hspace=.1) 
#     plt.tight_layout()
    plt.show()     

BF / MinMax - Lüftung

# def plot_bilanzfehler():
#     bilanzsumme = daten_sub['Wärmebilanz'].sum()/240

#     fig, ax = plt.subplots(constrained_layout=True, figsize=(8,1.5))   
#     daten_sub['Wärmebilanz'].resample("D").sum().div(240).plot(ax=ax,color=colo('grün',1), linewidth=1, label = 'Nr: ' +str(nr)+' '+str(int(bilanzsumme))+'kWh', style='-')  
#     ax.axhline(y=0, linewidth=0.4,   color=colo('black',.7), xmin=0.0001, xmax=1)
#     # ax.set_ylabel(r'\textbf{Bilanzfehler} ($kWh$)')    
#     ax.set_ylim(-100,100)
#     date_form = DateFormatter("%b")
#     ax.xaxis.set_major_formatter(date_form)
#     plt.xticks(rotation=0, ha='right')
# #     x_axis = ax.axes.get_xaxis()
# #     x_axis.set_visible(False)
#     ax.set_xlabel('')
#     h0, l0 = ax.get_legend_handles_labels() 
#     legend = plt.legend(h0, l0, ncol=1, loc=1)
#     set_legend_linewidth(legend)   

# #     ax.set_title('Nr: ' +str(nr)+' '+str(int(bilanzsumme))+'kWh')
# #     ax.set(xlim=[pd.to_datetime("31.01.18 00:00:00"),pd.to_datetime("20.02.18 23:00:00")])
#     plt.show()
# # plot_bilanzfehler()

Berechnungen

# außen_C  = 0 
# zu_C     = 0 
# ab_C     = 0 
# fort_C   = 0  
# außen_rF = 0 
# zu_rf    = 0 
# ab_rF    = 0 
# fort_rf  = 0
# by       = 0  # Anteil der Luft, die durch den Bypass geht verändern in %, gemessen sind 45%
# zu_Vp    = 0  # Gesamtluftstrom verändern in % 
# # Temp
# low_C    = -1
# high_C   =  1.1
# step_C   =  2/1
# # rel LF
# low_rF   = -5
# high_rF  =  6
# step_rF  =  10/1
# # bypass & Vp
# low_by   = -10
# high_by  =  11
# step_by  =  20/1
# # index
# nr        = 0
# first_one = 0
# grenzen   = 10000 ## Betrag des Blanzfehlers ab wann die Variante "gut" ist

# ## aus Lüftung_kalibrieren
# varianten = [17,54,31,8,28]

# ## einmal mit Standardwerten durchrechnen um ein Ausgangspunkt für Min und Max zu haben
# title = ' außen_C='+str(außen_C)  +    ',  fort_C='+str(fort_C)  +  ', außen_rF='+str(außen_rF)  +  ', fort_rf='+str(fort_rf)  +  ', by='+str(by)  +  ', zu_Vp='+str(zu_Vp) 
# effizienz(außen_C=außen_C,                 fort_C=fort_C,              außen_rF=außen_rF,              fort_rf=fort_rf,              by=by,              zu_Vp=zu_Vp)
# wärmefluss(title) 
# nr = 0
# print(str(nr) + ' ' +title)
# plot_bilanzfehler()
# # print('Wärmebilanz: '+str(int(daten_sub['Wärmebilanz'].sum()/240)))
# # print('')


# ## minmax ist für die Fehlerbalken in Lüftung (und Bilanz)
# ## Ausgangspubnkte für Min und Max anlegen
# minmax                    = pd.DataFrame(columns=["Wärmebilanz"])
# minmax['Wärmebilanz']     = daten_sub['Wärmebilanz'].resample("D").sum()/240
# # minmax['Wärmebilanz_min'] = 0 #daten_sub['Wärmebilanz'].resample("D").sum()/240
# # minmax['Wärmebilanz_max'] = 0 #daten_sub['Wärmebilanz'].resample("D").sum()/240
# minmax['Lüftung']         = daten_sub['Lüftung'].resample("D").sum()/240
# # minmax['Lüftung_min']     = 0 #daten_sub['Lüftung'].resample("D").sum()/240
# # minmax['Lüftung_max']     = 0 #daten_sub['Lüftung'].resample("D").sum()/240
# ## bf speichert alle Varianten um die besten zu finden
# bf = pd.DataFrame(columns=["Wärmebilanz_sum","Wärmebilanz_std","Wärmebilanz_po","Wärmebilanz_ne", "Lüftung_rein", "Lüftung_raus", "Lüftung", "titel"])
# for außen_C in np.arange(low_C, high_C, step_C):
#     for fort_C in np.arange(low_C, high_C, step_C):
#         for außen_rF in np.arange(low_rF, high_rF, step_rF):
#             for fort_rf in np.arange(low_rF, high_rF, step_rF):
#                 for by in np.arange(low_by, high_by, step_by):
#                     for zu_Vp in np.arange(low_by, high_by, step_by):

#                         ## Berechnung
#                             nr    = nr +1

# #                         if nr in varianten:

#                             title = 'effizienz(außen_C='+str(außen_C)  +    ',  fort_C='+str(fort_C)  +  ', außen_rF='+str(außen_rF)  +  ', fort_rf='+str(fort_rf)  +  ', by='+str(by)  +  ', zu_Vp='+str(zu_Vp)+')' 
#                             effizienz(außen_C=außen_C,                 fort_C=fort_C,              außen_rF=außen_rF,              fort_rf=fort_rf,              by=by,              zu_Vp=zu_Vp)
#                             wärmefluss(title) 

#                             ## Varianten in bf
#                             bf.loc[nr] = [(int(daten_sub['Wärmebilanz'].sum()/240)),  daten_sub['Wärmebilanz'].std(),  int(daten_sub['Wärmebilanz_po'].sum()/240),  int(daten_sub['Wärmebilanz_ne'].sum()/240),  daten_sub['Lüftung_rein'].mean(),  daten_sub['Lüftung_raus'].mean(), daten_sub['Lüftung'].sum()/240,          title] 


#                             ## MinMax df
#                             Wärmebilanz_sum                   = daten_sub['Wärmebilanz'].sum()/240
#     #                         plot_bilanzfehler()
#                             if (Wärmebilanz_sum > -grenzen) & (Wärmebilanz_sum < grenzen):
#                                 ## ersten Datensatz in min und max Felder setzen
#                                 if first_one == 0:
#                                     minmax['Wärmebilanz_min'] = daten_sub['Wärmebilanz'].resample("D").sum()/240
#                                     minmax['Wärmebilanz_max'] = daten_sub['Wärmebilanz'].resample("D").sum()/240
#                                     minmax['Lüftung_min']     = daten_sub['Lüftung'].resample("D").sum()/240
#                                     minmax['Lüftung_max']     = daten_sub['Lüftung'].resample("D").sum()/240
#                                     first_one = 1
#                                 ## minmax für Wärmebilanz
#                                 Wärmebilanz_tgl                   = daten_sub['Wärmebilanz'].resample("D").sum()/240
#                                 minmax['Wärmebilanz_'+str(nr)]    = Wärmebilanz_tgl 
#                                 minmax['Wärmebilanz_min']         = np.where(Wärmebilanz_tgl < minmax['Wärmebilanz_min'], Wärmebilanz_tgl, minmax['Wärmebilanz_min'])
#                                 minmax['Wärmebilanz_max']         = np.where(Wärmebilanz_tgl > minmax['Wärmebilanz_max'], Wärmebilanz_tgl, minmax['Wärmebilanz_max'])
#                                 plot_bilanzfehler()

#                                 ## minmax für Lüftung
#                                 Lüftung_tgl                       = daten_sub['Lüftung'].resample("D").sum()/240
#                                 minmax['Lüftung_'+str(nr)]        = Lüftung_tgl
#                                 minmax['Lüftung_min']             = np.where(Lüftung_tgl < minmax['Lüftung_min'], Lüftung_tgl, minmax['Lüftung_min'])         
#                                 minmax['Lüftung_max']             = np.where(Lüftung_tgl > minmax['Lüftung_max'], Lüftung_tgl, minmax['Lüftung_max'])

#                             #display(minmax.loc['2017-12-06'][['Wärmebilanz','Wärmebilanz_max','Wärmebilanz_min']])



#                             ## Ausgabe während der Berechnung
#                             print(str(nr) + ' ' +title)
#     #                         print('Wärmebilanz: '+str(int(daten_sub['Wärmebilanz'].sum()/240)))
#     #                         print('')


# ## leeren Zeilen rauswerfen
# minmax = minmax.replace(0, np.nan)
# minmax = minmax.dropna(how='all', axis=0)
# minmax = minmax.replace(np.nan, 0)    
# # display(minmax)
# #display(round(bf,4)) 
# # round(bf,4).to_csv('Lueftung_kalibrieren_Varianten.csv')  

Plot Min_Max

# Wärmebilanz_lower_error      = minmax['Wärmebilanz_min'] - minmax['Wärmebilanz']
# Wärmebilanz_upper_error      = minmax['Wärmebilanz_max'] + minmax['Wärmebilanz']
# Wärmebilanz_error            = [Wärmebilanz_lower_error, Wärmebilanz_upper_error]

# Lüftung_lower_error          = minmax['Lüftung_min'] - minmax['Lüftung']
# Lüftung_upper_error          = minmax['Lüftung_max'] + minmax['Lüftung']
# Lüftung_error                = [Lüftung_lower_error, Lüftung_upper_error]

# minmax['Date1'] = minmax.index

# fig, ax = plt.subplots(constrained_layout=True) 
# ax.ticklabel_format(useLocale=True) ## dot as thousand separator  

# ax.fill_between(minmax['Date1'], minmax['Wärmebilanz_min'], minmax['Wärmebilanz_max'],edgecolor='black', facecolor=colo('grün',1.5), alpha=1, label = 'min - max')
# # ax.plot(minmax['Date1'], minmax['Wärmebilanz'],color=colo('grün',1),   linewidth=0.5, label = 'Wärmebilanz')

# ax2 = ax.twinx() 
# ax2.fill_between(minmax['Date1'], minmax['Lüftung_min'], minmax['Lüftung_max'],edgecolor='black', facecolor=colo('grau',1.9), alpha=1, label = 'min - max')
# # ax2.plot(minmax['Date1'], minmax['Lüftung'],color=colo('grau',.7),   linewidth=0.5, label = 'Lüftung')



# ## Achsen & Legende
# ax.set_ylabel(r'\textbf{Wärmeenergie} ($kWh$)')    
# ax2.set_ylim(-600,200)  
# ax.set_ylim(-80,120)  
# # ax.set_yticks([0,100, 500, 1000,1500])  
# ax.set_xlabel('')
# ax.get_yaxis().set_major_formatter(mpl.ticker.FuncFormatter(lambda x, loc: locale.format_string('%d', x, 1))) ## dot as thousand separator
# h0, l0 = ax.get_legend_handles_labels() 
# h2, l2 = ax2.get_legend_handles_labels() 
# legend = plt.legend(h0+h2, l0+l2, ncol=2, loc=1)
# set_legend_linewidth(legend)   

# ax.set(xlim=[pd.to_datetime("05.01.17 00:00:00"),pd.to_datetime("30.04.18 23:00:00")])
# ## X Achse mit Monaten und 2 mal dem Jahr 
# monthlyX(ax)
# # plt.savefig(output_folder + '/' + file_name + '_MINMAX_Übersicht.pdf')
# plt.show() 

Plot Varianten

# # def minmax_varianten():
# fig, ax = plt.subplots(constrained_layout=False) 
# ax2 = ax.twinx()
# ax2.spines['right'].set_position(('axes', 1.0))
# ax3 = ax.twinx()
# ax3.spines['right'].set_position(('axes', 1.15))
# bf['Wärmebilanz_sum'].plot(ax=ax,color=colo('grün',1), linewidth=1, label = 'Wärmebilanz_sum',style='.-')  
# bf['Wärmebilanz_std'].plot(ax=ax2,color=colo('rot',1), linewidth=.6, label = 'Wärmebilanz_std')    
# bf['Wärmebilanz_po'].plot(ax=ax3,color=colo('blau',1), linewidth=1, label = 'Summe positiv')   
# bf['Wärmebilanz_ne'].plot(ax=ax3,color=colo('orange',1), linewidth=1, label = 'Summe negativ')   
# ax.axhline(y=-100, linewidth=0.4,   color=colo('grau',.7), xmin=0.0001, xmax=1)
# ax.axhline(y=100, linewidth=0.4,   color=colo('grau',.7), xmin=0.0001, xmax=1)
# ax.axhline(y=0, linewidth=0.4,   color=colo('black',.7), xmin=0.0001, xmax=1)
# ax.set_ylabel(r'\textbf{Energie}')  
# ax2.set_ylabel(r'\textbf{Standardabweichung}')  
# ax3.set_ylabel(r'\textbf{Summe po / ne}')  
# ax.set_xlabel('')   
# ax.set_ylim(-5000,30000)
# ax2.set_ylim(1.,10)  
# ax3.set_ylim(-10000,30000)  
# h0, l0 = ax.get_legend_handles_labels() 
# h2, l2 = ax2.get_legend_handles_labels() 
# h4, l4 = ax3.get_legend_handles_labels() 
# legend = plt.legend(h0+h2+h4, l0+l2+l4, ncol=2, loc=1)
# set_legend_linewidth(legend) 
# ax.set_xlim(0,64)  
# ## nur die Besten der Besten
# display(bf[bf['Wärmebilanz_sum'].between(-500, 500)].sort_values(by=['Wärmebilanz_std'])[['Wärmebilanz_sum', 'Wärmebilanz_std', 'titel']].style.set_properties(subset=['titel'], **{'width': '600px'}))

Beste Varianten

181 80 1.491278 effizienz(außen_C=-1.0, fort_C=1.0, außen_rF=-5.0, fort_rf=5.0, by=-10.0, zu_Vp=-10.0)
209 -109 1.536273 effizienz(außen_C=-1.0, fort_C=1.0, außen_rF=0.0, fort_rf=5.0, by=-10.0, zu_Vp=0.0)
188 -26 1.575407 effizienz(außen_C=-1.0, fort_C=1.0, außen_rF=-5.0, fort_rf=5.0, by=10.0, zu_Vp=0.0)
177 -84 1.582081 effizienz(außen_C=-1.0, fort_C=1.0, außen_rF=-5.0, fort_rf=0.0, by=0.0, zu_Vp=10.0)
237 5 1.603220 effizienz(außen_C=-1.0, fort_C=1.0, außen_rF=5.0, fort_rf=5.0, by=-10.0, zu_Vp=10.0)
216 -57 1.620828 effizienz(außen_C=-1.0, fort_C=1.0, außen_rF=0.0, fort_rf=5.0, by=10.0, zu_Vp=10.0)

173 -65 1.438039 außen_C-1.0 fort_C1.0 außen_rF-5 fort_rf0 by-10 zu_Vp0
Heizung: 19956 kWh
Lüftungsverluste: -14872 kWh (-74%)
TMWV: -7249 kWh (-36%)
Bilanzfehler: -65 kWh (0%)

180 -20 1.514149 außen_C-1.0 fort_C1.0 außen_rF-5 fort_rf0 by10 zu_Vp10
Heizung: 19956 kWh
Lüftungsverluste: -14827 kWh (-74%)
TMWV: -7249 kWh (-36%)
Bilanzfehler: -20 kWh (0%)

184 101 1.407519 außen_C-1.0 fort_C1.0 außen_rF-5 fort_rf5 by0 zu_Vp-10
Heizung: 19956 kWh
Lüftungsverluste: -14704 kWh (-73%)
TMWV: -7249 kWh (-36%)
Bilanzfehler: 101 kWh (0%)

201 123 1.506070 außen_C-1.0 fort_C1.0 außen_rF0 fort_rf0 by-10 zu_Vp10
Heizung: 19956 kWh
Lüftungsverluste: -14683 kWh (-73%)
TMWV: -7249 kWh (-36%)
Bilanzfehler: 123 kWh (0%)

212 -78 1.450378 außen_C-1.0 fort_C1.0 außen_rF0 fort_rf5 by0 zu_Vp0
Heizung: 19956 kWh
Lüftungsverluste: -14884 kWh (-74%)
TMWV: -7249 kWh (-36%)
Bilanzfehler: -78 kWh (0%)

240 33 1.512975 außen_C-1.0 fort_C1.0 außen_rF5 fort_rf5 by0 zu_Vp10
Heizung: 19956 kWh
Lüftungsverluste: -14773 kWh (-74%)
TMWV: -7249 kWh (-36%)
Bilanzfehler: 33 kWh (0%)

426 194 1.476510 außen_C0.0 fort_C1.0 außen_rF-5 fort_rf5 by-10 zu_Vp10
Heizung: 19956 kWh
Lüftungsverluste: -15168 kWh (-76%)
TMWV: -6692 kWh (-33%)
Bilanzfehler: 194 kWh (0%)

Bokeh Plot

Libraries

# from bokeh.io import output_file, output_notebook, show
# # output_notebook()
# from bokeh.layouts import column
# from bokeh.plotting import figure, ColumnDataSource, Figure,curdoc 
# from bokeh.models import LinearAxis, Range1d, BoxSelectTool, DatetimeTickFormatter, RangeTool, HoverTool
# output_notebook()  

Berechnungen und Testplot



# by    =  .45  # Anteil der Luft, die durch den Bypass geht, gemessen sind 45%
# zu_Vp = 0     # Gesamtluftstrom verändern in %
# lüf   = 1     # 1 ist richtig, 0 ist wahrscheinlich falsch

# title = 'B'+str(by)+' L'+str(lüf)+' Z'+str(zu_Vp)+''
# # kalibrierung(1) 
# # zuweisungen()
# effizienz(by=by, außen_rF=0, zu_rf=0, ab_rF=0, fort_rf=0, zu_Vp=zu_Vp) 
# wärmefluss(title) 


# daten_bok = daten_sub.loc[eins : sechs]#.resample('1H').mean().copy()
# daten_bok = daten_bok.rolling(1000, center=True, min_periods=1).mean()  
# # daten_bok = daten_sub.loc[eins : sechs].copy() 

# daten_tgl = daten_sub.loc[eins : sechs].resample('D').sum().div(240).copy()    
# daten_tgl = daten_tgl.replace(0, np.nan)
# daten_tgl = daten_tgl.dropna(how='all', axis=0)
# daten_tgl = daten_tgl.replace(np.nan, 0)

# # wärmefluss_plot(1,title,0) 

Bokehplot

# daten_bok['date'] = str(daten_bok.index)  
# tools_to_show     = 'box_zoom,reset,pan,undo,redo,xzoom_out,yzoom_out,hover'   ## box_zoom,pan,save,xpan,hover,reset,undo,redo,xzoom_out,yzoom_out,xzoom_in,yzoom_in
# p                 = figure(plot_width=1200, plot_height=600,sizing_mode="scale_width",x_axis_type="datetime",title=None, toolbar_sticky=False,  tools=tools_to_show,  active_drag="box_zoom", toolbar_location="left", output_backend="canvas")

# ## linke Achse
# p.y_range=Range1d(-20,90)
# ## Energie
# p.line(daten_bok.index, daten_bok['Außenluft_Energie'],     line_width=2, color=colo('blau',1),     legend_label="Außenluft_Energie", visible = False)
# p.line(daten_bok.index, daten_bok['Zuluft_Energie'],        line_width=2, color=colo('orange',1),   legend_label="Zuluft_Energie",    visible = False)
# p.line(daten_bok.index, daten_bok['Abluft_Energie'],        line_width=2, color=colo('rot',1),      legend_label="Abluft_Energie",    visible = False)
# p.line(daten_bok.index, daten_bok['Fortluft_Energie'],      line_width=2, color=colo('grün',1),     legend_label="Fortluft_Energie",  visible = False)

# p.line(daten_bok.index, daten_bok['verlorene_Energie'],         line_width=2, color=colo('black',1),    legend_label="verlorene_Energie",     visible = False)
# p.line(daten_bok.index, daten_bok['verlorene_Energie_A+Z'],     line_width=2, color=colo('blau',1),    legend_label="verlorene_Energie_A+Z",  visible = False)
# p.line(daten_bok.index, daten_bok['verlorene_Energie_A+F'],     line_width=2, color=colo('rot',1),    legend_label="verlorene_Energie_A+F",   visible = False) 
# p.line(daten_bok.index, daten_bok['verlorene_Energie_A-F'],     line_width=2, color=colo('orange',1),   legend_label="verlorene_Energie_A-F", visible = False)

# # p.line(daten_bok.index, daten_bok['Nacherhitzer_Energie'],      line_width=2, color=colo('violet',1),    legend_label="Nacherhitzer_Energie", visible = False) 


# ## Temperatur        
# p.line(daten_bok.index, daten_bok['Außenluft_C'],           line_width=2, color=colo('blau',1),     legend_label="Außenluft_C",       visible = False)
# p.line(daten_bok.index, daten_bok['Zuluft_C'],              line_width=2, color=colo('orange',1),   legend_label="Zuluft_C",          visible = False)
# p.line(daten_bok.index, daten_bok['Abluft_C'],              line_width=2, color=colo('rot',1),      legend_label="Abluft_C",          visible = False)
# p.line(daten_bok.index, daten_bok['Fortluft_C'],            line_width=2, color=colo('grün',1),     legend_label="Fortluft_C",        visible = False)
# p.line(daten_bok.index, daten_bok['L_Zulufttemperatur'],    line_width=2, color=colo('grün',.7),    legend_label="Zuluft_C_intelli",  visible = False)
# ## rel LF
# p.line(daten_bok.index, daten_bok['Außenluft_rF'],          line_width=2, color=colo('blau',1),     legend_label="Außenluft_rF",      visible = False)
# p.line(daten_bok.index, daten_bok['Zuluft_rF'],             line_width=2, color=colo('orange',1),   legend_label="Zuluft_rF",         visible = False)
# p.line(daten_bok.index, daten_bok['Abluft_rF'],             line_width=2, color=colo('rot',1),      legend_label="Abluft_rF",         visible = False)
# p.line(daten_bok.index, daten_bok['Fortluft_rF'],           line_width=2, color=colo('grün',1),     legend_label="Fortluft_rF",       visible = False)
# ## Wassergehalt
# # p.line(daten_bok.index, daten_bok['Außenluft_WG'],          line_width=2, color=colo('blau',1),     legend_label="Außenluft_WG",      visible = False)
# # p.line(daten_bok.index, daten_bok['Zuluft_WG'],             line_width=2, color=colo('orange',1),   legend_label="Zuluft_WG",         visible = False)
# # p.line(daten_bok.index, daten_bok['Abluft_WG'],             line_width=2, color=colo('rot',1),      legend_label="Abluft_WG",         visible = False)
# # p.line(daten_bok.index, daten_bok['Fortluft_WG'],           line_width=2, color=colo('grün',1),     legend_label="Fortluft_WG",       visible = False)
# ## Gas & Heizung
# p.line(daten_bok.index, daten_bok['S_Gas_Energie_'],        line_width=2, color=colo('grau',.8),    legend_label="S_Gas_Energie",    visible = False)
# p.line(daten_bok.index, daten_bok['S_Kessel_Energie'],      line_width=2, color=colo('blau',.8),    legend_label="S_Kessel_Energie",  visible = False)
# ## Lüftung
# p.line(daten_bok.index, daten_bok['Lüftung_rein'],          line_width=2, color=colo('grün',.8),    legend_label="Lüftung_rein",      visible = False)
# p.line(daten_bok.index, daten_bok['Lüftung_raus'],          line_width=2, color=colo('violet',.8),  legend_label="Lüftung_raus",      visible = False)
# # p.line(daten_bok.index, daten_bok['Lüftung_TMWV'],          line_width=2, color=colo('blau',.8),    legend_label="Lüftung_TMWV",      visible = False)
# ## Luftdruck
# p.line(daten_bok.index, daten_bok['W_Luftdruck'],           line_width=2, color=colo('violet',.8),  legend_label="W_Luftdruck",       visible = False)
# # p.line(daten_bok.index, daten_bok['L_Zuluft_Druck'],        line_width=2, color=colo('violet',.8),  legend_label="L_Zuluft_Druck",    visible = False)
# ## Wärmebilanz
# p.line(daten_bok.index, daten_bok['S_Solar_Energie'],       line_width=2, color=colo('gelb',1),     legend_label="Solar_Energie",     visible = False)
# p.line(daten_bok.index, daten_bok['S_Heizung_Energie'],     line_width=2, color=colo('blau',1.2),   legend_label="Heizung_Energie",   visible = False)
# p.line(daten_bok.index, daten_bok['S_FriWa_Energie_Prim'],  line_width=2, color=colo('rot',.8),     legend_label="FriWa_Energie",     visible = False)
# p.line(daten_bok.index, daten_bok['Nacherhitzer_Energie'],  line_width=2, color=colo('orange',.8),  legend_label="Nacherhitzer",      visible = False)
# p.line(daten_bok.index, daten_bok['Wärmespeicherkap'],      line_width=2, color=colo('orange',1),   legend_label="Wärmespeicherkap",  visible = False)
# p.line(daten_bok.index, daten_bok['Strom'],                 line_width=2, color=colo('gelb',.8),    legend_label="Strom",             visible = False)
# p.line(daten_bok.index, daten_bok['Wärme_durch_Personen'],  line_width=2, color=colo('violet',1),   legend_label="Personenwärme",     visible = False)
# p.line(daten_bok.index, daten_bok['Lüftung'],               line_width=2, color=colo('grau',1.3),   legend_label="Lüftung",           visible = False)
# p.line(daten_bok.index, daten_bok['TMWV'],                  line_width=2, color=colo('rot',1),      legend_label="TMWV",              visible = False)
# p.line(daten_bok.index, daten_bok['Wärmebilanz'],           line_width=2, color=colo('grün',1.5),   legend_label="Wärmebilanz",       visible = True)

# ## rechte Achse 
# p.extra_y_ranges = {"zwei": Range1d(start=0, end=1800)}
# p.line(daten_bok.index, daten_bok['L_Zuluft_VPunkt'],       line_width=2, color=colo('grau',1),     legend_label="VPunkt",    y_range_name="zwei",      visible = True)
# p.line(daten_bok.index, daten_bok['Vpunkt_extern'],         line_width=2, color=colo('rot',1),      legend_label="VPunkt by", y_range_name="zwei",      visible = False)
# p.line(daten_bok.index, daten_bok['L_Seminarraum_1_CO2'],   line_width=2, color=colo('blau',1),     legend_label="CO2 1",     y_range_name="zwei",      visible = False)
# p.line(daten_bok.index, daten_bok['L_Seminarraum_2_CO2'],   line_width=2, color=colo('rot',1),      legend_label="CO2 2",     y_range_name="zwei",      visible = False) 
# p.add_layout(LinearAxis(y_range_name="zwei"), 'right')

# ## 2. rechte Achse 
# p.extra_y_ranges['drei'] = Range1d(start=0, end=180)
# p.line(daten_bok.index, daten_bok['L_Zuluft_Druck'],        line_width=2, color=colo('violet',.8),  legend_label="L_Zuluft_Druck", y_range_name="drei", visible = True)
# p.add_layout(LinearAxis(y_range_name="drei"), 'right')



# ## hoverBox 
# hover                 = p.select(dict(type=HoverTool)) 
# hover.tooltips        = [("", "@y{0.0}")]  
# hover.mode            = 'vline'   
# p.legend.location     = "top_right"
# p.legend.click_policy = "hide"
# p.add_tools(BoxSelectTool(dimensions="width")) 
# p.xaxis.formatter=DatetimeTickFormatter(hours=["%d.%m. %H:%M"],days=["%d.%m. %H:%M"],months=["%d. %m. %Y"],years=["%d. %m. %Y"],)
# p.xaxis.axis_label_text_font_size  = "10pt"
# p.xaxis.major_label_text_font_size = "10pt"
# p.yaxis.axis_label_text_font_size  = "10pt"
# p.yaxis.major_label_text_font_size = "10pt"
# output_file('Wärmebilant_minl.html')
# show(p)

Details

# fig, ax = plt.subplots() 
# ax2 = ax.twinx()
# daten_bok['Wärmebilanz'].plot(ax=ax,color=colo('grün',1.2), linewidth=1, label = 'Wärmebilanz')  
# # daten_bok['Lüftung'].plot(ax=ax,color=colo('grau',1), linewidth=1, label = 'Lüftung')   
# # daten_bok['Lüftung_rein'].plot(ax=ax,color=colo('rot',1), linewidth=1, label = 'Lüftung_rein')  
# # daten_bok['Lüftung_raus'].plot(ax=ax,color=colo('blau',1), linewidth=1, label = 'Lüftung_raus')   
# # daten_bok['Nacherhitzer_Energie'].plot(ax=ax,color=colo('gelb',1), linewidth=1, label = 'Nacherhitzer')   
# daten_bok['S_Heizung_Energie'].plot(ax=ax,color=colo('orange',1), linewidth=1, label = 'Heizung')   


# daten_bok['L_Zuluft_Druck'].plot(ax=ax2,color=colo('violet',1.4), linewidth=1, label = 'Zuluft_Druck')   

# daten_bok['L_Zuluft_VPunkt'].div(15).plot(ax=ax2,color=colo('grau',1.4), linewidth=1, label = 'Zuluft V_Punkt')   



# ax.axhline(y=0, linewidth=0.6,   color=colo('black',1), xmin=0.0001, xmax=.98)
# ax.set_ylabel(r'\textbf{Energie} $kWh$')  
# ax2.set_ylabel(r'\textbf{Druck} $hPa$')  
# ax.set_xlabel('')   
# ax.set_ylim(-2,10)  
# ax2.set_ylim(70,115)  
# h0, l0 = ax.get_legend_handles_labels() 
# h2, l2 = ax2.get_legend_handles_labels() 
# legend = plt.legend(h0+h2, l0+l2, ncol=4, loc=1)
# set_legend_linewidth(legend) 
# ax.set(xlim=[pd.to_datetime('2018-02-01'),pd.to_datetime('2018-02-03')])  

Scatterplot, allesmögliche gegen den Bilanzfehler

# # konstante Zeiten:
# # Bilanzfehler:  3 bis 4    '2017-12-08 22:00:00' : '2017-12-09 09:00:00'
# # Bilanzfehler:  0 bis -2   '2018-02-02 23:00:00' : '2018-02-03 03:00:00'
# # Bilanzfehler: -1 bis 1    '2018-02-09 02:15:00' : '2018-02-09 05:30:00'
# # Bilanzfehler:   fast 0    '2018-02-09 17:00:00' : '2018-02-09 22:00:00'
# # Bilanzfehler:  0 bsi 1    '2018-02-10 04:00:00' : '2018-02-10 12:00:00'
# # gesamter Zeitraum         '2017-12-06 00:00:00' : '2018-02-20 23:59:45' geht nicht wegen der Lücken

#  ## Funktion kalibriert und gib Strings für copy&paste aus
# def kalibrieren(X,Y):
#     polyfit = np.polyfit(X,Y,deg=1)
#     schaetzer = np.poly1d(polyfit)
# #     print('daten_kalibriert[\''+X.name+'\'] = daten[\''+X.name+'\'] * ' +str(schaetzer[1]) +   ' + ' +str(schaetzer[0])    )
#     return schaetzer(X)

# #daten_scatter = daten_sub[['Wärmebilanz','L_Zuluft_Druck','Lüftung','S_Heizung_Energie']]
# daten_scatter = daten_sub[['Wärmebilanz','Lüftung','S_Heizung_Energie','Außenluft_C','Zuluft_C','Abluft_C','Fortluft_C','Außenluft_rF','Zuluft_rF','Abluft_rF','Fortluft_rF','Außenluft_Energie','Zuluft_Energie','Abluft_Energie','Fortluft_Energie','L_Zuluft_Druck','L_Zuluft_VPunkt']]
# # daten_scatter = daten_scatter.loc['2018-02-06 00:00:00' : '2018-02-15 23:59:45'].resample('10min').mean() 
# daten_scatter = daten_scatter.rolling(1000, center=True, min_periods=1).mean()  

# # daten_scatter['L_Zuluft_Druck1'] = kalibrieren(daten_scatter['Wärmebilanz'],daten_scatter['Lüftung'])

# for column in daten_scatter:
#     if column == 'Wärmebilanz': 
#         continue

#     ## Polynome für Regerssionsgerade berechnen und ausgeben 
#     w = np.polyfit(daten_scatter['Wärmebilanz'],daten_scatter[column],1)
#     p = np.poly1d(w)    
#     ## Punktwolke plotten  
#     fig, ax = plt.subplots(nrows=2, ncols=1, figsize=(4, 3.5), dpi=230,constrained_layout=False,)
#     ax0 = plt.subplot(211)  
#     ax2 = plt.subplot(212) 
#     ax3 = ax2.twinx() 

#     ax0.set_title(column)
#     ax0.scatter(daten_scatter['Wärmebilanz'],daten_scatter[column], label=column, color=colo('blau',1), s=1) 


#     daten_scatter[column].plot(ax=ax2,linewidth=0.5,color=colo('blau',1))
#     daten_scatter['Wärmebilanz'].plot(ax=ax3,linewidth=0.5,color=colo('grün',1)) 

#     ax2.set_xlabel('')
#     ax2.xaxis.set_tick_params(width=0.5)
#     ax2.yaxis.set_tick_params(width=0.5) 

#     h0, l0 = ax2.get_legend_handles_labels()  
#     legend = plt.legend(h0, l0, borderpad=0.15,labelspacing=0.1,  frameon=True, edgecolor="black", ncol=4, loc=1,framealpha=1, facecolor='white') 
#     legend.get_frame().set_linewidth(0.3)   
#     fig.tight_layout()
#     plt.show() 


Funktionsaufrufe



# wärmefluss(1)
# daten_tgl = daten_sub.resample('D').sum().div(240)  
# wärmefluss_plot(1,'title')

# bypass 40 % = B40
# Lüftung außen + zuluft = L0
# Lüftung außen  = L1
# Zuweisungen ja = Z1



außen_C  = 0
zu_C     = 0
ab_C     = 0 
fort_C   = 0 
außen_rF = 0
zu_rf    = 0 
ab_rF    = 0 
fort_rf  = 0
by       = 0 # Anteil der Luft, die durch den Bypass geht, gemessen sind 45%
zu_Vp    = 0    # Gesamtluftstrom verändern in % 

# außen_C  = 1.0 
# fort_C   = 1.0 
# außen_rF = -5 
# fort_rf  = 5 
# by       = -10 
# zu_Vp    = 10

## Energie der Luftströme und die Effiziens der WRG berechnen
title = 'Lüftung mit Fehlerbalken'
title = 'außen_C'+str(außen_C)  +  ' zu_C'+str(zu_C)  +  ' ab_C'+str(ab_C)  +  ' fort_C'+str(fort_C)  +  ' außen_rF'+str(außen_rF)  +  ' zu_rf'+str(zu_rf)  +  ' ab_rF'+str(ab_rF)  +  ' fort_rf'+str(fort_rf)  +  ' by'+str(by)  +  ' zu_Vp'+str(zu_Vp) 
effizienz(    außen_C=außen_C,            zu_C=zu_C,            ab_C=ab_C,            fort_C=fort_C,            außen_rF=außen_rF,            zu_rf=zu_rf,            ab_rF=ab_rF,            fort_rf=fort_rf,            by=by,            zu_Vp=zu_Vp)
wärmefluss(title) 
# print(title)
# print(daten_sub['Wärmebilanz'].sum()/240)




## Wärmeflussbilanz auf täglicher Basis erstellen
daten_tgl = daten_sub.resample('D').sum().div(240).copy()    
daten_tgl = daten_tgl.replace(0, np.nan)
daten_tgl = daten_tgl.dropna(how='all', axis=0)
daten_tgl = daten_tgl.replace(np.nan, 0)


## err=0 - Bilanzfehler in grün
## err=1 - Fehlerbalken Lüftung 
wärmefluss_plot(1,'Standard',err=0,nr=99) 








## WRG Effizienz Plot
# effizienz_plot(title) 
# effizienz_bax(title)




## einzelne Tageswerte plotten zum Vergleich untereinander (drei Plotz mit vielen Subplots)
# bilanz(1,2,2018)   
# tageswerte(1,2,2018)
# luftwerte(1,2,2018) 

Heizung: 19956 kWh
Lüftungsverluste: -13746 kWh (-68%)
TMWV: -7306 kWh (-36%)
Bilanzfehler: 1396 kWh (6%)



fig, ax = plt.subplots(constrained_layout=True, figsize=(8,2.5))   
ax2 = ax.twinx()
daten_sub['Wärmebilanz'].resample("D").sum().div(240).plot(ax=ax,color=colo('grün',1), linewidth=.5, label = 'Wärmebilanz', style='-')   
# daten_sub['L_Seminarraum_1_CO2'].resample("D").mean().plot(ax=ax2,color=colo('rot',1), linewidth=.5, label = 'CO2 Mittelwert', style='-')  
# daten_sub['S_Solarstrahlung'].resample("D").mean().plot(ax=ax2,color=colo('orange',1), linewidth=.5, label = 'Solarstrahlung Mittelwert', style='-')  
# daten_sub['W_Temperatur'].resample("D").mean().plot(ax=ax2,color=colo('rot',1), linewidth=.5, label = 'Temperatur Wetterstation Mittelwert', style='-')  
daten_sub['Außenluft_Energie'].resample("D").sum().div(240).plot(ax=ax2,color=colo('blau',1), linewidth=.5, label = 'Außenluft_Energie Summe', style='-')  
# daten_sub['h21_Außenluft'].resample("D").mean().plot(ax=ax2,color=colo('rot',1), linewidth=.5, label = 'Enthalpie_Außenluft Mittelwert', style='-')  
daten_sub['Vpunkt_extern'].resample("D").mean().plot(ax=ax2,color=colo('blau',1), linewidth=.5, label = 'Vpunkt_extern Mittelwert', style='-')  
# daten_sub['L_Aussenlufttemperatur_1'].resample("D").mean().plot(ax=ax2,color=colo('blau',1), linewidth=.5, label = 'Aussenlufttemperatur_1 Mittelwert', style='-')  
# daten_sub['Personen_1'].resample("D").sum().div(240).plot(ax=ax,color=colo('rot',1), linewidth=.5, label = 'PersonenStunden', style='-')  
# daten_sub.resample('D')['Personen_1'].agg(['max']).plot(ax=ax2,color=colo('blau',1), linewidth=.5, label = 'Personen max', style='-')  

## 2 tages Mittelwerte
# daten_sub['Wärmebilanz'].resample("2D").sum().div(480).plot(ax=ax,color=colo('grün',1), linewidth=.5, label = 'Wärmebilanz', style='-')   
# daten_sub['L_Aussenlufttemperatur_1'].resample("2D").mean().plot(ax=ax2,color=colo('blau',1), linewidth=.5, label = 'Aussenlufttemperatur_1 Mittelwert', style='-')  


ax.axhline(y=0, linewidth=0.4,   color=colo('black',.7), xmin=0.0001, xmax=1)



# ax.set_ylabel(r'\textbf{Bilanzfehler} ($kWh$)')    
ax.set_ylim(-50,150) 
# ax2.set_ylim(-30,90)
date_form = DateFormatter("%b")
ax.xaxis.set_major_formatter(date_form)
plt.xticks(rotation=0, ha='right') 
ax.set_xlabel('')
h0, l0 = ax.get_legend_handles_labels() 
h2, l2 = ax2.get_legend_handles_labels() 
legend = plt.legend(h0+h2, l0+l2, ncol=3, loc=1)
set_legend_linewidth(legend)   

ax.set(xlim=[pd.to_datetime("2017-11-01"),pd.to_datetime("2017-11-20")])
plt.show()
# daten_sub['L_Seminarraum_1_CO2'].resample("D").mean()
# daten_scatter = daten_sub.loc['2017.08.01':'2018.04.30'].resample("D").sum().div(240).copy

# fig, ax = plt.subplots(nrows=2, ncols=1, figsize=(4, 3.5), dpi=230,constrained_layout=False,)
# ax0 = plt.subplot(111)   
# ax0.set_title('Außenluft_Energie')
# ax0.scatter(daten_scatter('Wärmebilanz'),daten_scatter('Außenluft_Energie'), label='Außenluft_Energie', color=colo('blau',1), s=1) 
# fig.tight_layout()
# plt.show() 


fig, ax = plt.subplots(constrained_layout=True, figsize=(8,3.5))   
ax2 = ax.twinx()
daten_sub['Nacherhitzer_Energie'].plot(ax=ax,color=colo('blau',1), linewidth=.5, label = 'Nacherhitzer_Energie', style='-')   
daten_sub['L_Zuluft_VPunkt'].plot(ax=ax2,color=colo('violet',1), linewidth=.5, label = 'L_Zuluft_VPunkt', style='-')   

daten_sub['L_Zulufttemperatur'].plot(ax=ax,color=colo('rot',1), linewidth=.5, label = 'L_Zulufttemperatur', style='-')   
daten_sub['Abluft_C'].plot(ax=ax,color=colo('orange',1), linewidth=.5, label = 'Abluft_C', style='-')   
WGR_kal['Zuluft_nach_NE_h'].plot(ax=ax,color=colo('rot',1.4), linewidth=1, label = 'Enthalpie Zuluft nach NE', style='-')   
daten_sub['h11_Abluft'].plot(ax=ax,color=colo('orange',1.4), linewidth=1, label = 'Enthalpie Abluft', style='-')   


# WGR_kal['Zuluft_vor_NE_h'].plot(ax=ax,color=colo('gelb',.8), linewidth=.5, label = 'Enthalpie Zuluft vor NE', style='-')   
# daten_sub['Außenluft_C'].plot(ax=ax,color=colo('grün',1), linewidth=.5, label = 'Außenluft_C', style='-')   

ax.axhline(y=0, linewidth=0.4,   color=colo('black',.7), xmin=0.0001, xmax=1)



# ax.set_ylabel(r'\textbf{Bilanzfehler} ($kWh$)')    
ax.set_ylim(0,50) 
# ax2.set_ylim(-33,100)
date_form = DateFormatter("%d.%m. %H")
ax.xaxis.set_major_formatter(date_form)
plt.xticks(rotation=0, ha='center') 
ax.set_xlabel('')
h0, l0 = ax.get_legend_handles_labels() 
h2, l2 = ax2.get_legend_handles_labels() 
legend = plt.legend(h0+h2, l0+l2, ncol=3, loc=1)
set_legend_linewidth(legend)   

#ax.set(xlim=[pd.to_datetime("2017.11.13 05:00:00"),pd.to_datetime("2017.11.13 23:00:00")])


# ax.set(xlim=[pd.to_datetime("2017.12.05 07:00:00"),pd.to_datetime("2017.12.12 12:00:00")])

ax.set(xlim=[pd.to_datetime("2018.02.16 07:00:00"),pd.to_datetime("2018.02.17 12:00:00")])
# ax.set(xlim=[pd.to_datetime("2017.12.08 07:00:00"),pd.to_datetime("2017.12.09 12:00:00")])
plt.show()

# daten_sub.head()

CO2 - Menschen

wärmefluss(title) 
daten_tgl = daten_sub.resample('D').sum().div(240).copy()    
daten_tgl = daten_tgl.replace(0, np.nan)
daten_tgl = daten_tgl.dropna(how='all', axis=0)
daten_tgl = daten_tgl.replace(np.nan, 0)

Heizung: 19956 kWh
Lüftungsverluste: -13746 kWh (-68%)
TMWV: -7306 kWh (-36%)
Bilanzfehler: 1396 kWh (6%)

#print (daten_sub.resample('D')['Personen_1'].agg(['max']))

daten_tgl['Personen_max_1'] = daten_sub.resample('D')['Personen_1'].agg(['max'])  
daten_tgl['Personen_max_2'] = daten_sub.resample('D')['Personen_2'].agg(['max'])  

daten_tgl['Personen_max'] = daten_tgl['Personen_max_1']  + daten_tgl['Personen_max_2'] 
daten_tgl['Personen']     = daten_tgl['Personen_1']  + daten_tgl['Personen_2'] 

daten_tgl['Personen_max_korr'] = daten_tgl['Personen_max'] *.6
daten_tgl['Personen_korr']     = daten_tgl['Personen']  -5

#display(daten_tgl['Personen_max'])

fig, ax = plt.subplots(figsize=(5.9,2.2))    
ax2 = ax.twinx() 

daten_tgl['Personen'].plot(ax=ax,color=colo('blau',1), linewidth=.5, label = 'Personenstunden',style='-')   
daten_tgl['Personen_max'].plot(ax=ax2,color=colo('rot',1), linewidth=.5, label = 'Personen_max',style='-')    

# daten_tgl['Personen_korr'].plot(ax=ax,color=colo('blau',1), linewidth=.5, label = 'Personenstunden',style='-')   
# daten_tgl['Personen_max_korr'].plot(ax=ax2,color=colo('grün',1), linewidth=.5, label = 'Personen_max',style='-')    

# daten_co2['L_Seminarraum_1_CO2'].plot(ax=ax,color=colo('grün',1.7), linewidth=1, label = 'CO2_1')   
# daten_co2['L_Seminarraum_2_CO2'].plot(ax=ax,color=colo('blau',1.7), linewidth=1, label = 'CO2_2')   

# daten_tgl['1CO2med'].div(24).plot(ax=ax,color=colo('grün',1), linewidth=1, label = 'CO2_1mef')   
# daten_tgl['2CO2med'].div(24).plot(ax=ax,color=colo('blau',1), linewidth=1, label = 'CO2_2med')   


# jeden Donnerstag eine Linie
from datetime import date, timedelta
dstart = date(2017,5,1)
dend = date(2018,4,30) 
days = [dstart + timedelta(days=x) for x in range((dend-dstart).days + 1) if (dstart + timedelta(days=x)).weekday() == 3]

xposition = [pd.to_datetime('05.01.17'), pd.to_datetime('30.04.18')]
for xc in days:
    ax.axvline(x=xc, ymin=0, ymax=0.02, color='k', linestyle='-',linewidth=0.5)

ax.set_ylabel(r'\textbf{Personenstunden} $nh$')  
ax.set_ylim(0,125)  
ax.set_yticks([0,25, 50, 75,100])  
ax2.set_ylabel(r'\textbf{Personen} $n$')  
ax2.set_ylim(0,50)  
ax2.set_yticks([0,10, 20, 30,40])  

ax.set_xlabel('')  
h0, l0 = ax.get_legend_handles_labels() 
h2, l2 = ax2.get_legend_handles_labels() 
legend = plt.legend(h0+h2, l0+l2, ncol=2, loc=2)
set_legend_linewidth(legend) 
# ax.set(xlim=[pd.to_datetime('2018-02-16'),pd.to_datetime('2018-02-20')])  
ax.set(xlim=[pd.to_datetime("05.01.17 00:00:00"),pd.to_datetime("30.04.18 23:00:00")])
## X Achse mit Monaten und 2 mal dem Jahr :-)
monthlyX(ax)

plt.savefig(output_folder + '/' + file_name + '_Personen_durch_CO2.pdf')  

Heizung + 2 Stunden

## Die Bilanz soll nur erstellt werden, wenn die Heizung läuft + 2 Stunden in denen die Wärme durch die Lüftung auch wieder raus ist.
## Hier nur als Beispiel mit Heizung_Vpunkt unter 1050 und 


# daten_flag = daten_sub.copy()
# daten_flag["Lüftung1"]                                                               = daten_flag["Lüftung"]   
# daten_flag["Lüftung_flag"]                                                           = 0

#### codeblock ALT
# daten_flag["S_Heizung_Vpunkt_flag"]                                                  = np.nan
# daten_flag.loc[daten_flag["S_Heizung_Vpunkt"]      < 1050,     "S_Heizung_Vpunkt_flag"] = 1
# daten_flag["S_Heizung_Vpunkt_flag"].fillna(method = "ffill",limit = 480,     inplace = True)
# daten_flag.loc[daten_flag["S_Heizung_Vpunkt_flag"] == 1,     "Lüftung"]               = 0
# daten_flag.loc[daten_flag["S_Heizung_Vpunkt_flag"] == 1,     "TMWV"]                  = 0
#### codeblock ALT

# daten_flag["S_Heizung_Vpunkt_flag"]                                                    = 0
# daten_flag.loc[daten_flag["S_Heizung_Vpunkt"]      > 1050,     "S_Heizung_Vpunkt_flag"] = 1
# daten_flag["S_Heizung_Vpunkt_flag"].fillna(value = 1,limit = 480,     inplace = True)
# daten_flag.loc[daten_flag["S_Heizung_Vpunkt_flag"] == 0,     "Lüftung"]                = 0



# daten_flag.loc[daten_flag["S_Heizung_Vpunkt_flag"] == 1,     "Lüftung_flag"]               = 1

# fig, ax = plt.subplots() 
# ax2 = ax.twinx() 


# daten_flag['S_Heizung_Vpunkt'].plot(ax=ax,color=colo('grün',1), linewidth=1, label = 'Heizung',style='-')   
# daten_flag['S_Heizung_Vpunkt_flag'].plot(ax=ax2,color=colo('blau',1), linewidth=1, label = 'S_Heizung_flag',style='-')   
# # daten_flag['Lüftung1'].plot(ax=ax2,color=colo('orange',1), linewidth=1, label = 'Lüftung1',style='-')   
# daten_flag['Lüftung'].plot(ax=ax2,color=colo('rot',1), linewidth=1, label = 'Lüftung',style='-')   
# # daten_flag['TMWV'].plot(ax=ax2,color=colo('violet',1), linewidth=1, label = 'TMWV',style='-')   
# ax.axhline(y=1050, linewidth=0.4,   color=colo('black',.7), xmin=0.0001, xmax=1)


# # ax.set_ylabel(r'\textbf{Energie} $kWh$')  
# # ax2.set_ylabel(r'\textbf{Druck} $hPa$')  
# ax.set_xlabel('')   
# # ax.set_ylim(850,2100)  
# ax2.set_ylim(-10,3)  
# h0, l0 = ax.get_legend_handles_labels() 
# h2, l2 = ax2.get_legend_handles_labels() 
# legend = plt.legend(h0+h2, l0+l2, ncol=4, loc=1)
# set_legend_linewidth(legend) 
# # ax.set(xlim=[pd.to_datetime('2018-02-16'),pd.to_datetime('2018-02-20')])  
# ax.set(xlim=[pd.to_datetime('2017-09-03 00:00:00'),pd.to_datetime('2017-09-03 23:30:00')])  

Volumenstroeme

effizienz()
# wärmefluss('title') 

MinMax Plot

## läuft
sampling     = '15s'
mist         = daten_sub.loc['2017-05-01':'2018-04-30'].resample(sampling).min()
daten_tgl    = daten_sub.copy()
stat         = pd.DataFrame()
stat['Date'] = mist.index 

stat['L_Zuluft_Druck']   = daten_tgl.loc['2017-05-01':'2018-04-30']['L_Zuluft_Druck'].resample(sampling).mean().values

stat['V_Punkt_mean_in']   = daten_tgl.loc['2017-05-01':'2018-04-30']['Vpunkt_intern'].resample(sampling).mean().values
stat['V_Punkt_min_in']    = daten_tgl.loc['2017-05-01':'2018-04-30']['Vpunkt_intern'].resample(sampling).min().values
stat['V_Punkt_max_in']    = daten_tgl.loc['2017-05-01':'2018-04-30']['Vpunkt_intern'].resample(sampling).max().values

stat['V_Punkt_mean_ex']   = daten_tgl.loc['2017-05-01':'2018-04-30']['Vpunkt_extern'].resample(sampling).mean().values
stat['V_Punkt_min_ex']    = daten_tgl.loc['2017-05-01':'2018-04-30']['Vpunkt_extern'].resample(sampling).min().values
stat['V_Punkt_max_ex']    = daten_tgl.loc['2017-05-01':'2018-04-30']['Vpunkt_extern'].resample(sampling).max().values


# stat['V_Punkt_median'] = daten_tgl.loc['2017-05-01':'2018-04-30']['Vpunkt_extern'].resample('1D').median().values
# stat['S_Gas_Vpunkt']   = daten_tgl.loc['2017-05-01':'2018-04-30']['S_Gas_Vpunkt'].resample('1D').sum().values/240/1000
# stat['L_Aussenlufttemperatur_1'] = daten_tgl.loc['2017-05-01':'2018-04-30']['L_Aussenlufttemperatur_1'].resample('1D').mean().values


fig, ax = plt.subplots()

ax.fill_between(stat['Date'], stat['V_Punkt_min_ex'], stat['V_Punkt_max_ex'],edgecolor='black', facecolor=colo('blau',1.5), alpha=1, label = 'min - max')
ax.plot(stat['Date'], stat['V_Punkt_mean_ex'],color=colo('blau',1),   linewidth=0.5, label = 'Mittelwert extern')

ax.fill_between(stat['Date'], stat['V_Punkt_min_in'], stat['V_Punkt_max_in'],edgecolor='black', facecolor=colo('grün',1.5), alpha=.6, label = 'min - max')
ax.plot(stat['Date'], stat['V_Punkt_mean_in'],color=colo('grün',1),   linewidth=0.5, label = 'Mittelwert intern')

ax2 = ax.twinx() 
ax2.plot(stat['Date'], stat['L_Zuluft_Druck'],color=colo('rot',1),   linewidth=0.5, label = 'L_Zuluft_Druck') 
# ax2.plot(stat['Date'], stat['S_Gas_Vpunkt'],color=colo('rot',1),   linewidth=0.5, label = 'Gasverbrauch') 
# ax2.set_ylabel(r'\textbf{Gasverbrauch} (m\textsuperscript{3}/d)')  
# ax2.set(ylim=0) 
ax2.set(ylim=[70,100]) 
# ax3 = ax.twinx() 
# ax3.plot(stat['Date'], stat['L_Aussenlufttemperatur_1'],color=colo('orange',1),   linewidth=0.5, label = 'Gasverbrauch')
# ax3.set_ylabel(r'\textbf{Temperatur} ($^\circ$C)')  

## Achsen & Legende
ax.set_ylabel(r'\textbf{Volumenstrom} (m\textsuperscript{3}/h)')    
ax.set(ylim=0) 
ax.set_yticks([0,100, 500, 1000,1500])  
ax.set_xlabel('')
ax.get_yaxis().set_major_formatter(mpl.ticker.FuncFormatter(lambda x, loc: locale.format_string('%d', x, 1))) ## dot as thousand separator
h0, l0 = ax.get_legend_handles_labels() 
# h2, l2 = ax2.get_legend_handles_labels() 
legend = plt.legend(h0, l0, ncol=2, loc=2)
set_legend_linewidth(legend)   

## jeden Donnerstag eine Linie
# from datetime import date, timedelta
# dstart = date(2017,5,1)
# dend = date(2018,4,30) 
# days = [dstart + timedelta(days=x) for x in range((dend-dstart).days + 1) if (dstart + timedelta(days=x)).weekday() == 3]

# xposition = [pd.to_datetime('05.01.17'), pd.to_datetime('30.04.18')]
# for xc in days:
#     ax.axvline(x=xc, color='k', linestyle='-',linewidth=0.5)



ax.set(xlim=[pd.to_datetime("2017-11-01"),pd.to_datetime("2017-11-03")])
## X Achse mit Monaten und 2 mal dem Jahr :-)
# monthlyX(ax)
# plt.savefig(output_folder + '/' + file_name + '_Volumenstroeme_tgl_Linie.pdf')


plt.show()
## läuft
sampling     = '2D'
mist         = daten_sub.loc['2017-05-01':'2018-04-30'].resample(sampling).min()
daten_tgl    = daten_sub.copy()
stat         = pd.DataFrame()
stat['Date'] = mist.index 

stat['V_Punkt_mean_in']   = daten_tgl.loc['2017-05-01':'2018-04-30']['Vpunkt_intern'].resample(sampling).mean().values
stat['V_Punkt_min_in']    = daten_tgl.loc['2017-05-01':'2018-04-30']['Vpunkt_intern'].resample(sampling).min().values
stat['V_Punkt_max_in']    = daten_tgl.loc['2017-05-01':'2018-04-30']['Vpunkt_intern'].resample(sampling).max().values

stat['V_Punkt_mean_ex']   = daten_tgl.loc['2017-05-01':'2018-04-30']['Vpunkt_extern'].resample(sampling).mean().values
stat['V_Punkt_min_ex']    = daten_tgl.loc['2017-05-01':'2018-04-30']['Vpunkt_extern'].resample(sampling).min().values
stat['V_Punkt_max_ex']    = daten_tgl.loc['2017-05-01':'2018-04-30']['Vpunkt_extern'].resample(sampling).max().values


# stat['V_Punkt_median'] = daten_tgl.loc['2017-05-01':'2018-04-30']['Vpunkt_extern'].resample('1D').median().values
# stat['S_Gas_Vpunkt']   = daten_tgl.loc['2017-05-01':'2018-04-30']['S_Gas_Vpunkt'].resample('1D').sum().values/240/1000
# stat['L_Aussenlufttemperatur_1'] = daten_tgl.loc['2017-05-01':'2018-04-30']['L_Aussenlufttemperatur_1'].resample('1D').mean().values


fig, ax = plt.subplots()

ax.plot(stat['Date'], stat['V_Punkt_mean_ex'],color=colo('blau',1),   linewidth=0.8, label = 'Mittelwert extern')
ax.plot(stat['Date'], stat['V_Punkt_mean_in'],color=colo('grün',1),   linewidth=0.8, label = 'Mittelwert intern')

ax.fill_between(stat['Date'], stat['V_Punkt_min_ex'], stat['V_Punkt_max_ex'],edgecolor='black', facecolor=colo('blau',1.7), alpha=.8, label = 'Extrema extern')
ax.fill_between(stat['Date'], stat['V_Punkt_min_in'], stat['V_Punkt_max_in'],edgecolor='black', facecolor=colo('grün',1.5), alpha=.6, label = 'Extrema intern')
# ax2 = ax.twinx() 
# ax2.plot(stat['Date'], stat['S_Gas_Vpunkt'],color=colo('rot',1),   linewidth=0.5, label = 'Gasverbrauch') 
# ax2.set_ylabel(r'\textbf{Gasverbrauch} (m\textsuperscript{3}/d)')  
# ax2.set(ylim=0) 
# ax3 = ax.twinx() 
# ax3.plot(stat['Date'], stat['L_Aussenlufttemperatur_1'],color=colo('orange',1),   linewidth=0.5, label = 'Gasverbrauch')
# ax3.set_ylabel(r'\textbf{Temperatur} ($^\circ$C)')  

## Achsen & Legende
ax.set_ylabel(r'\textbf{Volumenstrom} (m\textsuperscript{3}/h)')    
ax.set(ylim=[0,2200]) 
ax.set_yticks([0,100, 500, 1000,1500])  
ax.set_xlabel('')
ax.get_yaxis().set_major_formatter(mpl.ticker.FuncFormatter(lambda x, loc: locale.format_string('%d', x, 1))) ## dot as thousand separator
h0, l0 = ax.get_legend_handles_labels() 
# h2, l2 = ax2.get_legend_handles_labels() 
legend = plt.legend(h0, l0, ncol=2, loc=1)
set_legend_linewidth(legend)   

## jeden Donnerstag eine Linie
# from datetime import date, timedelta
# dstart = date(2017,5,1)
# dend = date(2018,4,30) 
# days = [dstart + timedelta(days=x) for x in range((dend-dstart).days + 1) if (dstart + timedelta(days=x)).weekday() == 3]

# xposition = [pd.to_datetime('05.01.17'), pd.to_datetime('30.04.18')]
# for xc in days:
#     ax.axvline(x=xc, color='k', linestyle='-',linewidth=0.5)



ax.set(xlim=[pd.to_datetime("05.01.17 00:00:00"),pd.to_datetime("30.04.18 23:00:00")])
## X Achse mit Monaten und 2 mal dem Jahr :-)
monthlyX(ax)
plt.savefig(output_folder + '/' + file_name + '_Volumenstroeme_tgl_Linie.pdf')


plt.show()
# Durchschnittliche Voluemströme 
#Sommer
display(daten_tgl.loc['2017-05-15':'2017-09-10']['Vpunkt_intern'].mean())
display(daten_tgl.loc['2017-05-15':'2017-09-10']['Vpunkt_extern'].mean())

#Winter
display(daten_tgl.loc['2017-09-15':'2018-04-05']['Vpunkt_intern'].mean())
display(daten_tgl.loc['2017-09-15':'2018-04-05']['Vpunkt_extern'].mean())

## im Winter größer als 1000
224.01327824687255



134.30582456682035



1227.4207999831044



1000.0598109489523
daten_count = daten_sub.loc['2017-09-15':'2018-04-05'].copy()
display(daten_count[daten_count['Vpunkt_extern'] > 0]['Vpunkt_extern'].count()/240)
display(daten_count[daten_count['Vpunkt_extern'] > 1400]['Vpunkt_extern'].count()/240)
display(daten_count[daten_count['Vpunkt_extern'] > 1500]['Vpunkt_extern'].count()/240)
4824.733333333334



2125.4791666666665



398.76666666666665

Histogramme

mist  = daten_sub.loc['2017-05-01':'2018-04-30'].resample(sampling).min()
daten_tgl = daten_sub.copy()


sample = '15s' 
# vol = daten_sub['2017-05-01':'2018-04-30'].resample('15s').mean().copy()
vol = daten_sub.copy()
# vol['L_Zuluft_VPunkt'] = vol['Vpunkt_extern']   
vol.dropna(inplace= True)

Analyse

## Anzahl der bins festlegen
binsNR = [*range(1, 61, 1)] 
## bin_t = die Dauer, die jedes bin in Summe enthält
bin_t = pd.cut(daten_sub['Vpunkt_extern'],60,labels=binsNR).value_counts().sort_index()
## intervall = das Intervall (von, bis] für jedes bin
values, interval = pd.cut(daten_sub['Vpunkt_extern'],60,retbins=True)
## Mittelwerte des Intervalle berechnen 
interval_m = []
for i in range(0, 60):
    interval_m.append((interval[i] + interval[i+1])/2)
## df aus Dauer und Mittelwert
df = pd.DataFrame({'Dauer':(bin_t/240), 'V_Punkt':interval_m}) 

## Zeiten der drei Abschnitte berechnen
u = 0
for i in range(1, 13):
     u = u + bin_t[i]
m = 0
for i in range(13, 37):
    m = m + bin_t[i]
o = 0
for i in range(37, 61):
    o = o + bin_t[i]

Summe1 = bin_t.sum()/240
Summe2 = (u+m+o)/240
t_u = u/240
t_m = m/240
t_o = o/240

## mittlerer Volumenstrom eines jeden Abschnittes
## relativen Anteil berechnen
faktor = []
for i in range(1, 13):
    faktor.append(bin_t[i] / u)
for i in range(13, 37):
    faktor.append(bin_t[i] / m)
for i in range(37, 61):
    faktor.append(bin_t[i] / o)
df['faktor'] = faktor
## Volumenstrom * relativer Anteil
df['V_mittel'] = df.V_Punkt * faktor
## Abschnitte aufsummieren
V_m_u = df.loc[1:12]['V_mittel'].sum()
V_m_m = df.loc[13:36]['V_mittel'].sum()
V_m_o = df.loc[37:60]['V_mittel'].sum()

## Ausgabe
print(f'Kontrolle: {Summe1 - Summe2}') 
print(f'unten Dauer: {round(t_u,1)} h, durschn. Volumenstrom: {round(V_m_u,1)}m³') 
print(f'mitte Dauer: {round(t_m,1)} h, durschn. Volumenstrom: {round(V_m_m,1)}m³')
print(f'oben Dauer : {round(t_o,1)} h, durschn. Volumenstrom: {round(V_m_o,1)}m³') 

# display(df.head())
# display(df.tail())
# interval
Kontrolle: 0.0
unten Dauer: 3142.1 h, durschn. Volumenstrom: 97.4m³
mitte Dauer: 2905.8 h, durschn. Volumenstrom: 604.6m³
oben Dauer : 2653.8 h, durschn. Volumenstrom: 1482.2m³

Plot gesamt

## Histo
bins  = 60
oben  = 36
unten = 12
plt.figure(figsize=(2.78,2.25))
N, bins, patches = plt.hist(daten_sub['Vpunkt_extern'], bins=bins, orientation="horizontal", label='Value')
plt.hist(daten_sub['Vpunkt_extern'], bins=bins, orientation="horizontal", label='Value', edgecolor='black', linewidth=.4, histtype='step')
## die drei Bereiche einfärben, Füllung und Rahmen
for i in range(0,unten):
    patches[i].set_facecolor(colo('grün',.6))
    patches[i].set_edgecolor(colo('grün',.6))
for i in range(unten,oben):
    patches[i].set_facecolor(colo('grün',1))
    patches[i].set_edgecolor(colo('grün',1))    
for i in range(oben,60):
    patches[i].set_facecolor(colo('grün',1.6))
    patches[i].set_edgecolor(colo('grün',1.6))

## notwendig um die Achsen der Figur zu bekommen
ax = plt.gca()
## Label für Legende

top    = mpatches.Patch(facecolor =colo('grün',1.6),   edgecolor='black', label=r'$1.179 - 1.891$')
center = mpatches.Patch(facecolor =colo('grün',1),     edgecolor='black', label='') #r'$\dot V \hspace{0.38cm}   500 - 1.000$')
bottom = mpatches.Patch(facecolor =colo('grün',.6),    edgecolor='black', label='') #r'$\dot V \hspace{0.74cm}   0 - \hspace{0.25cm} 500$')
## \hphantom{} funktioniert nicht in der Legende bzw. nicht vor dem ersten sichtbaren Zeichen, daher die Notlösung mit .text()
ax.text(.646, 818, r'$468 - 1.150$', transform=ax.get_yaxis_transform())
ax.text(.65,  625, r'$110 - \hphantom{1.}438$', transform=ax.get_yaxis_transform()) 
## Legende
legend = plt.legend(handles=[top,center,bottom],loc='lower right', bbox_to_anchor=(1., .24),title=r'$\dot{V}$ extern',borderpad=.4)  
set_legend_linewidth(legend)  
## Hintergrund der Legende transparent, damit der Text sichtbar wird ;-)
legend.get_frame().set_alpha(None)
legend.get_frame().set_facecolor((0, 0, 0, 0))

## Y Achse formatieren
ax.set(ylim=[0,1900]) 
## Ticks sind Mittelwerte des jeweiligen Abteils
ax.set_yticks([V_m_u, V_m_m,V_m_o]) 
# ax.set_ylabel(r'\textbf{Volumenstrom} ($m^3/h$)')   
ax.get_yaxis().set_major_formatter(mpl.ticker.FuncFormatter(lambda x, loc: locale.format_string('%d', x, 1))) ## dot as thousand separator
## X Achse skalieren mit dem Faktir 1/240, damit die 15s in Stunden abgebildet werden
ax.set_xlabel(r'\textbf{Zeit} (h)')   
ax.set(xlim=[0,500000]) 
ax.set_xticks([0,120000, 240000,360000,480000])  
x_vals = ax.get_xticks()
ax.set_xticklabels(['{:3.0f}%'.format(x / 240) for x in x_vals])
## remove minorticks
plt.tick_params(axis='x', which='minor', bottom=False)

## Stundenwerte
ax.text(.05,  220,  r'$3.142 h$', transform=ax.get_yaxis_transform()) 
ax.text(.05,  880,  r'$2.905 h$', transform=ax.get_yaxis_transform()) 
ax.text(.05,  1630, r'$2.653 h$', transform=ax.get_yaxis_transform()) 

plt.savefig(output_folder + '/' + file_name + '_Volumenstroeme_Histogramm_gesamt.pdf') 
plt.show()

Plot einzeln

daten_std = daten.resample('15s').mean()#.reset_index()
daten_std['L_Zuluft_VPunkt'] = daten_std['L_Zuluft_1_VPunkt']  + daten_std['L_Zuluft_2_VPunkt'] + daten_std['L_Zuluft_3_VPunkt'] 
daten_std['L_Zuluft_VPunkt'].isna().sum()  

bins = 40 
fig, axes = plt.subplots(nrows=3, ncols=1, sharex=True , constrained_layout=False,figsize=(3,2.25))
plt.subplots_adjust(hspace=.0)
# plt.hist(daten_std['L_Zuluft_VPunkt'],   bins=100, orientation="horizontal", color=colo('orange',1), linewidth=0.5, label = 'Zuluft gesamt')  
daten_std['L_Zuluft_1_VPunkt'].plot.hist(ax=axes[0], bins=bins, orientation="horizontal", color=colo('rot',1),    linewidth=0.4, edgecolor='black', label = 'Seminar 1',  histtype='stepfilled')  
daten_std['L_Zuluft_1_VPunkt'].plot.hist(ax=axes[0], bins=bins, orientation="horizontal", color=colo('black',1),  linewidth=0.3,                    label = '_nolegend_', histtype='step')  

daten_std['L_Zuluft_2_VPunkt'].plot.hist(ax=axes[1], bins=bins, orientation="horizontal", color=colo('orange',1), linewidth=0.4, edgecolor='black', label = 'Seminar 2',  histtype='stepfilled')  
daten_std['L_Zuluft_2_VPunkt'].plot.hist(ax=axes[1], bins=bins, orientation="horizontal", color=colo('black',1),  linewidth=0.4,                    label = '_nolegend_', histtype='step')  

daten_std['L_Zuluft_3_VPunkt'].plot.hist(ax=axes[2], bins=bins, orientation="horizontal", color=colo('blau',1),   linewidth=0.4, edgecolor='black', label = 'Foyer',       histtype='stepfilled')  
daten_std['L_Zuluft_3_VPunkt'].plot.hist(ax=axes[2], bins=bins, orientation="horizontal", color=colo('black',1),  linewidth=0.4,                    label = '_nolegend_', histtype='step')  

# W_raus.plot.barh(position = 1.5, color = (Farben_raus), edgecolor='black',linewidth = 0.3, width = 0.5, ax = ax, stacked = True, alpha = 1,align='edge')

for ax in axes:
    ax.legend(bbox_to_anchor=(1., .86), ncol=1)
## Legende  
# h0, l0 = axes[0].get_legend_handles_labels()
# h2, l2 = axes[1].get_legend_handles_labels()  
# h4, l4 = axes[2].get_legend_handles_labels()  
# legend = plt.legend(h0+h2+h4, l0+l2+l4, loc='lower right', ncol=1, bbox_to_anchor=(1., .14))  
set_legend_linewidth(legend)  
# legend.get_frame().set_linewidth(0.3)

## Grenzen und Ticks
# axes[0].set(xlim=[0,2000]) 
# axes[1].set(xlim=[0,2000]) 
# axes[2].set(xlim=[0,2000]) 
axes[0].set(ylim=[0,1400]) 
axes[1].set(ylim=[0,180]) 
axes[2].set(ylim=[0,500]) 
axes[0].set_yticks([0,618]) 
axes[1].set_yticks([0,104]) 
axes[2].set_yticks([0,142])  
## Beschriftung Y Achse
axes[0].set_xlabel('')
axes[1].set_xlabel('')
axes[2].set_xlabel(r'\textbf{Zeit} (h)')   
## Tausendertrennzeichen
axes[0].get_yaxis().set_major_formatter(mpl.ticker.FuncFormatter(lambda x, loc: locale.format_string('%d', x, 1))) ## dot as thousand separator
axes[1].get_yaxis().set_major_formatter(mpl.ticker.FuncFormatter(lambda x, loc: locale.format_string('%d', x, 1))) ## dot as thousand separator
axes[2].get_yaxis().set_major_formatter(mpl.ticker.FuncFormatter(lambda x, loc: locale.format_string('%d', x, 1))) ## dot as thousand separator
axes[0].get_xaxis().set_major_formatter(mpl.ticker.FuncFormatter(lambda x, loc: locale.format_string('%d', x, 1))) ## dot as thousand separator
axes[1].get_xaxis().set_major_formatter(mpl.ticker.FuncFormatter(lambda x, loc: locale.format_string('%d', x, 1))) ## dot as thousand separator
axes[2].get_xaxis().set_major_formatter(mpl.ticker.FuncFormatter(lambda x, loc: locale.format_string('%d', x, 1))) ## dot as thousand separator

## X Achse skalieren mit dem Faktir 1/240, damit die 15s in Stunden abgebildet werden
axes[0].set_xticks([0,120000, 240000,360000,480000])  
x_vals = axes[0].get_xticks()
axes[0].set_xticklabels(['{:3.0f}%'.format(x / 240) for x in x_vals])
## remove minorticks
plt.tick_params(axis='x', which='minor', bottom=False)


## Beschriftungen Y Achse
axes[0].text(-0.28, -800, r'\textbf{Volumenstrom} ($m^3/h$)', va='center', rotation='vertical', transform=axes[0].get_yaxis_transform()) 

## Save
plt.savefig(output_folder + '/' + file_name + '_Volumenstroeme_Histogramm_einzeln.pdf', bbox_inches='tight') 
print(f'Seminar 1: {round(daten_std.L_Zuluft_1_VPunkt.mean(),1)}')
print(f'Seminar 2: {round(daten_std.L_Zuluft_2_VPunkt.mean(),1)}')
print(f'Flur:      {round(daten_std.L_Zuluft_3_VPunkt.mean(),1)}') 
Seminar 1: 618.2
Seminar 2: 103.8
Flur:      142.6

Aufteilung Lueftung - Heizkörper

# gc.collect() 
verg  = daten_sub.rolling(1500).mean()#.loc['12.10.17 10:00:00':'12.11.17 10:18:00']  
verg['delta_Heizung']              = verg['S_Heizung_VL']       - verg['S_Heizung_RL']
verg['delta_Nacherhitzer']         = verg['L_Nacherhitzer_VL']  - verg['L_Nacherhitzer_RL']
verg['diff_delta']                 = verg['delta_Heizung'] - verg['delta_Nacherhitzer']
## nur relevant wenn Heizung an
verg['delta_Heizung']              = np.where(verg['S_Heizung_Vpunkt'] > 50,  verg['delta_Heizung'], 0)
verg['delta_Nacherhitzer']         = np.where(verg['S_Heizung_Vpunkt'] > 50,  verg['delta_Nacherhitzer'], 0)
verg['diff_delta']                 = np.where(verg['S_Heizung_Vpunkt'] > 50,  verg['diff_delta'], 0)
## nur relevant wenn Heizung an
verg['S_Heizung_VL']              = np.where(verg['S_Heizung_Vpunkt'] > 50,  verg['S_Heizung_VL'], 0)
verg['L_Nacherhitzer_VL']         = np.where(verg['S_Heizung_Vpunkt'] > 50,  verg['L_Nacherhitzer_VL'], 0)
verg['S_Heizung_RL']              = np.where(verg['S_Heizung_Vpunkt'] > 50,  verg['S_Heizung_RL'], 0)
verg['L_Nacherhitzer_RL']         = np.where(verg['S_Heizung_Vpunkt'] > 50,  verg['L_Nacherhitzer_RL'], 0)

fig, ax = plt.subplots(figsize=(5.9,3))   
# fig, ax = plt.subplots()   
# ax2 = ax.twinx()
# ax.axhline(0, linewidth=0.3,color='black') 
# ax.axhline(1, linewidth=0.3,color='black') 
verg['S_Heizung_VL'].plot(ax=ax,color=colo('blau',1),        linewidth=0.3, label = 'S_Heizung_VL') 
verg['S_Heizung_RL'].plot(ax=ax,color=colo('blau',1.5),      linewidth=0.5, label = 'S_Heizung_RL')   
verg['L_Nacherhitzer_VL'].plot(ax=ax,color=colo('grün',1),   linewidth=0.3, label = 'L_Nacherhitzer_VL') 
verg['L_Nacherhitzer_RL'].plot(ax=ax,color=colo('grün',1.5), linewidth=0.5, label = 'L_Nacherhitzer_RL')   
verg['diff_delta'].plot(ax=ax,color=colo('rot',1),           linewidth=0.5, label = 'Differenz')   



## Achsen 
ax.set_ylabel(r'\textbf{Temperatur} ($^\circ$C)')  
ax.set_xlabel('')  
# ax.set(ylim=[20,35]) 
# ax.set_yticks([-5,1,0,5,10])  
h0, l0 = ax.get_legend_handles_labels()  
legend = plt.legend(h0, l0, ncol=1, loc=2)
set_legend_linewidth(legend)  
monthlyX(ax)
# ax.set(xlim=[pd.to_datetime("12.12.17 00:00:00"),pd.to_datetime("12.12.17 23:59:00")])
ax.set(xlim=[pd.to_datetime("05.01.17 00:00:00"),pd.to_datetime("30.04.18 23:59:00")])
plt.savefig(output_folder + '/' + file_name + '_Temperaturspreizungen_Heizung_Lüftung.pdf')  

Spreizung Differenz



fig, ax = plt.subplots(figsize=(5.9,2.2))   
# fig, ax = plt.subplots()   
# ax2 = ax.twinx()
ax.axhline(0, linewidth=0.3,color='black') 
ax.axhline(1, linewidth=0.3,color='black') 
verg['delta_Heizung'].plot(ax=ax,color=colo('blau',1),        linewidth=0.3, label = 'Spreizung Heizung') 
verg['delta_Nacherhitzer'].plot(ax=ax,color=colo('grün',1),   linewidth=0.3, label = 'Spreizung Lüftung') 
verg['diff_delta'].plot(ax=ax,color=colo('rot',1),            linewidth=0.5, label = 'Differenz')   

# verg['L_Aussenlufttemperatur_1'].plot(ax=ax2,color=colo('blau',1),   linewidth=0.5, label = 'L_Aussenlufttemperatur_1') 
# verg['S_Gas_Vpunkt'].plot(ax=ax2,color=colo('blau',1),   linewidth=0.5, label = 'S_Gas_Vpunkt')  
## Orintierungslinien

# ax.axvline(pd.to_datetime('2017-05-15'), linewidth=0.5,color='black') 
# ax.axvline(pd.to_datetime('2017-09-13'), linewidth=0.5,color='black') 
# ax.axvline(pd.to_datetime('2017-11-22'), linewidth=0.5,color='black')  
# ax.axvline(pd.to_datetime('2018-04-10'), linewidth=0.5,color='black')  


## Achsen 
ax.set_ylabel(r'\textbf{Temperatur} ($^\circ$C)')  
ax.set_xlabel('')  
ax.set(ylim=[-5,15]) 
ax.set_yticks([-5,1,0,5,10])  
h0, l0 = ax.get_legend_handles_labels()  
legend = plt.legend(h0, l0, ncol=1, loc=2)
set_legend_linewidth(legend)  
monthlyX(ax)
# ax.set(xlim=[pd.to_datetime("12.12.17 00:00:00"),pd.to_datetime("12.12.17 23:59:00")])
ax.set(xlim=[pd.to_datetime("05.01.17 00:00:00"),pd.to_datetime("30.04.18 23:59:00")])
plt.savefig(output_folder + '/' + file_name + '_Temperaturspreizungen_Heizung_Lüftung_Differenz.pdf')  

Histoplot

fig, ax = plt.subplots()
bins = 500
plt.hist(verg['diff_delta'].resample("1H").mean(), bins=bins, density=False, orientation="horizontal", color=colo('violet',1), linewidth=0.8, label = 'delta_RL', histtype='stepfilled')      

# ax.axhline(0, linewidth=0.8,color='grey') 
## Achsenbeschriftung
ax.set_ylabel(r'\textbf{Temperaturdifferenz} (K)')     
ax.set_xlabel(r'\textbf{Zeit} (h)')   
## Legende
h0, l0 = ax.get_legend_handles_labels() 
legend = plt.legend(h0, l0, ncol=1, loc=1)  
set_legend_linewidth(legend)   
## Y Achse formatieren
ax.set(ylim=[-1.5,1]) 
# ax.set_yticks([60,65,70,75,80,85,90,95,100]) 

## X Achse skalieren mit dem Faktor 1/240, damit die 15s in Stunden abgebildet werden
ax.get_xaxis().set_major_formatter(mpl.ticker.FuncFormatter(lambda x, loc: locale.format_string('%d', x, 1))) ## dot as thousand separator
x_vals = ax.get_xticks()
# ax.set_xticklabels(['{:3.0f}%'.format(x / 240) for x in x_vals])
# ax.set(xlim=[0,50000]) 
# ax.set_xticks([0,120000])  
## remove minorticks
plt.tick_params(axis='x', which='minor', bottom=False)
# plt.title('density=False, Bins:'+str(bins))
# plt.savefig(output_folder + '/' + file_name + '_Luftdruck_Histogramm_Sommer.pdf') 
c:\users\kolja\appdata\local\programs\python\python37\lib\site-packages\numpy\lib\histograms.py:829: RuntimeWarning: invalid value encountered in greater_equal
  keep = (tmp_a >= first_edge)
c:\users\kolja\appdata\local\programs\python\python37\lib\site-packages\numpy\lib\histograms.py:830: RuntimeWarning: invalid value encountered in less_equal
  keep &= (tmp_a <= last_edge)

Save & Upload


# daten_kal_sub.to_csv('Finde_die_Kalibrierung.csv')
## Skriptlaufzeit Ende (Funktion in: libraries_and_styles.ipynb)
hours, minutes, seconds = laufzeit()
## Notebook speichern vor dem Upload (Funktion in: libraries_and_styles.ipynb)
save_notebook() 
## Notebook als Markdown Datei mit eingebetten Grafiken speichern und auf den Server laden
%run ../Template/save_and_upload.ipynb  
 Uebersicht_Wetter WRG_Effizienz