<jupyter_start><jupyter_text>This script shows how to use the existing code in opengrid to create a water consumption benchmark.<jupyter_code>import numpy as np
import matplotlib.pyplot as plt
import pandas as pd

from opengrid_dev import config
c = config.Config()

%matplotlib inline
plt.rcParams['figure.figsize'] = 16,8
from opengrid_dev.library.houseprint import houseprint<jupyter_output><empty_output><jupyter_text>Load the Houseprint and sync all data<jupyter_code>hp = houseprint.Houseprint()
hp.sync_tmpos()<jupyter_output><empty_output><jupyter_text>Create a dataframe containing a column for each water sensor with data of exactly one year (up till now)<jupyter_code>df = hp.get_data(sensortype='water', head=pd.Timestamp('now') - pd.Timedelta(days=365))
#retain only positive values (sometimes there are meter resets)
df = df[df > 0]<jupyter_output><empty_output><jupyter_text>Plot results  Plot timeseries and load duration for each retained sensor<jupyter_code>for sensor in df.columns:
    plt.figure()
    ts = df[sensor].dropna()
    ax1=plt.subplot(121)
    plt.plot_date(ts.index, ts, '-', label=sensor)
    plt.ylabel('water consumption [l/min]')
    plt.legend()
    
    ax2=plt.subplot(122)
    plt.plot(np.sort(ts)[::-1], label=sensor)
    plt.ylabel('water JBDC [l/min]')
    plt.legend()<jupyter_output><empty_output><jupyter_text>Let's refine the load duration into a histogram<jupyter_code>for sensor in df.columns:
    plt.figure()
    ts = df[sensor]
    ts=ts[ts>1]
    ts=ts[ts<30]
    ts.hist(bins=100)
    plt.title(hp.find_sensor(sensor).device.key + ' - ' + hp.find_sensor(sensor).description + ' - ' + sensor)
for sensor in df.columns:
        
    plt.figure()
    ts = df[sensor]
    ts=ts[ts>0.1]
    ts=ts[ts<30]
    
    hst, edges = np.histogram(ts, np.arange(0,20,0.5))
    hst_weighted = hst * edges[1:]
    plt.plot(np.arange(0,20,0.5)[1:], hst_weighted)
    #plt.plot(np.arange(0,20,0.25)[1:], hst)
    plt.title(hp.find_sensor(sensor).device.key + ' - ' + sensor)
    plt.ylabel('Water consumption (liter)')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13566634707574304, 'fraction_numerical': 0.021572387344199424, 'mean_word_length': 4.610215053763441, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '73772', 'license': 'Apache-2.0', 'n_tokens_mistral': 797, 'n_tokens_neox': 760, 'n_words': 158, 'path': 'notebooks/Analysis/Water_consumption.ipynb', 'repo_name': 'opengridcc/opengrid_dev', 'size': '2086'}