This script shows how to use the existing code in opengrid to create a water consumption benchmark.


In [ ]:
import os, sys
import inspect
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
script_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
# add the path to opengrid to sys.path
sys.path.append(os.path.join(script_dir, os.pardir, os.pardir))

from opengrid.library import config
c = config.Config()

%matplotlib inline
plt.rcParams['figure.figsize'] = 16,8

In [ ]:
sys.path.append(c.get('tmpo', 'folder'))

try:
    if os.path.exists(c.get('tmpo', 'data')):
        path_to_tmpo_data = c.get('tmpo', 'data')
except:
    path_to_tmpo_data = None

In [ ]:
from opengrid.library.houseprint import houseprint

We create one dataframe containing a column for each water sensor


In [ ]:
hp = houseprint.load_houseprint_from_file('new_houseprint.pkl')
hp.init_tmpo()

In [ ]:
df = hp.get_data(sensortype='water')

In [ ]:
#1st derivative
df = df.diff()

#retain only positive values (sometimes there are meter resets)
df = df[df > 0]

In [ ]:
# plot timeseries and load duration for each retained sensor

for sensor in df.columns:
    plt.figure()
    ax1=plt.subplot(121)
    plt.plot_date(df.index, df[sensor], '-', label=sensor)
    plt.ylabel('water consumption [l/min]')
    plt.legend()
    
    ax2=plt.subplot(122)
    plt.plot(np.sort(df[sensor])[::-1], label=sensor)
    plt.ylabel('water JBDC [l/min]')
    plt.legend()

In [ ]: