Lueftung_kalibrieren_11

Bibliotheken importieren

# Name des aktuellen Notebooks für die exportierten Datein
file_name = "Lueftung_kalibrieren_11" 
# Ordner auf dem Server (nach files/)
ftp_folder = 'Notebooks/Aufbereitung'
## 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)

Daten Import

## einmalig Daten aus unterschiedlichen Datien zusammenfügen und als Testo_Arbeitsdaten_15s.csv speichern

# wrg = pd.read_csv("MA_WGR_Daten_Testo.csv",sep=";",decimal=",",encoding="cp1252")
# wrg['Datum'] = pd.to_datetime(wrg["Datum"],dayfirst=True,)
# wrg.set_index(["Datum"], inplace=True)

# wrgF = pd.read_csv("MA_WGR_Daten_Testo_Feb.csv",sep=";",decimal=",",encoding="cp1252")
# wrgF['Datum'] = pd.to_datetime(wrgF["Datum"],dayfirst=True,)
# wrgF.set_index(["Datum"], inplace=True)

# wrgF2 = pd.read_csv("MA_WGR_Daten_Testo_Feb2.csv",sep=";",decimal=",",encoding="cp1252")
# wrgF2['Datum'] = pd.to_datetime(wrgF2["Datum"],dayfirst=True,)
# wrgF2.set_index(["Datum"], inplace=True)

# wrg   = wrg.resample('15s').interpolate(method='linear')
# wrgF  = wrgF.resample('15s').interpolate(method='linear')
# wrgF2 = wrgF2.resample('15s').interpolate(method='linear')

# daten = pd.read_csv('../1_Daten/Arbeitsdaten/Daten_15s.csv')
# daten["Zeit"] = pd.to_datetime(daten["Zeit"],dayfirst=True)
# daten["Zeit1"] = daten["Zeit"]
# daten.set_index(['Zeit1'], inplace=True)
# daten = daten.loc['2017-12-05 10:00:00':'2018-02-23 14:38:00']
# daten['L_Zuluft_VPunkt'] = daten['L_Zuluft_1_VPunkt']  + daten['L_Zuluft_2_VPunkt'] + daten['L_Zuluft_3_VPunkt'] 

# # concat wrg`s
# frames = [wrg, wrgF, wrgF2]
# testo = pd.concat(frames)
# testo.columns = ['Außenluft_C', 'Außenluft_rF', 'Zuluft_C', 'Zuluft_rF', 'Abluft_C','Abluft_rF', 'Fortluft_C', 'Fortluft_rF']
# testo['Zeit'] = testo.index
# testo.to_csv('Testo_174H.csv')

# ## GET the data, just for saving, not use
# # Testo_174H = pd.read_csv("Testo_174H.csv")
# # Testo_174H['Datum'] = pd.to_datetime(Testo_174H["Datum"],dayfirst=True,)
# # Testo_174H.set_index(["Datum"], inplace=True)
# # Testo_174H.head()


# # merge mit testo
# testo  = testo.merge(daten , left_on=['Zeit'], right_on=['Zeit'], how='outer')
# testo["Zeit"] = pd.to_datetime(testo["Zeit"],dayfirst=True)
# testo.set_index(['Zeit'], inplace=True)
# testo.to_csv('Testo_Arbeitsdaten_15s.csv')
# # testo.head()
daten = pd.read_csv("Testo_Arbeitsdaten_15s.csv")
daten['Zeit'] = pd.to_datetime(daten["Zeit"],dayfirst=True,)
daten.set_index(["Zeit"], inplace=True)

## 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

## 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-23 14:38:45'] 
daten = pd.concat([datena, datenb, datenc])
# del [[datena, datenb, datenc]] gc.collect()
daten.dropna(inplace=True)
## wurde in dem Zeitraum 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-23 14:38: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 Messzeitraum 6.12.2017 - 20.2.2018
# ## alt
# von = '2017-12-06 00:00:00'
# bis = '2018-02-20 23:59:45'
von  = pd.to_datetime("2017-12-06 00:00", infer_datetime_format=True).to_pydatetime()
bis  = pd.to_datetime("2018-02-20 23:59:45", infer_datetime_format=True).to_pydatetime()
## Periode 1
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()
## Periode 2
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()
## Periode 3
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()
## Zeitraum für Mischkalibrierung
Mischkal_start = pd.to_datetime("2018-02-22 16:40:00", infer_datetime_format=True).to_pydatetime()
Mischkal_ende  = pd.to_datetime("2018-02-23 14:38:00", infer_datetime_format=True).to_pydatetime()
fig, ax = plt.subplots(figsize=(6,2)) 
daten['Außenluft_C'].plot(ax=ax,color=colo('blau',1),  linewidth=0.5, label = 'Temperatur Außenluft')  

ax2 = ax.twinx()
daten['Außenluft_rF'].plot(ax=ax2,color=colo('rot',1),  linewidth=0.5, label = 'rel. Luftfeuchte Außenluft')  

ax.set_xlabel('')   
ax.set_ylabel(r'\textbf{Temperatur} ($^\circ$C)')   
ax2.set_ylabel(r'\textbf{rel Luftfeuchte} (\%)') 
# Legende
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) 
# monthlyX(ax)

ax = plt.gca()
ax.xaxis.set_major_locator(mdates.DayLocator(interval=10))
ax.xaxis.set_major_formatter(mdates.DateFormatter('%d.%m.'))  
fig.autofmt_xdate(rotation=0,ha='center') 
plt.title('Kontrollplot') 
## alt
# xlabels = ['6. Dez','7.','8.','9.','10.','11.','12.']
# ax.set_xticklabels(ax.get_xticklabels(), rotation=0, ha='center')
# plt.xticks(rotation=0)
# ax.xaxis.set_tick_params(rotation=0)
# plt.setp(ax.get_xticklabels(), rotation=0, ha="center", rotation_mode="anchor")
c:\users\kolja\appdata\local\programs\python\python37\lib\site-packages\ipykernel_launcher.py:20: UserWarning: This figure was using constrained_layout==True, but that is incompatible with subplots_adjust and or tight_layout: setting constrained_layout==False. 





