Skip to content

Instantly share code, notes, and snippets.

View nipunbatra's full-sized avatar

Nipun Batra nipunbatra

View GitHub Profile
In [60]: sql = "select timestamp, value from data where probe='edu.mit.media.funf.probe.builtin.WifiProbe'"
In [61]: df = psql.frame_query(sql, con)
In [62]: df.index = pd.to_datetime(df.timestamp, unit='s')
In [63]: df = df.drop("timestamp", 1)
In [65]: ser = df.value.apply(json.loads)
In [67]: ser.values[0]
Out[67]:
{u'BSSID': u'80:a1:d7:bb:e5:0c',
u'SSID': u'NoNetworkFound',
u'capabilities': u'[WEP][ESS]',
In [74]: sql = "select timestamp, value from data where probe='edu.mit.media.funf.probe.builtin.AudioFeaturesProbe'"
In [75]: df = psql.frame_query(sql, con)
In [76]: df.index = pd.to_datetime(df.timestamp, unit='s')
In [77]: df = df.drop("timestamp", 1)
In [79]: ser = df.value.apply(json.loads)
In [82]: ser.values[0]
Out[82]:
{u'diffSecs': 1.0540001392364502,
u'l1Norm': 68.381625,
u'l2Norm': 110.89188822903144,
In [112]: sql = "select timestamp, value from data where probe='edu.mit.media.funf.probe.builtin.BatteryProbe'"
In [113]: df = psql.frame_query(sql, con)
In [114]: df.index = pd.to_datetime(df.timestamp, unit='s')
In [115]: df = df.drop("timestamp", 1)
In [117]: ser = df.value.apply(json.loads)
In [120]: ser.values[0]
Out[120]:
{u'health': 2,
u'icon-small': 17303134,
u'invalid_charger': 0,
In [147]: ser.values[0]
Out[147]: {u'accuracy': 0, u'lux': 90.0, u'timestamp': 1369176076.891088}
In [148]: ser.values
Out[148]:
array([{u'lux': 90.0, u'timestamp': 1369176076.891088, u'accuracy': 0},
{u'lux': 90.0, u'timestamp': 1369176076.891088, u'accuracy': 0},
{u'lux': 90.0, u'timestamp': 1369176076.891088, u'accuracy': 0},
...,
{u'lux': 40.0, u'timestamp': 1372336580.332052, u'accuracy': 0},
In [1]: import pandas as pd
In [2]: df1=pd.read_csv("1.csv", index_col=1, parse_dates=True)
In [3]: df2=pd.read_csv("2.csv", index_col=1, parse_dates=True)
In [4]: df1.head(5)
Out[4]:
id temp pir reed
timestamp
2012-01-16 16:46:28 0 23.25 1 0
2012-01-16 16:46:29 1 23.10 1 0
2012-01-16 16:46:30 2 23.20 0 0
from nilmtk.plots import latexify, format_axes
import matplotlib.pyplot as plt
import pandas as pd
df_idx=pd.date_range(start="2014-01-01", freq="D", periods=7)
normal = pd.Series([75,83,75,79,49,74,83],index=df_idx)
off_peak = pd.Series([53,50,48,56,44,42,58],index=df_idx)
peak = pd.Series([43,42,44,34,28,47,41],index=df_idx)
df = pd.DataFrame({'peak':peak,'normal':normal,'off peak':off_peak}, index=df_idx)
from mpltools import style
style.use('ggplot')
import nilmtk.preprocessing.electricity.building as prepb
import nilmtk.preprocessing.electricity.single as prep
from nilmtk.stats.electricity.building import plot_missing_samples_using_bitmap
from nilmtk.sensors.electricity import Measurement
PATH = "/home/nipun/Dropbox/nilmtk_datasets/iawe"
from nilmtk.dataset import DataSet
import brewer2mpl
set3 = brewer2mpl.get_map('Set3', 'qualitative', 12).mpl_colors
import matplotlib.pyplot as plt
from pymodbus.constants import Endian
from struct import pack, unpack
from pymodbus.constants import Endian
from pymodbus.utilities import pack_bitstring
from pymodbus.utilities import unpack_bitstring
from pymodbus.exceptions import ParameterException
from pymodbus.client.sync import ModbusSerialClient as ModbusClient
from pymodbus.transaction import ModbusSocketFramer as ModbusFramer
import datetime
import time
id a1 b1 c1 a2 b2 c2
1 2 2 2 2 2 2
2 3 4 2 2 2 2
\usepackage[hidelinks]{hyperref}
\usepackage{comment}
\usepackage{array}
\usepackage{url}
\usepackage{listings}
\usepackage{algorithm}
\usepackage{algorithmic}
\usepackage{rotating}
\newcommand{\redcolor}[1]{\textcolor{red}{#1}}
\newcommand{\bluecolor}[1]{\textcolor{blue}{#1}}