smartMeter

Posted -dragon-

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了smartMeter相关的知识,希望对你有一定的参考价值。

NILMTK的学习(所用数据集合REDD)

1相关API的理解

1.1 获取数据对象,convert and load data

redd = DataSet(‘/data/REDD/redd.h5’)

print redd.metadata#输出该数据集相关信息和实验环境

print redd.buildings#输出所有测试房间信息
OrderedDict([
(1, Building(instance=1, dataset=’REDD’)),
(2, Building(instance=2, dataset=’REDD’)),
(3, Building(instance=3, dataset=’REDD’)),
(4, Building(instance=4, dataset=’REDD’)),
(6, Building(instance=6, dataset=’REDD’))]

print redd.buildings[1].metadata
‘instance’: 1, ‘dataset’: ‘REDD’, ‘original_name’: ‘house_1’
输出如下信息:
MeterGroup(meters=
ElecMeter(instance=1, building=1, dataset=’REDD’, site_meter, appliances=[])
ElecMeter(instance=2, building=1, dataset=’REDD’, site_meter, appliances=[])
ElecMeter(instance=5, building=1, dataset=’REDD’, appliances=[Appliance(type=’fridge’, instance=1)])
ElecMeter(instance=6, building=1, dataset=’REDD’, appliances=[Appliance(type=’dish washer’, instance=1)])
ElecMeter(instance=7, building=1, dataset=’REDD’, appliances=[Appliance(type=’sockets’, instance=1)])
ElecMeter(instance=8, building=1, dataset=’REDD’, appliances=[Appliance(type=’sockets’, instance=2)])
ElecMeter(instance=9, building=1, dataset=’REDD’, appliances=[Appliance(type=’light’, instance=1)])
ElecMeter(instance=11, building=1, dataset=’REDD’, appliances=[Appliance(type=’microwave’, instance=1)])
ElecMeter(instance=12, building=1, dataset=’REDD’, appliances=[Appliance(type=’unknown’, instance=1)])
ElecMeter(instance=13, building=1, dataset=’REDD’, appliances=[Appliance(type=’electric space heater’, instance=1)])
ElecMeter(instance=14, building=1, dataset=’REDD’, appliances=[Appliance(type=’electric stove’, instance=1)])
ElecMeter(instance=15, building=1, dataset=’REDD’, appliances=[Appliance(type=’sockets’, instance=3)])
ElecMeter(instance=16, building=1, dataset=’REDD’, appliances=[Appliance(type=’sockets’, instance=4)])
ElecMeter(instance=17, building=1, dataset=’REDD’, appliances=[Appliance(type=’light’, instance=2)])
ElecMeter(instance=18, building=1, dataset=’REDD’, appliances=[Appliance(type=’light’, instance=3)])
ElecMeter(instance=19, building=1, dataset=’REDD’, appliances=[Appliance(type=’unknown’, instance=2)])
MeterGroup(meters=
ElecMeter(instance=3, building=1, dataset=’REDD’, appliances=[Appliance(type=’electric oven’, instance=1)])
ElecMeter(instance=4, building=1, dataset=’REDD’, appliances=[Appliance(type=’electric oven’, instance=1)])
)
MeterGroup(meters=
ElecMeter(instance=10, building=1, dataset=’REDD’, appliances=[Appliance(type=’washer dryer’, instance=1)])
ElecMeter(instance=20, building=1, dataset=’REDD’, appliances=[Appliance(type=’washer dryer’, instance=1)])
)


2 The Load API: Loading data into memory

2.1: 获取总表中的某一类用电器

fridge = elec['fridge']
print (fridge)

ElecMeter(instance=5, building=1, dataset=’REDD’, appliances=[Appliance(type=’fridge’, instance=1)])

2.2:显示可用的数据,在该数据集合中功率可用

print (fridge.available_columns())

[(‘power’, ‘active’)]

2.3:显示所选房间的所有数据

df = fridge.load().next()
print df

2.4:显示前面几组数据的详细信息

df = fridge.load().next()
print (df.head())

physical_quantity power
type active
2011-04-18 09:22:13-04:00 6
2011-04-18 09:22:16-04:00 6
2011-04-18 09:22:20-04:00 6
2011-04-18 09:22:23-04:00 6
2011-04-18 09:22:26-04:00 6


3 Meter selection and basic statistics

3.1 找到嵌套的电表
Note that there are two nested MeterGroups: one for the electric oven, and one for the washer dryer (both of which are 240 volt appliances and have two meters per appliance)

print (elec.nested_metergroups())

[MeterGroup(meters=
ElecMeter(instance=3, building=1, dataset=’REDD’, appliances=[Appliance(type=’electric oven’, instance=1)])
ElecMeter(instance=4, building=1, dataset=’REDD’, appliances=[Appliance(type=’electric oven’, instance=1)])
), MeterGroup(meters=
ElecMeter(instance=10, building=1, dataset=’REDD’, appliances=[Appliance(type=’washer dryer’, instance=1)])
ElecMeter(instance=20, building=1, dataset=’REDD’, appliances=[Appliance(type=’washer dryer’, instance=1)])
)]

3.2 找到主电表

print (elec.mains())

MeterGroup(meters=
ElecMeter(instance=1, building=1, dataset=’REDD’, site_meter, appliances=[])
ElecMeter(instance=2, building=1, dataset=’REDD’, site_meter, appliances=[])
)
3.3 得到两个主电表相加的数据和,这就是总的数据

print (elec.mains().power_series_all_data().head())

Loading data for meter ElecMeterID(instance=1, building=1, dataset=’REDD’)
Loading data for meter ElecMeterID(instance=2, building=1, dataset=’REDD’)
Done loading data all meters for this chunk.
2011-04-18 09:22:09-04:00 342.820007
2011-04-18 09:22:10-04:00 344.559998
2011-04-18 09:22:11-04:00 345.140015
2011-04-18 09:22:12-04:00 341.679993
2011-04-18 09:22:13-04:00 341.029999

3.4 显示数据中可用的数据类型

mains = elec.mains()
print (mains.available_power_ac_types())

3.5显示总用电量和单个电表的用电量

mains = elec.mains()
print (elec.mains().total_energy())
energy_per_meter = elec.submeters().energy_per_meter() # kWh, again
print (energy_per_meter)

3.6 找到用电总量大于20W的

energy_per_meter = elec.submeters().energy_per_meter()
energy_per_meter = energy_per_meter.loc['active']
more_than_20 = energy_per_meter[energy_per_meter > 20]
print (more_than_20)

(5, 1, REDD) 44.750925
(8, 1, REDD) 22.939649
(9, 1, REDD) 30.734511
(((10, 1, REDD), (20, 1, REDD)),) 32.614809
Name: active, dtype: float64

3.7 显示标签

print (more_than_20.index)

Index([ (5, 1, u’REDD’),
(8, 1, u’REDD’),
(9, 1, u’REDD’),
(((10, 1, u’REDD’), (20, 1, u’REDD’)),)],
dtype=’object’)


NOTE:the ElecMeter class represents a single electricity meter. Each ElecMeter has a list of associated Appliance objects. ElecMeter has many of the same stats methods as MeterGroup such as total_energy and available_power_ac_types and power_series and power_series_all_data. We will now explore some more stats functions (many of which are also available on MeterGroup)…


3.8 单个电表画图

fridge_meter = elec['fridge']
fridge_meter.plot()

3.9 全局选中所有房间的用电器

import nilmtk
print (nilmtk.global_meter_group.select_using_appliances(type='washer dryer'))

MeterGroup(meters=
ElecMeter(instance=10, building=1, dataset=’REDD’, appliances=[Appliance(type=’washer dryer’, instance=1)])
ElecMeter(instance=20, building=1, dataset=’REDD’, appliances=[Appliance(type=’washer dryer’, instance=1)])
ElecMeter(instance=7, building=2, dataset=’REDD’, appliances=[Appliance(type=’washer dryer’, instance=1)])
ElecMeter(instance=13, building=3, dataset=’REDD’, appliances=[Appliance(type=’washer dryer’, instance=1)])
ElecMeter(instance=14, building=3, dataset=’REDD’, appliances=[Appliance(type=’washer dryer’, instance=1)])
ElecMeter(instance=7, building=4, dataset=’REDD’, appliances=[Appliance(type=’washer dryer’, instance=1)])
ElecMeter(instance=8, building=5, dataset=’REDD’, appliances=[Appliance(type=’washer dryer’, instance=1)])
ElecMeter(instance=9, building=5, dataset=’REDD’, appliances=[Appliance(type=’washer dryer’, instance=1)])
ElecMeter(instance=4, building=6, dataset=’REDD’, appliances=[Appliance(type=’washer dryer’, instance=1)])

3.10 选中多个用电器

 print (elec.select_using_appliances(type=['fridge', 'microwave']))

MeterGroup(meters=
ElecMeter(instance=5, building=1, dataset=’REDD’, appliances=[Appliance(type=’fridge’, instance=1)])
ElecMeter(instance=11, building=1, dataset=’REDD’, appliances=[Appliance(type=’microwave’, instance=1)])
)
3.11 另一种选择方法

print (nilmtk.global_meter_group.select_using_appliances(category='heating'))

MeterGroup(meters=
ElecMeter(instance=13, building=1, dataset=’REDD’, appliances=[Appliance(type=’electric space heater’, instance=1)])
ElecMeter(instance=10, building=3, dataset=’REDD’, appliances=[Appliance(type=’electric furnace’, instance=1)])
ElecMeter(instance=4, building=4, dataset=’REDD’, appliances=[Appliance(type=’electric furnace’, instance=1)])
ElecMeter(instance=6, building=5, dataset=’REDD’, appliances=[Appliance(type=’electric furnace’, instance=1)])
ElecMeter(instance=12, building=5, dataset=’REDD’, appliances=[Appliance(type=’electric space heater’, instance=1)])
ElecMeter(instance=13, building=5, dataset=’REDD’, appliances=[Appliance(type=’electric space heater’, instance=1)])
ElecMeter(instance=12, building=6, dataset=’REDD’, appliances=[Appliance(type=’electric space heater’, instance=1)])
)
3.12 一种全局选中的方法

print (nilmtk.global_meter_group.select_using_appliances(building=1, category='single-phase induction motor'))

MeterGroup(meters=
ElecMeter(instance=5, building=1, dataset=’REDD’, appliances=[Appliance(type=’fridge’, instance=1)])
ElecMeter(instance=6, building=1, dataset=’REDD’, appliances=[Appliance(type=’dish washer’, instance=1)])
ElecMeter(instance=10, building=1, dataset=’REDD’, appliances=[Appliance(type=’washer dryer’, instance=1)])
ElecMeter(instance=20, building=1, dataset=’REDD’, appliances=[Appliance(type=’washer dryer’, instance=1)])

3.13 选中一个子表中的第二个

print (elec['light', 2])

ElecMeter(instance=17, building=1, dataset=’REDD’, appliances=[Appliance(type=’light’, instance=2)])

3.14 特殊选择

print (nilmtk.global_meter_group['dataset': 'REDD', 'building': 1, 'type': 'fridge', 'instance': 1])

ElecMeter(instance=5, building=1, dataset=’REDD’, appliances=[Appliance(type=’fridge’, instance=1)])

3.15 电表ID

from nilmtk.elecmeter import ElecMeterID 

nilmtk.global_meter_group[ElecMeterID(instance=8, building=1, dataset='REDD')]

ElecMeter(instance=8, building=1, dataset=’REDD’, appliances=[Appliance(type=’sockets’, instance=2)]

以上是关于smartMeter的主要内容,如果未能解决你的问题,请参考以下文章

组态王和modbusrtu协议的派诺三相电表通信,实时采集电表电量读数,寄存器地址该如何设置?说明参数如下

单相电表互感器三相电量采集modbus转mqtt上传开发需求说明

电力系统需求侧中 电表最大需量(MD,契约用电负荷)的概念与含义

智能电表的模块化和一体化

电脑读取RS485接口电表 软件

使用Redis和jackson操作json中遇到的坑