Text(0.5, 1.0, 'Kontrollplot')

174H kalibrieren

def TESTO_Kalibrierung(variante='testo'):
    global testo
    testo = daten.copy()

    if variante == '0':
        testo['Abluft_rF']    = daten['Abluft_rF']     
        testo['Fortluft_rF']  = daten['Fortluft_rF']  
        testo['Außenluft_rF'] = daten['Außenluft_rF']  
        testo['Zuluft_rF']    = daten['Zuluft_rF']     
        testo['Abluft_C']     = daten['Abluft_C']     
        testo['Fortluft_C']   = daten['Fortluft_C']   
        testo['Außenluft_C']  = daten['Außenluft_C']         
        testo['Zuluft_C']     = daten['Zuluft_C']     

    if variante == 'testo':
        ## Aus der Kalibrierung vom 25.03.2019 gegen das Testo480 
        testo['Abluft_rF']    = daten['Abluft_rF']    * 1.0386 - 0.0826
        testo['Fortluft_rF']  = daten['Fortluft_rF']  * 0.9522 + 2.5642
        testo['Außenluft_rF'] = daten['Außenluft_rF'] * 1.0568 + 3.1864
        testo['Zuluft_rF']    = daten['Zuluft_rF']    * 1.0489 + 2.9552
        testo['Abluft_C']     = daten['Abluft_C']     * 1.0447 - 0.5989
        testo['Fortluft_C']   = daten['Fortluft_C']   * 1.0002 + 0.2829
        testo['Außenluft_C']  = daten['Außenluft_C']  * 1.0191 - 0.809
        testo['Zuluft_C']     = daten['Zuluft_C']     * 1.0059 - 0.3276

    if variante == 'self':
        ## kal['ref_rF'] = (kal.Abluft_rF + kal.Fortluft_rF ) / 2
        ## kal['ref_C']  = (kal.Abluft_C + kal.Fortluft_C + kal.Zuluft_C) / 3
        testo['Abluft_rF']    = daten['Abluft_rF']    * 0.828993573070746  +  6.801455317349444
        testo['Fortluft_rF']  = daten['Fortluft_rF']  * 1.0674200418092923 + -2.6412934624410167
        testo['Außenluft_rF'] = daten['Außenluft_rF'] * 0.8002161817773167 +  5.231630936999777
        testo['Zuluft_rF']    = daten['Zuluft_rF']    * 0.9223667924445846 +  1.4339541677129877
        testo['Abluft_C']     = daten['Abluft_C']     * 1.0209706144779265 + -0.4144120307172744
        testo['Fortluft_C']   = daten['Fortluft_C']   * 0.9647290370199838 +  0.6981836985112495
        testo['Außenluft_C']  = daten['Außenluft_C']  * 1.1242036726591484 + -2.0880414590720107
        testo['Zuluft_C']     = daten['Zuluft_C']     * 0.9913301797188931 +  0.1560904830431007 

 ## 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)

# TESTO_kalibrierung()

Mischkalibrierung für die Variante "self"

# ## 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(schaetzer)
# #     print('daten_kal_selbst[\''+X.name+'\'] = pow(daten_kal_selbst[\''+X.name+'\'],3) * ' +str(schaetzer[3]) +   ' + pow(daten_kal_selbst[\''+X.name+'\'],2) * ' +str(schaetzer[2]) +   ' + daten_kal_selbst[\''+X.name+'\'] * ' +str(schaetzer[1]) +   ' + ' +str(schaetzer[0])    )
#     print('daten_sub[\''+X.name+'\'] = daten[\''+X.name+'\'] * ' +str(schaetzer[1]) +   ' + ' +str(schaetzer[0])    )
#     return schaetzer(X)



# ## Referenzen definieren
# daten_kal['ref_rF'] = (daten_kal.Abluft_rF + daten_kal.Fortluft_rF  + daten_kal.Zuluft_rF + daten_kal.Außenluft_rF) / 4 
# daten_kal['ref_C']  = (daten_kal.Abluft_C + daten_kal.Fortluft_C + daten_kal.Zuluft_C + daten_kal.Außenluft_C) / 4

# kalibrieren(daten_kal['Abluft_rF'],   daten_kal['ref_rF'])
# kalibrieren(daten_kal['Fortluft_rF'], daten_kal['ref_rF'])
# kalibrieren(daten_kal['Außenluft_rF'],daten_kal['ref_rF'])
# kalibrieren(daten_kal['Zuluft_rF'],   daten_kal['ref_rF']) 
# kalibrieren(daten_kal['Abluft_C'],    daten_kal['ref_C'])  
# kalibrieren(daten_kal['Fortluft_C'],  daten_kal['ref_C']) 
# kalibrieren(daten_kal['Außenluft_C'], daten_kal['ref_C'])  
# kalibrieren(daten_kal['Zuluft_C'],    daten_kal['ref_C']) 

Plot Kalibrierung

