Example #1
0
def query():
    data = json.loads(request.data)
    home_number = data["home_number"]
    start_timestamp = data['start'] * 1000
    end_timestamp = data['end'] * 1000

    # Creating a SMAP interface
    smap = SMAP(SMAP_URL)
    uuid = smap.find_uuid(home_number)
    smap_readings = smap.get_readings(uuid, start_timestamp, end_timestamp)

    df = to_pd_series(smap_readings)

    # Downsample
    df = df.resample('1T').dropna()

    # Creating nilmtk building
    b = Building()
    # Attaching mains
    b.utility.electric.mains[MainsName(1, 1)] = df
    # Instantiating CO disaggregator
    disaggregator = CO_1d()
    # Loading model
    path_to_file = os.path.join(MODEL_PATH, home_number + ".json")
    disaggregator.import_model(path_to_file)
    # Perform disaggregation
    disaggregator.disaggregate(b)
    predictions = disaggregator.predictions
    return pd_to_higcharts(predictions)
Example #2
0
def query_raw():
    data = json.loads(request.data)
    home_number = data["home_number"]
    start_timestamp = data['start'] * 1000
    end_timestamp = data['end'] * 1000

    # Creating a SMAP interface
    smap = SMAP(SMAP_URL)
    uuid = smap.find_uuid(home_number)
    smap_readings = smap.get_readings(uuid, start_timestamp, end_timestamp)

    df = to_pd_series(smap_readings)

    # Downsample
    df = df.resample('1T').dropna()
    df.rename(columns={"poweractive": "total"})
    return pd_to_higcharts(df)
from iiit_disagg.smap_interface import SMAP
from iiit_disagg.smap_interface import to_pd_series
from nilmtk.building import Building
from nilmtk.sensors.electricity import MainsName, Measurement
from nilmtk.disaggregate.co_1d import CO_1d

FLAT_NUMBER = '101'
START = 1387996200000
END = 1388341800000
DISAGG_FEATURE = Measurement('power', 'active')

# Making SMAP connection
smap = SMAP("http://nms.iiitd.edu.in:9102/")

# Get UUID
UUID = smap.find_uuid(FLAT_NUMBER)

# Getting data for UUID
smap_readings = smap.get_readings(UUID, START, END)

# Transform to NILMTK Mains
df = to_pd_series(smap_readings)

# Downsample
df = df.resample('1T')

# Creating nilmtk building
b = Building()

# Attaching mains
b.utility.electric.mains[MainsName(1, 1)] = df