コード例 #1
0
ファイル: test_metergroup.py プロジェクト: BenGeek88/nilmtk
    def test_select(self):
        fridge_meter = ElecMeter()
        fridge = Appliance({'type':'fridge', 'instance':1})
        fridge_meter.appliances = [fridge]
        mg = MeterGroup([fridge_meter])

        self.assertEqual(mg.select_using_appliances(category='cold'), mg)
コード例 #2
0
    def test_getitem(self):
        fridge_meter = ElecMeter()
        fridge = Appliance({'type': 'fridge', 'instance': 1})
        fridge_meter.appliances = [fridge]
        mg = MeterGroup([fridge_meter])

        # test good keys
        for key in [
                'fridge', ('fridge', 1), {
                    'type': 'fridge'
                }, {
                    'type': 'fridge',
                    'instance': 1
                }
        ]:
            self.assertEqual(mg[key], fridge_meter)

        # test bad key values
        for key in [
                'foo', ('foo', 2), ('fridge', 2), {
                    'type': 'fridge',
                    'instance': -12
                }
        ]:
            with self.assertRaises(KeyError):
                mg[key]

        # test bad key types
        for key in [True, False, ['fridge']]:
            with self.assertRaises(TypeError):
                mg[key]
コード例 #3
0
    def test_select(self):
        fridge_meter = ElecMeter()
        fridge = Appliance({'type': 'fridge', 'instance': 1})
        fridge_meter.appliances = [fridge]
        mg = MeterGroup([fridge_meter])

        self.assertEqual(mg.select_using_appliances(category='cold'), mg)
コード例 #4
0
ファイル: test_metergroup.py プロジェクト: vermaarjun7/nilmtk
 def test_wiring_graph(self):
     meter1 = ElecMeter(metadata={'site_meter': True}, 
                        meter_id=ElecMeterID(1,1,'REDD'))
     meter2 = ElecMeter(metadata={'submeter_of': 1}, 
                        meter_id=ElecMeterID(2,1,'REDD'))
     meter3 = ElecMeter(metadata={'submeter_of': 2},
                        meter_id=ElecMeterID(3,1,'REDD'))
     mg = MeterGroup([meter1, meter2, meter3])
     wiring_graph = mg.wiring_graph()
     
     self.assertIs(mg.mains(), meter1)
     self.assertEqual(mg.meters_directly_downstream_of_mains().meters, [meter2])
     self.assertEqual(wiring_graph.nodes(), [meter2, meter3, meter1])
コード例 #5
0
    def test_pipeline(self):
        meter1 = ElecMeter(store=self.datastore,
                           metadata=self.meter_meta,
                           meter_id=METER_ID)

        # load co_test.h5
        dataset = DataSet(join(data_dir(), 'co_test.h5'))
        meter2 = dataset.buildings[1].elec.mains()

        for meter in [meter1, meter2]:
            for chunksize in [None, 2**10, 2**29]:
                if chunksize is None:
                    load_kwargs = {}
                else:
                    load_kwargs = {'chunksize': chunksize}

                source_node = meter.get_source_node(**load_kwargs)
                good_sections = GoodSections(source_node)
                good_sections.run()
                combined = good_sections.results  #.simple()
                meter.clear_cache()
                meter.good_sections(**load_kwargs)
                meter.good_sections(**load_kwargs)
                meter.clear_cache()

        dataset.store.close()
コード例 #6
0
ファイル: test_metergroup.py プロジェクト: vermaarjun7/nilmtk
 def test_from_list(self):
     meters = []
     for i in range(1,6):
         meters.append(ElecMeter(meter_id=ElecMeterID(i, 1, None)))
         
     mg = global_meter_group.from_list([
         ElecMeterID(1,1,None),
         (ElecMeterID(2,1,None), 
          (ElecMeterID(3,1,None), ElecMeterID(4,1,None), ElecMeterID(5,1,None)))
     ])
     """
コード例 #7
0
ファイル: test_metergroup.py プロジェクト: BenGeek88/nilmtk
    def test_getitem(self):
        fridge_meter = ElecMeter()
        fridge = Appliance({'type':'fridge', 'instance':1})
        fridge_meter.appliances = [fridge]
        mg = MeterGroup([fridge_meter])

        # test good keys
        for key in ['fridge', ('fridge', 1), {'type':'fridge'}, 
                    {'type':'fridge', 'instance': 1}]:
            self.assertEqual(mg[key], fridge_meter)
        
        # test bad key values
        for key in ['foo', ('foo', 2), ('fridge', 2), 
                    {'type':'fridge', 'instance': -12}]:
            with self.assertRaises(KeyError):
                mg[key]

        # test bad key types
        for key in [True, False, (1,2,3), ['fridge']]:
            with self.assertRaises(TypeError):
                mg[key]
コード例 #8
0
ファイル: test_metergroup.py プロジェクト: scoredata/nilmtk
    def test_proportion_of_energy_submetered(self):
        meters = []
        for i in [1, 2, 3]:
            meter_meta = self.datastore.load_metadata(
                'building1')['elec_meters'][i]
            meter_id = ElecMeterID(i, 1, 'REDD')
            meter = ElecMeter(self.datastore, meter_meta, meter_id)
            meters.append(meter)

        mains = meters[0]
        mg = MeterGroup(meters)
        self.assertEqual(mg.proportion_of_energy_submetered(), 1.0)
コード例 #9
0
    def test_from_list(self):
        meters = []
        for i in range(1, 6):
            meters.append(ElecMeter(meter_id=ElecMeterID(i, 1, None)))

        mg = global_meter_group.from_list([
            ElecMeterID(1, 1, None),
            (ElecMeterID(2, 1,
                         None), (ElecMeterID(3, 1,
                                             None), ElecMeterID(4, 1, None),
                                 ElecMeterID(5, 1, None)))
        ])
        self.assertEqual(mg.meters[0], meters[0])
        self.assertEqual(mg.meters[1].meters[0], meters[1])
        self.assertEqual(len(mg.meters[1].meters[1].meters), 3)
        self.assertEqual(len(mg.meters), 2)
コード例 #10
0
ファイル: test_metergroup.py プロジェクト: BenGeek88/nilmtk
 def setUpClass(cls):
     filename = join(data_dir(), 'energy.h5')
     cls.datastore = HDFDataStore(filename)
     ElecMeter.load_meter_devices(cls.datastore)
コード例 #11
0
 def setUpClass(cls):
     filename = join(data_dir(), 'energy_complex.h5')
     cls.datastore = HDFDataStore(filename)
     ElecMeter.load_meter_devices(cls.datastore)
     cls.meter_meta = cls.datastore.load_metadata(
         'building1')['elec_meters'][METER_ID.instance]
コード例 #12
0
 def test_full_results_with_no_sections_raises_runtime_error(self):
     mg = MeterGroup([ElecMeter(), ElecMeter()])
     with self.assertRaises(RuntimeError):
         mg.dropout_rate(full_results=True)
コード例 #13
0
 def setUpClass(cls):
     filename = join(data_dir(), 'energy.h5')
     cls.datastore = HDFDataStore(filename)
     ElecMeter.load_meter_devices(cls.datastore)
コード例 #14
0
 def setUpClass(cls):
     filename = join(data_dir(), 'energy_complex.h5')
     cls.datastore = HDFDataStore(filename)
     ElecMeter.load_meter_devices(cls.datastore)
     cls.meter_meta = cls.datastore.load_metadata('building1')['elec_meters'][METER_ID.instance]