def TESTO_Kalibrierung_plot(df,titel): 
    fig, ax = plt.subplots(figsize=(6,2)) 
    df['Außenluft_C'].plot(ax=ax,color=colo('blau',1),  linewidth=0.8, label = 'Außenluft') 
    df['Zuluft_C'].plot(ax=ax,color=colo('rot',1),      linewidth=0.8, label = 'Zuluft') 
    df['Abluft_C'].plot(ax=ax,color=colo('orange',1),   linewidth=0.8, label = 'Abluft') 
    df['Fortluft_C'].plot(ax=ax,color=colo('violet',1), linewidth=0.8, label = 'Fortluft') 

    ax2 = ax.twinx()
    df['Außenluft_rF'].plot(ax=ax2,color=colo('blau',1),  linewidth=0.8, label = '__nolable__') 
    df['Zuluft_rF'].plot(ax=ax2,color=colo('rot',1),      linewidth=0.8, label = '__nolable__') 
    df['Abluft_rF'].plot(ax=ax2,color=colo('orange',1),   linewidth=0.8, label = '__nolable__') 
    df['Fortluft_rF'].plot(ax=ax2,color=colo('violet',1), linewidth=0.8, label = '__nolable__') 

    ## Y Achse formatieren
    ax.set(ylim=[18,23])
    ax.set_yticks([19])  
    ax.set_ylabel(r'\textbf{Temperatur} ($^\circ$C)')  
    ax2.set(ylim=[25,58]) 
    ax2.set_yticks([40,45])
    ax2.set_ylabel(r'\textbf{rel. Luftfeuchte} (\%)') 

    # Legende
    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) 
    plt.title(titel) 
    # X Achse formatieren
    ax.set_xlabel('') 
    ax.set(xlim=[Mischkal_start, Mischkal_ende])
#     ax = plt.gca()
    ax.xaxis.set_major_locator(mdates.HourLocator(interval=6))
    ax.xaxis.set_major_formatter(mdates.DateFormatter('%d.%m. %H:%M'))  
    fig.autofmt_xdate(rotation=0,ha='center') 


## Kalibrierung und Plot aufrufen
TESTO_Kalibrierung('0')
TESTO_Kalibrierung_plot(df=testo, titel='Testo 174H Rohdaten')

TESTO_Kalibrierung('self')
TESTO_Kalibrierung_plot(df=testo, titel='Testo 174H Mischkalibrierung')

TESTO_Kalibrierung('testo')
TESTO_Kalibrierung_plot(df=testo, titel='Testo 174H gegen Testo 480')
c:\users\kolja\appdata\local\programs\python\python37\lib\site-packages\ipykernel_launcher.py:34: UserWarning: This figure was using constrained_layout==True, but that is incompatible with subplots_adjust and or tight_layout: setting constrained_layout==False. 
c:\users\kolja\appdata\local\programs\python\python37\lib\site-packages\ipykernel_launcher.py:34: UserWarning: This figure was using constrained_layout==True, but that is incompatible with subplots_adjust and or tight_layout: setting constrained_layout==False. 
c:\users\kolja\appdata\local\programs\python\python37\lib\site-packages\ipykernel_launcher.py:34: UserWarning: This figure was using constrained_layout==True, but that is incompatible with subplots_adjust and or tight_layout: setting constrained_layout==False. 

Kalibrierungsabfrage

def welche_TESTO_Kalibrierung(df):
    value = int(df['Außenluft_rF'].loc["2018-02-22 17:00:00" : "2018-02-22 20:00:00"].mean())
    if value == 42:
        print('Rohdaten')
    if value == 39:
        print('Mischkalibrierung')
    if value == 48:
        print('gegen Testo 480')
    ## debug
#     print(str(value))

## Kalibrierung und Durchschnittwert aufrufen
TESTO_Kalibrierung('0')
welche_TESTO_Kalibrierung(testo)

TESTO_Kalibrierung('self')
welche_TESTO_Kalibrierung(testo)

TESTO_Kalibrierung('testo')
welche_TESTO_Kalibrierung(testo)
Rohdaten
Mischkalibrierung
gegen Testo 480

Lüftung gegen T174H kalibrieren

Berechnungen

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

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

WGR_kal = pd.DataFrame()


