Exemple #1
0
#     plt.suptitle(file + '(' + meta[file[0:-4]]['appliance']['type'] + '-' +
#                  meta[file[0:-4]]['appliance']['status'] + ')')
#     plt.savefig('model/knowledge_model_temp/jpg/total/' + file[0:-4] + '.jpg',
#                 dpi=600)

#     plt.close()
#     print('dealing...:%03d/%03d' % (count, total_len))

for file, start_point in start_index.items():
    plt.figure(figsize=(8, 6))
    plt.cla()
    count += 1
    file_dir = source_dir + file
    Voltage, Current = read_source_data(file_dir,
                                        offset=start_point,
                                        length=length1)
    Stable_V, Stable_I = read_source_data(file_dir,
                                          offset=start_point + 3000,
                                          length=length2)
    tem = np.array(Current) - np.array(Stable_I)

    ax1 = plt.subplot(411)
    plt.plot(t1, Voltage)
    plt.grid(alpha=0.5, linestyle='-.')
    plt.title('Voltage')
    plt.xticks([])

    ax2 = plt.subplot(412)
    plt.plot(t1, Current)
    plt.grid(alpha=0.5, linestyle='-.')
Exemple #2
0
import sys
import os
import numpy as np
sys.path.append('data/')
from read_PLAID_data import read_source_data, read_index

source_dir = 'data/source/submetered_new_pured/source/'
type_index = read_index('type')
skip_list = type_index['Compact Fluorescent Lamp'] + type_index['Laptop']
csv_dir = os.listdir(source_dir)
record = {}
for file in csv_dir:
    if int(file[0:-4]) in skip_list:
        continue
    file_dir = source_dir + file
    Switch_V, Switch_I = read_source_data(file_dir, offset=0, length=1500)
    Total_V, Total_I = read_source_data(file_dir, offset=0)
    I_max = np.max(abs(Switch_I))
    # slide_arr = np.zeros(10)
    value0 = 0
    # Threshold = np.sum(slide_arr) / len(slide_arr)
    Threshold = 0.01256 * I_max
    # diff = 0
    slide_width = 10

    for i, value in enumerate(Total_I):
        if i == 0:
            value0 = value
            continue

        if abs(value - value0) > 10 * Threshold:
Exemple #3
0
from pyhht.visualization import plot_imfs

import matplotlib.pyplot as plt

sys.path.append('data/')
from read_PLAID_data import read_source_data

source_dir = 'data/source/submetered_new_pured/source/'

with open(
        '/home/chaofan/powerknowledge/data/source/metadata_submetered2.1.json',
        'r',
        encoding='utf8') as load_meta:
    meta = json.load(load_meta)

length1 = 3000
length2 = 3000
t = range(3000)
csv_dir = os.listdir(source_dir)
for file in csv_dir:
    file_dir = source_dir + file
    Switch_V, Switch_I = read_source_data(file_dir, offset=0, length=length1)
    Stable_V, Stable_I = read_source_data(file_dir,
                                          offset=3000,
                                          length=length2)
    tem = np.array(Switch_I) - np.array(Stable_I)

    decomposer = EMD(tem, n_imfs=3)
    imfs = decomposer.decompose()
    plot_imfs(tem, imfs, t)
Exemple #4
0
import os
sys.path.append('data/')
from read_PLAID_data import read_source_data, slider_plot

source_dir = 'data/source/submetered_new/'
file_list = os.listdir(source_dir)
# with open('model/find_result.txt', 'r') as f:
#     file_list = []
#     for line in f.readlines():
#         line = line.strip('\n')
#         line = line.split(':')
#         file = line[0][1:-1]
#         if '.csv' in file:
#             file_list.append(file)
file_dir = source_dir + '1.csv'
Switch_V, Switch_I = read_source_data(file_dir)
slider_plot(Switch_I)
# with open(
#         '/home/chaofan/powerknowledge/data/source/metadata_submetered2.1.json',
#         'r',
#         encoding='utf8') as load_meta:
#     meta = json.load(load_meta)
# count = 0

# for i, file in enumerate(file_list):
#     file_dir = source_dir + file
#     Switch_V, Switch_I = read_source_data(file_dir)
#     print(file + '(' + meta[file[0:-4]]['appliance']['type'] + '-' +
#           meta[file[0:-4]]['appliance']['status'] + ')')
#     slider_plot(Switch_I)