Exemplo n.º 1
0
def test_convert_random_dataset():
    input_filepath = r'C:\Users\CVLab\Documents\nilm\nilmtk\data\random.h5'
    output_filepath = r'C:\Users\CVLab\Documents\nilm\nilmtk\data\random_csv'

    if os.path.isdir(output_filepath):
        shutil.rmtree(output_filepath)

    input_store = HDFDataStore(input_filepath)
    output_store = CSVDataStore(output_filepath)

    convert_datastore(input_store, output_store)

    input_store.close()
    output_store.close()
Exemplo n.º 2
0
def test_convert_random_dataset():
    input_filepath = 'data/random.h5'
    output_filepath = 'data/random_csv'

    if os.path.isdir(output_filepath):
        shutil.rmtree(output_filepath)

    input_store = HDFDataStore(input_filepath)
    output_store = CSVDataStore(output_filepath)

    convert_datastore(input_store, output_store)

    input_store.close()
    output_store.close()
Exemplo n.º 3
0
def test_convert_random_dataset():
    input_filepath = 'data/random.h5'
    output_filepath = 'data/random_csv'

    if os.path.isdir(output_filepath):
        shutil.rmtree(output_filepath)

    input_store=HDFDataStore(input_filepath)
    output_store=CSVDataStore(output_filepath)

    convert_datastore(input_store, output_store)

    input_store.close()
    output_store.close()
    
Exemplo n.º 4
0
    def test_co_correctness(self):
        elec = self.dataset.buildings[1].elec
        co = CombinatorialOptimisation()
        co.train(elec)
        mains = elec.mains()
        output = HDFDataStore("output.h5", "w")
        co.disaggregate(mains, output, resample_seconds=1)

        for meter in range(2, 4):
            df1 = output.store.get("/building1/elec/meter{}".format(meter))
            df2 = self.dataset.store.store.get("/building1/elec/meter{}".format(meter))

            self.assertEqual((df1 == df2).sum().values[0], len(df1.index))
            self.assertEqual(len(df1.index), len(df2.index))
        output.close()
        rm("output.h5")
Exemplo n.º 5
0
    def test_co_correctness(self):
        elec = self.dataset.buildings[1].elec
        co = CombinatorialOptimisation()
        co.train(elec)
        mains = elec.mains()
        output = HDFDataStore('output.h5', 'w')
        co.disaggregate(mains, output, resample_seconds=1)

        for meter in range(2, 4):
            df1 = output.store.get('/building1/elec/meter{}'.format(meter))
            df2 = self.dataset.store.store.get(
                '/building1/elec/meter{}'.format(meter))

            self.assertEqual((df1 == df2).sum().values[0], len(df1.index))
            self.assertEqual(len(df1.index), len(df2.index))
        output.close()
        remove("output.h5")
Exemplo n.º 6
0
    def test_fhmm_correctness(self):
        elec = self.dataset.buildings[1].elec
        fhmm = FHMM()
        fhmm.train(elec)
        mains = elec.mains()
        output = HDFDataStore('output.h5', 'w')
        fhmm.disaggregate(mains, output, sample_period=1)

        for meter in range(2, 4):
            df1 = output.store.get('/building1/elec/meter{}'.format(meter))
            df2 = self.dataset.store.store.get(
                '/building1/elec/meter{}'.format(meter))

            self.assertEqual((df1 == df2).sum().values[0], len(df1.index))
            self.assertEqual(len(df1.index), len(df2.index))
        output.close()
        remove("output.h5")
Exemplo n.º 7
0
    def test_fhmm_correctness(self):
        elec = self.dataset.buildings[1].elec
        fhmm = FHMM()
        fhmm.train(elec)
        mains = elec.mains()
        output = HDFDataStore('output.h5', 'w')
        fhmm.disaggregate(mains, output, sample_period=1)

        for meter in range(2, 4):
            df1 = output.store.get('/building1/elec/meter{}'.format(meter))
            df2 = self.dataset.store.store.get(
                '/building1/elec/meter{}'.format(meter))

            self.assertEqual((df1 == df2).sum().values[0], len(df1.index))
            self.assertEqual(len(df1.index), len(df2.index))
        output.close()
        remove("output.h5")
Exemplo n.º 8
0
disag_filename = 'disag-out.h5'
pred_df1 = None
if not Path("disag-out.h5").exists():
    from nilmtk.datastore import HDFDataStore

    output = HDFDataStore(disag_filename, 'w')

    # test_mains: The aggregated signal meter
    # output: The output datastore
    # train_meter: This is used in order to copy the metadata of the train meter into the datastore
    pred_df1 = gru.disaggregate(test_mains,
                                output,
                                train_meter,
                                sample_period=1)
    output.close()

result = DataSet(disag_filename)
res_elec = result.buildings[1].elec
predicted = res_elec['fridge']
ground_truth = test_elec['fridge']

import matplotlib.pyplot as plt
predicted.plot()
plt.show()
ground_truth.plot()
plt.show()
test_elec.mains().plot()
plt.show()
pred_df1.plot()
plt.show()
from nilmtk.datastore import HDFDataStore, CSVDataStore 
from nilmtk.datastore.datastore import convert_datastore
import os
import shutil

input_filepath = 'data/random.h5'
output_filepath = 'data/random_csv'

if os.path.isdir(output_filepath):
    shutil.rmtree(output_filepath)

input_store=HDFDataStore(input_filepath)
output_store=CSVDataStore(output_filepath)

convert_datastore(input_store, output_store)

input_store.close()
output_store.close()
Exemplo n.º 10
0
from nilmtk.datastore import HDFDataStore, CSVDataStore
from nilmtk.datastore.datastore import convert_datastore
import os
import shutil

input_filepath = 'data/random.h5'
output_filepath = 'data/random_csv'

if os.path.isdir(output_filepath):
    shutil.rmtree(output_filepath)

input_store = HDFDataStore(input_filepath)
output_store = CSVDataStore(output_filepath)

convert_datastore(input_store, output_store)

input_store.close()
output_store.close()