def WRG_Kalibrierung(TE_Kalibrierung='testo', nur_Testo=0):
    global WGR_kal
    TESTO_Kalibrierung(TE_Kalibrierung)
    WGR_kal = daten.copy() 
    welche_TESTO_Kalibrierung(testo)



    WGR_kal['L_Aussenlufttemperatur_1_korr'] = kalibrieren(daten['L_Aussenlufttemperatur_1'], testo['Außenluft_C'])
    WGR_kal['L_Ablufttemperatur_korr']       = kalibrieren(daten['L_Ablufttemperatur'],       testo['Abluft_C'])
    WGR_kal['L_Fortlufttemperatur_korr']     = kalibrieren(daten['L_Fortlufttemperatur'],     testo['Fortluft_C'])

    ## Kalibrierung gegen Testo
    ## werden für Zu und Fortluftfeuchte Berechnung benötigt
    # WGR_kal['W_Luftfeuchtigkeit_rol']        = daten['W_Luftfeuchtigkeit'].rolling(150, center=True, min_periods=1).mean()  
    WGR_kal['W_Luftfeuchtigkeit_korr']       = kalibrieren(daten['W_Luftfeuchtigkeit'],        testo['Außenluft_rF'])
    WGR_kal['L_Duschen_Ablufttfeuchte_korr'] = kalibrieren(daten['L_Duschen_Ablufttfeuchte'],  testo['Abluft_rF'])

    if nur_Testo == 1:
            WGR_kal['L_Aussenlufttemperatur_1_korr'] = testo['Außenluft_C']          
            WGR_kal['L_Ablufttemperatur_korr']       = testo['Abluft_C']          
            WGR_kal['L_Fortlufttemperatur_korr']     = testo['Fortluft_C']              
            WGR_kal['W_Luftfeuchtigkeit_korr']       = testo['Außenluft_rF']
            WGR_kal['L_Duschen_Ablufttfeuchte_korr'] = testo['Abluft_rF']      

    ## Zuluftfeuchte
    WGR_kal['Außenluft_WG']                  = psy.Hum_rat2(WGR_kal['L_Aussenlufttemperatur_1_korr'],  WGR_kal['W_Luftfeuchtigkeit_korr']/100,        daten['W_Luftdruck'])
    ## Fortluftfeuchte
    WGR_kal['Abluft_WG']                     = psy.Hum_rat2(WGR_kal['L_Ablufttemperatur_korr'],        WGR_kal['L_Duschen_Ablufttfeuchte_korr']/100,  daten['W_Luftdruck'])
    WGR_kal['Fortluft_relF']                 = psy.Rel_hum2(WGR_kal['L_Fortlufttemperatur_korr'],      WGR_kal['Abluft_WG']*100,                      daten['W_Luftdruck'])

    ## Kalibrierung gegen Testo
    WGR_kal['Fortluft_relF_korr']            = kalibrieren(WGR_kal['Fortluft_relF'],     testo['Fortluft_rF'])

    if nur_Testo == 1:
        WGR_kal['Fortluft_relF_korr']        = testo['Fortluft_rF'] 


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

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

    ## 2 Enthalpie der Luft nach dem Nacherhitzer in kJ/kg
    WGR_kal['Zuluft_nach_NE_h']              = psy.Enthalpy_Air_H2O(daten['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'] * daten['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'] * daten['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()  
    WGR_kal['Zuluft_vor_NE_C_kal']           = kalibrieren(WGR_kal['Zuluft_vor_NE_C_rol'],       testo['Zuluft_C'])

    if nur_Testo == 1:
        WGR_kal['Zuluft_vor_NE_C_kal']       = testo['Zuluft_C']


    ## Zuluftfeuchte
    WGR_kal['Zuluft_relF']                   = psy.Rel_hum2(WGR_kal['Zuluft_vor_NE_C_kal'], WGR_kal['Außenluft_WG']*100, daten['W_Luftdruck'])
    WGR_kal['Zuluft_relF_korr']              = kalibrieren(WGR_kal['Zuluft_relF'],       testo['Zuluft_rF'])

    if nur_Testo == 1:
        WGR_kal['Zuluft_relF_korr']          = testo['Zuluft_rF'] 
    return WGR_kal


# 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

# WRG_Kalibrierung('self')

WRG_Kalibrierung(TE_Kalibrierung='0', nur_Testo=0)
print(WGR_kal['L_Aussenlufttemperatur_1_korr'].mean())
WRG_Kalibrierung(TE_Kalibrierung='0', nur_Testo=1)
print(WGR_kal['L_Aussenlufttemperatur_1_korr'].mean())

WRG_Kalibrierung(TE_Kalibrierung='self', nur_Testo=0)
print(WGR_kal['L_Aussenlufttemperatur_1_korr'].mean())
WRG_Kalibrierung(TE_Kalibrierung='self', nur_Testo=1)
print(WGR_kal['L_Aussenlufttemperatur_1_korr'].mean())

WRG_Kalibrierung(TE_Kalibrierung='testo', nur_Testo=0)
print(WGR_kal['L_Aussenlufttemperatur_1_korr'].mean())
WRG_Kalibrierung(TE_Kalibrierung='testo', nur_Testo=1)
print(WGR_kal['L_Aussenlufttemperatur_1_korr'].mean()) 
Rohdaten
4.96855498649096
Rohdaten
4.968554986490586
Mischkalibrierung
3.49762630454983
Mischkalibrierung
3.497626304549632
gegen Testo 480
4.254454386732749
gegen Testo 480
4.254454386732556
WGR_kal['L_Duschen_Ablufttfeuchte_korr'] = kalibrieren(daten['L_Duschen_Ablufttfeuchte'],  testo['Abluft_rF'], output=1)


print(WGR_kal['L_Duschen_Ablufttfeuchte_korr'].loc['2017-12-06 00:00:00'])
print(daten['L_Duschen_Ablufttfeuchte'].loc['2017-12-06 00:00:00'])
print(testo['Abluft_rF'].loc['2017-12-06 00:00:00'])
WGR_kal['L_Duschen_Ablufttfeuchte'] = WGR_kal['L_Duschen_Ablufttfeuchte'] * 0.519191751276289 + 15.157293846837895
34.29989371639467
36.87
38.397529999999996

Plots

xxx
WRG_Kalibrierung(0)
kal_von = "2018-02-01 12:00:00"
kal_bis = "2018-02-11 19:59:00"
---------------------------------------------------------------------------

NameError                                 Traceback (most recent call last)

<ipython-input-12-9a1104cd4084> in <module>
----> 1 xxx
      2 WRG_Kalibrierung(0)
      3 kal_von = "2018-02-01 12:00:00"
      4 kal_bis = "2018-02-11 19:59:00"


NameError: name 'xxx' is not defined

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)])  

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()) ) 

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 
#     kalibrierung() 
#     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['h21_Außenluft'],  daten_sub['h21_Außenluft_by'])
    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
    ## 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_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_VPunkt'],  daten_sub['Vpunkt_extern'])
    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_plot

def effizienz_plot(title):
    global daten_sub 
    fig, ax = plt.subplots(figsize=(6,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['EÜG_Außenluft_vorl'].plot(ax=ax,color=colo('grün',1),   linewidth=.5, label = 'EÜG_Außenluft')  
    daten_sub['RWZ_Außenluft_vorl'].plot(ax=ax,color=colo('blau',1),   linewidth=.5, label = 'RWZ_Außenluft') 
    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(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.get_xaxis().set_major_formatter(mdates.DateFormatter("%d.%m.")) 
    # plt.savefig(output_folder + '/' + file_name + '_' +title + '.pdf') 
    plt.show()
effizienz()
effizienz_plot('Test')
xxx

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)

Datenqualitätscheck

kalibrierung(variante = 'testo')
WRG_Kalibrierung(testo='no')
# zuweisungen()

WGR_kal['Nacherhitzer_Energie']          = energie(WGR_kal['L_Nacherhitzer_VL'], WGR_kal['L_Nacherhitzer_RL'], WGR_kal['S_Heizung_Vpunkt'])
daten_sub['Zuluft_WG']                   = psy.Hum_rat2(daten_sub['Zuluft_C'],        daten_sub['Zuluft_rF']    /100,   daten_sub['W_Luftdruck'])
daten_sub['h22_Zuluft']                  = psy.Enthalpy_Air_H2O(daten_sub['Zuluft_C'],    daten_sub['Zuluft_WG'])
WGR_kal['Zuluft_nach_NE_h_korr']         = daten_sub['h22_Zuluft'] + WGR_kal['Nacherhitzer_Energie']
WGR_kal['Außenluft_WG']                  = psy.Hum_rat2(WGR_kal['Außenluft_C'],  WGR_kal['Außenluft_rF']/100,        WGR_kal['W_Luftdruck'])
WGR_kal['Zuluft_nach_NE_h']              = psy.Enthalpy_Air_H2O(WGR_kal['L_Zulufttemperatur'],    WGR_kal['Außenluft_WG'])



effizienz() 

## 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'] * daten_sub['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()  


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


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['TMWV'].plot(ax=ax,color=colo('gelb',1), linewidth=.5, label = 'TMWV', style='-')  
daten_sub['L_Zuluft_VPunkt'].plot(ax=ax2,color=colo('violet',1), linewidth=.5, label = 'Zuluft Vpunkt', style='-')   

daten_sub['L_Zulufttemperatur'].plot(ax=ax,color=colo('rot',1), linewidth=.5, label = 'Zulufttemp nach NE', style='-')   

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

WGR_kal['Zuluft_C'].plot(ax=ax,color=colo('violet',1), linewidth=.5, label = 'Zulufttemp vor NE gem', style='-') 
WGR_kal['Zuluft_vor_NE_C_rol'].plot(ax=ax,color=colo('gelb',1), linewidth=.5, label = 'Zulufttemp vor NE ber', style='-') 

# daten_sub['Zuluft_C'].plot(ax=ax,color=colo('rot',1), linewidth=.5, label = 'Zulufttemp vor NE', 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,70) 
# ax2.set_ylim(-33,100)
date_form = DateFormatter("%H:%M\n%d.%m.")
ax.xaxis.set_major_formatter(date_form)
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)   

plt.title('Messwerte: Testo ')
plt.setp(ax.get_xticklabels(), ha="center", rotation=0)


# 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.01.31 07:00:00"),pd.to_datetime("2018.02.20 12:00:00")])

ax.set(xlim=[pd.to_datetime("2018.01.31 00:00:00"),pd.to_datetime("2018.02.01 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()

WGR_kal = daten_sub.copy()
# WRG_Kalibrierung()
daten_sub['TMWV']
# ddd

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=87, 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,87,81,72,65]) 
ax.set(xlim=[0,2000])  
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

#     ## Wärmespeicherkapazität des Gebäudes
#     ## Umweg über einen eigenen DataFrame
#     df                                  = pd.DataFrame()
#     df['Abluft_C']                      = daten_sub['Abluft_C'] 
#     df['Wärmespeicherkap']              = daten_sub['Abluft_C'].groupby(daten_sub.index.date).apply(lambda x: x.iloc[-1] -x.iloc[0]) * 8.837 / 24 # Stunden pro Tag
#     df['Wärmespeicherkap'].fillna(method='ffill', inplace =True) 

#     daten_sub['Wärmespeicherkap']       = df['Wärmespeicherkap']
#     daten_sub['gesp_Wärme_neg']         = np.where(daten_sub['Wärmespeicherkap'] < 0,  daten_sub['Wärmespeicherkap'].mul(-1), np.NaN)
#     daten_sub['gesp_Wärme_po']          = np.where(daten_sub['Wärmespeicherkap'] > 0,  daten_sub['Wärmespeicherkap'].mul( 1), np.NaN) 

    ## 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() ## oder median??
    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'] < 1, 0, daten_sub['Personen_1'])
    daten_sub['Personen_2']             = np.where(daten_sub['Personen_2'] < 1, 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 Heizung + 2h aus - keine Bilanz erstellen
#     daten_sub["S_Heizung_Vpunkt_flag"]                                                  = np.nan
#     daten_sub.loc[daten_sub["S_Heizung_Vpunkt"]      > 50,     "S_Heizung_Vpunkt_flag"] = 1
#     daten_sub["S_Heizung_Vpunkt_flag"].fillna(method = "ffill",limit = 480,     inplace = True)
#     daten_sub.loc[daten_sub["S_Heizung_Vpunkt_flag"] == 1,     "Lüftung"]               = 0


    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) 

#     print_md(f'{title} minütlich<br>Wärmebilanz Summe: {int(daten_sub.Wärmebilanz.sum()/240)} kWh<br> positiv: {int(daten_sub.Wärmebilanz_po.sum()/240)} negativ: {int(daten_sub.Wärmebilanz_ne.sum()/240)} ')

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.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)
#     return daten_tgl




def wärmefluss_plot(i,title,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=(8,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['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.\n %b') for item in W_rein.index[::1]] 
        ax.set_xlim(-0.5,len(W_rein.index))  
        ax.set_xticklabels(ticklabels, rotation=0)
        ax.set_xticks(np.arange(width/2, len(W_rein.index), step = 1))
        ax.set_xlabel('')
        ax.set_ylim(-100,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)

#     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())} ')

# effizienz()        
# wärmefluss_plot(1,'title',nr=0)
# daten_tgl['Wärmespeicherkap'].sum()

Kalibrierungtestplot

def kalibrierungtestplot():
    fig, axes = plt.subplots(nrows=3, ncols=1, sharex=True , constrained_layout=False,figsize=(5.8,4.05)) 

    axes[0].plot(daten_sub['Außenluft_C'], color=colo('blau',1.6),    linewidth=1,    label='__noLabel__') 
    axes[0].plot(WGR_kal['Außenluft_C'],   color=colo('blau',1),      linewidth=0.5,  label='Außenluft') 
    axes[0].plot(daten_sub['Zuluft_C'],    color=colo('orange',1.6),  linewidth=1,    label='__noLabel__') 
    axes[0].plot(WGR_kal['Zuluft_C'],      color=colo('orange',1),    linewidth=0.5,  label='Zuluft') 
    axes[0].plot(daten_sub['Abluft_C'],    color=colo('rot',1.6),     linewidth=1,    label='__noLabel__') 
    axes[0].plot(WGR_kal['Abluft_C'],      color=colo('rot',1),       linewidth=0.5,  label='Abluft') 
    axes[0].plot(daten_sub['Fortluft_C'],  color=colo('grün',1.6),    linewidth=1,    label='__noLabel__') 
    axes[0].plot(WGR_kal['Fortluft_C'],    color=colo('grün',1),      linewidth=0.5,  label='Fortluft') 
    axes[0].set(ylabel=r"\textbf{Temperatur}") 
    axes[0].set_ylim(-5,26)  

    axes[1].plot(daten_sub['Außenluft_rF'], color=colo('blau',1.6),    linewidth=1,    label='__noLabel__') 
    axes[1].plot(WGR_kal['Außenluft_rF'],   color=colo('blau',1),      linewidth=0.5,  label='Außenluft') 
    axes[1].plot(daten_sub['Zuluft_rF'],    color=colo('orange',1.6),  linewidth=1,    label='__noLabel__') 
    axes[1].plot(WGR_kal['Zuluft_rF'],      color=colo('orange',1),    linewidth=0.5,  label='Zuluft') 
    axes[1].plot(daten_sub['Abluft_rF'],    color=colo('rot',1.6),     linewidth=1,    label='__noLabel__') 
    axes[1].plot(WGR_kal['Abluft_rF'],      color=colo('rot',1),       linewidth=0.5,  label='Abluft') 
    axes[1].plot(daten_sub['Fortluft_rF'],  color=colo('grün',1.6),    linewidth=1,    label='__noLabel__') 
    axes[1].plot(WGR_kal['Fortluft_rF'],    color=colo('grün',1),      linewidth=0.5,  label='Fortluft') 
    axes[1].set(ylabel=r"\textbf{rel. Luftfeuchtigkeit}") 
    axes[1].set_ylim(20,100)  

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


    axes[0].set_title('Testo ($breit\&hell$) vs IntelliBMS ($dunkel\&schmal$)')
    axes[0].set(xlim=[pd.to_datetime('2018-01-31'),pd.to_datetime('2018-02-11')]) 
    axes[0].xaxis.set_major_formatter(mdates.DateFormatter('%d. %m.')) 

    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()

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()     

stacked Plot

## war nur n Versuch die Wärmebilanz anders darzustellen
def stacked_plot():
    df = daten_sub[['TMWV','S_Heizung_Energie']]
    fig, ax = plt.subplots()
    # split dataframe df into negative only and positive only values
    df_neg, df_pos = df.clip(upper=0), df.clip(lower=0)
    # stacked area plot of positive values
    df_pos.plot.area(ax=ax, stacked=True, linewidth=0.)
    # reset the color cycleb
    ax.set_prop_cycle(None)
    # stacked area plot of negative values, prepend column names with '_' such that they don't appear in the legend
    df_neg.rename(columns=lambda x: '_' + x).plot.area(ax=ax, stacked=True, linewidth=0.)
    # rescale the y axis
    ax.set_ylim([df_neg.sum(axis=1).min(), df_pos.sum(axis=1).max()]) 

BF / MinMax - Lüftung

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

    fig, ax = plt.subplots(constrained_layout=True, figsize=(4,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(-30,50)
    date_form = DateFormatter("%d.\n%m.")
    ax.xaxis.set_major_formatter(date_form)
    plt.xticks(rotation=0, ha='center')
#     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   = 100 ## Betrag des Blanzfehlers ab wann die Variante "gut" ist

## 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)
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
                        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')  
---------------------------------------------------------------------------

NameError                                 Traceback (most recent call last)

<ipython-input-22-d85660d1b160> in <module>
     28 ## einmal mit Standardwerten durchrechnen um ein Ausgangspunkt für Min und Max zu haben
     29 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)
---> 30 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)
     31 wärmefluss(title)
     32 nr = 0


NameError: name 'effizienz' is not defined

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
# minmax['Date1'] = pd.to_datetime(minmax['Date1'])
# minmax['Date1'] = [datetime.strptime(x, '%Y-%m-%d %H:%M:%S') for x in minmax.Date1]

# 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=colo('black',.1), 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('grey',1.5), 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{Bilanzfehler} ($kWh$)')    
# 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=1, loc=1)
set_legend_linewidth(legend)   
ax.axhline(y=0, linewidth=0.4,   color=colo('black',.7), xmin=0.0001, xmax=1)

# plt.gcf().autofmt_xdate()
date_form = DateFormatter("%d.\n%m.")
ax.xaxis.set_major_formatter(date_form)
plt.xticks(rotation=0, ha='center')
ax.set(xlim=[pd.to_datetime("2018-01-31"),pd.to_datetime("2018-02-20")])
## X Achse mit Monaten und 2 mal dem Jahr 
# monthlyX(ax)
# plt.savefig(output_folder + '/' + file_name + '_MINMAX_Übersicht.pdf')
plt.show()


# fig, ax = plt.subplots(constrained_layout=True) 
# ax.ticklabel_format(useLocale=True) ## dot as thousand separator  
# error_kw = dict(lw=0.5, capsize=1, capthick=0.5, ecolor=('black')) 

# minmax['Wärmebilanz'].plot.bar(position= 0.5, yerr=Wärmebilanz_error, error_kw=error_kw, color=colo('grün',1), edgecolor='black',linewidth = 0.3, width=0.3,ax=ax,stacked=True,alpha = 1) 
# minmax['Lüftung'].plot.bar(position= 1.5,     yerr=Lüftung_error,     error_kw=error_kw, color=colo('grau',1), edgecolor='black',linewidth = 0.3, width=0.3,ax=ax,stacked=True,alpha = 1) 


# display(minmax)
# display(minmax[['Wärmebilanz','Wärmebilanz_min','Wärmebilanz_max','Lüftung','Lüftung_min','Lüftung_max']])
---------------------------------------------------------------------------

NameError                                 Traceback (most recent call last)

<ipython-input-23-9719c9476cb3> in <module>
----> 1 Wärmebilanz_lower_error      = minmax['Wärmebilanz_min'] #- minmax['Wärmebilanz']
      2 Wärmebilanz_upper_error      = minmax['Wärmebilanz_max'] #+ minmax['Wärmebilanz']
      3 Wärmebilanz_error            = [Wärmebilanz_lower_error, Wärmebilanz_upper_error]
      4 
      5 


NameError: name 'minmax' is not defined

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_ne'].plot(ax=ax3,color=colo('blau',1), linewidth=1, label = 'Summe positiv')   
bf['Wärmebilanz_po'].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(-1500,2000)
ax2.set_ylim(1.7,3.7)  
ax3.set_ylim(-1000,3000)  
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(40,300)  
## nur die Besten der Besten
display(bf[bf['Wärmebilanz_sum'].between(-100, 100)].sort_values(by=['Wärmebilanz_std'])[['Wärmebilanz_sum', 'Wärmebilanz_std', 'Wärmebilanz_po', 'Wärmebilanz_ne', 'titel']].style.set_properties(subset=['titel'], **{'width': '600px'}))
---------------------------------------------------------------------------

NameError                                 Traceback (most recent call last)

<ipython-input-24-a98de1cae256> in <module>
      5 ax3 = ax.twinx()
      6 ax3.spines['right'].set_position(('axes', 1.15))
----> 7 bf['Wärmebilanz_sum'].plot(ax=ax,color=colo('grün',1), linewidth=1, label = 'Wärmebilanz_sum',style='-')
      8 bf['Wärmebilanz_std'].plot(ax=ax2,color=colo('rot',1), linewidth=.6, label = 'Wärmebilanz_std')
      9 bf['Wärmebilanz_ne'].plot(ax=ax3,color=colo('blau',1), linewidth=1, label = 'Summe positiv')


NameError: name 'bf' is not defined
# ## die besten Varianten von -50 bis 50 kWh Bilanzfehler, nach std sortiert
# Nr   sum std         

# 17    -10 1.733504    außen_C-1.0 fort_C1.0 außen_rF-5 fort_rf-5 by-10 zu_Vp-10
# 54    0   1.765677    außen_C1.0 fort_C1.0 außen_rF-5 fort_rf5 by-10 zu_Vp10
# 31    38  1.848723    außen_C-1.0 fort_C1.0 außen_rF5 fort_rf5 by10 zu_Vp-10
# 8 92  1.849826    außen_C-1.0 fort_C-1.0 außen_rF-5 fort_rf5 by10 zu_Vp10
# 28    39  1.887463    außen_C-1.0 fort_C1.0 außen_rF5 fort_rf-5 by10 zu_Vp10
bf

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() 


Genauigkeitscheck

daten_chck = daten.loc[eins : sechs].copy()    
daten_chck = daten_chck.replace(0, np.nan)
daten_chck = daten_chck.dropna(how='all', axis=0)
daten_chck = daten_chck.replace(np.nan, 0)
## Energie der Zuluft vor dem Nacherhitzer aus Intellidaten
## IntelliBMS Außenlufttemperatur gegen Testo kalibrieren
daten_chck['L_Aussenlufttemperatur_1_korr'] = kalibrieren(daten_chck['L_Aussenlufttemperatur_1'], daten_chck['Außenluft_C'])
## rel Luftfeuchte der Wetterstation gegen Testo kalibrieren
daten_chck['W_Luftfeuchtigkeit_korr']       = kalibrieren(daten_chck['W_Luftfeuchtigkeit'],        daten_chck['Außenluft_rF'])
## Wassergehalt der Außenluft berechnen (ist gleich dem WG der Zuluft)
daten_chck['Außenluft_WG']                  = psy.Hum_rat2(daten_chck['L_Aussenlufttemperatur_1_korr'],  daten_chck['W_Luftfeuchtigkeit_korr']/100,        daten_chck['W_Luftdruck'])
## Wassergehalt der Zuluft berechnen (ist gleich dem WG der Außenluft)
daten_chck['Zuluft_WG']                     = daten_chck['Außenluft_WG'] 
## spezifisches Gewicht der Zuluft in kg/m³
daten_chck['Zuluft_Masse']                  = psy.Dry_Air_Density(daten_chck['W_Luftdruck'], daten_chck['L_Zulufttemperatur'], daten_chck['Zuluft_WG']) * (1 + daten_chck['Zuluft_WG'])
## 2 Enthalpie der Luft nach dem Nacherhitzer in kJ/kg
daten_chck['Zuluft_nach_NE_h']              = psy.Enthalpy_Air_H2O(daten_chck['L_Zulufttemperatur'],    daten_chck['Zuluft_WG'])
## 3 Energie der Luft nach dem Nacherhitzer in kWh
daten_chck['Zuluft_nach_NE_Energie']        = daten_chck['Zuluft_nach_NE_h'] *  daten_chck['Zuluft_Masse'] * daten_chck['L_Zuluft_VPunkt'] * (1/3600) ## kJ in kWh
## abgegebene Energie des Nacherhitzers in kWh
daten_chck['Nacherhitzer_Energie']          = energie(daten_chck['S_Heizung_VL'], daten_chck['S_Heizung_RL'], daten_chck['S_Heizung_Vpunkt'])
## 4 Energie der Luft vor dem Nacherhitzer in kWh
daten_chck['Zuluft_vor_NE_Energie']         = daten_chck['Zuluft_nach_NE_Energie'] - daten_chck['Nacherhitzer_Energie']


## Energie der Zuluft vor dem Nacherhitzer aus Testodaten 
## Wassergehalt der Außenluft berechnen (ist gleich dem WG der Zuluft)
daten_chck['Zuluft_t_WG']                  = psy.Hum_rat2(daten_chck['Zuluft_C'],  daten_chck['Zuluft_rF']/100,        daten_chck['W_Luftdruck'])
## spezifisches Gewicht der Außenluft in kg/m³
daten_chck['Zuluft_t_Masse']               = psy.Dry_Air_Density(daten_chck['W_Luftdruck'], daten_chck['Zuluft_C'], daten_chck['Zuluft_t_WG']) * (1 + daten_chck['Zuluft_t_WG'])
## 2 Enthalpie der Außenluft in kJ/kg
daten_chck['Zuluft_t_h']                   = psy.Enthalpy_Air_H2O(daten_chck['L_Aussenlufttemperatur_1_korr'],    daten_chck['Zuluft_t_WG'])
## 3 Energie der Außenluft in kWh
daten_chck['Zuluft_t_Energie']             = daten_chck['Zuluft_t_h'] *  daten_chck['Zuluft_t_Masse'] * daten_chck['L_Zuluft_VPunkt'] * (1/3600) ## kJ in kWh

WGR_kal['L_Aussenlufttemperatur_1'] = WGR_kal['L_Aussenlufttemperatur_1'] * 0.9484152677039202 + 1.385025168282651
WGR_kal['W_Luftfeuchtigkeit'] = WGR_kal['W_Luftfeuchtigkeit'] * 0.6222670407587347 + 19.99665564449227
fig, ax = plt.subplots() 
daten_chck['Zuluft_vor_NE_Energie'].plot(ax=ax,color=colo('rot',1), linewidth=1, label = 'Zuluft_vor_NE_Energie')  
daten_chck['Zuluft_t_Energie'].plot(ax=ax,color=colo('grün',1), linewidth=1, label = 'Zuluft_t_Energie')   
daten_chck['Zuluft_vor_NE_Energie'].plot(ax=ax,color=colo('rot',1), linewidth=1, label = 'Zuluft_vor_NE_Energie')  
daten_chck['Zuluft_t_Energie'].plot(ax=ax,color=colo('grün',1), linewidth=1, label = 'Zuluft_t_Energie')   
ax.set_ylabel(r'\textbf{Energie}')  
ax.set_xlabel('')   
ax.set_ylim(0,25)  
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('2018-02-06'),pd.to_datetime('2018-02-08')])  
[(736731.0, 736733.0)]

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 % 

# kalibrierung() ## nichtmehr nötig aufzurufen
## mit den gegen die Testos kalibrierten Werte der Lüftungsanlage rechnen
# zuweisungen() 

## 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.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)

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


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

## einzelne Tageswerte plotten zum Vergleich untereinander (drei Plotz mit vielen Subplots)
bilanz(9,12,2017)   
tageswerte(9,12,2017)
luftwerte(9,12,2017) 

bilanz(11,2,2018)   
tageswerte(11,2,2018)
luftwerte(11,2,2018) 
---------------------------------------------------------------------------

NameError                                 Traceback (most recent call last)

<ipython-input-33-7ce220a070df> in <module>
     28 title = 'Lüftung mit Fehlerbalken'
     29 #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)
---> 30 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)
     31 wärmefluss(title)
     32 # print(title)


NameError: name 'effizienz' is not defined

CO2 - Menschen

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

daten_tgl['Personen_max_1'] = daten_sub.resample('D')['Personen_1'].agg(['max'])  
#display(daten_tgl['Personen_max'])

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

daten_tgl['Personen_1'].plot(ax=ax,color=colo('grün',1), linewidth=1, label = 'Personenstunden',style='.-')   
daten_tgl['Personen_max_1'].plot(ax=ax2,color=colo('rot',1), linewidth=1, label = 'Personen_max',style='.-')   
# daten_tgl['Personen_2'].plot(ax=ax,color=colo('blau',1), linewidth=1, label = 'Personen_2')   

daten_sub['Personen_1'].plot(ax=ax2,color=colo('grün',1.7), linewidth=1, label = 'Personen_15s')   
daten_sub['Personen_1'].resample("1H").mean().plot(ax=ax2,color=colo('rot',1.7), linewidth=1, label = 'Personen_1h')    
# daten_sub['Personen_2'].plot(ax=ax2,color=colo('blau',1.7), linewidth=1, label = 'Personen_2')   

# 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')   


ax.set_ylabel(r'\textbf{Personenstunden} $Nh$')  
ax2.set_ylabel(r'\textbf{Personen} $N$')  
ax.set_xlabel('')   
ax.set_ylim(0,130)  
ax2.set_ylim(0,30)  
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')])  
---------------------------------------------------------------------------

NameError                                 Traceback (most recent call last)

<ipython-input-34-7e5fdda90c90> in <module>
      1 #print (daten_sub.resample('D')['Personen_1'].agg(['max']))
      2 
----> 3 daten_tgl['Personen_max_1'] = daten_sub.resample('D')['Personen_1'].agg(['max'])
      4 #display(daten_tgl['Personen_max'])
      5 


NameError: name 'daten_sub' is not defined

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
# 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

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-12-11 17:00:00'),pd.to_datetime('2017-12-11 17:30:00')])  
---------------------------------------------------------------------------

NameError                                 Traceback (most recent call last)

<ipython-input-35-8e8360768455> in <module>
      3 
      4 
----> 5 daten_flag = daten_sub.copy()
      6 daten_flag["Lüftung1"]                                                               = daten_flag["Lüftung"]
      7 daten_flag["Lüftung_flag"]                                                           = 0


NameError: name 'daten_sub' is not defined

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  
 Bootshaus subdirectory