def get_test_data(num_houses): devices_types_unsampled={} ids_for_devices={} db_url='postgresql://*****:*****@db.wiki-energy.org:5432/postgres' psda.set_url(db_url) schema = 'shared' tables= psda.get_table_names(schema) print tables table=tables[3] ids_device_name='air1' ids_for_devices[ids_device_name]=psda.get_dataids_with_real_values(schema,table,ids_device_name) device_name='air1' devices_types_unsampled[device_name]=psda.generate_type_for_appliance_by_dataids(schema,table,device_name,ids_for_devices[ids_device_name][:num_houses]) device_name='use' devices_types_unsampled[device_name]=psda.generate_type_for_appliance_by_dataids(schema,table,device_name,ids_for_devices[ids_device_name][:num_houses]) #Resamples the data devices_types={} devices_types_unsplit={} sample_rate='1T' length='D' for key in devices_types_unsampled: devices_types_unsplit[key]=devices_types_unsampled[key].resample(sample_rate) #devices_types[key]=devices_types_unsplit[key].split_by(length) devices_types[key]=devices_types_unsplit[key] print "Resampled " + str(key) return devices_types
def get_type_from_dataset(device_name,schema,table_num,limit=0): ''' Given the device name ''' devices_types={} devices_types_unsampled={} db_url='postgresql://*****:*****@db.wiki-energy.org:5432/postgres' psda.set_url(db_url) table='group1_disaggregated_2013_0'+str(table_num) ids_for_device=psda.get_dataids_with_real_values(schema,table,device_name) if(limit>len(ids_for_device) or limit==0): limit=len(ids_for_device) device_type_orig=psda.generate_type_for_appliance_by_dataids(schema, table,device_name,ids_for_device[:limit]) return device_type_orig
def get_type_from_dataset(device_name, table_num, limit=0): """ Given the device name """ devices_types = {} devices_types_unsampled = {} db_url = "postgresql://*****:*****@db.wiki-energy.org:5432/postgres" psda.set_url(db_url) schema = "shared" table = "validated_0" + str(table_num) + "_2014" ids_for_device = psda.get_dataids_with_real_values(schema, table, device_name) if limit > len(ids_for_device) or limit == 0: limit = len(ids_for_device) device_type_orig = psda.generate_type_for_appliance_by_dataids(schema, table, device_name, ids_for_device[:limit]) return device_type_orig
def get_type_from_dataset(device_name, schema, table_num, limit=0): ''' Given the device name ''' devices_types = {} devices_types_unsampled = {} db_url = 'postgresql://*****:*****@db.wiki-energy.org:5432/postgres' psda.set_url(db_url) table = 'group1_disaggregated_2013_0' + str(table_num) ids_for_device = psda.get_dataids_with_real_values(schema, table, device_name) if (limit > len(ids_for_device) or limit == 0): limit = len(ids_for_device) device_type_orig = psda.generate_type_for_appliance_by_dataids( schema, table, device_name, ids_for_device[:limit]) return device_type_orig
def get_test_data(num_houses): devices_types_unsampled = {} ids_for_devices = {} db_url = 'postgresql://*****:*****@db.wiki-energy.org:5432/postgres' psda.set_url(db_url) schema = 'shared' tables = psda.get_table_names(schema) print tables table = tables[3] ids_device_name = 'air1' ids_for_devices[ids_device_name] = psda.get_dataids_with_real_values( schema, table, ids_device_name) device_name = 'air1' devices_types_unsampled[ device_name] = psda.generate_type_for_appliance_by_dataids( schema, table, device_name, ids_for_devices[ids_device_name][:num_houses]) device_name = 'use' devices_types_unsampled[ device_name] = psda.generate_type_for_appliance_by_dataids( schema, table, device_name, ids_for_devices[ids_device_name][:num_houses]) #Resamples the data devices_types = {} devices_types_unsplit = {} sample_rate = '1T' length = 'D' for key in devices_types_unsampled: devices_types_unsplit[key] = devices_types_unsampled[key].resample( sample_rate) #devices_types[key]=devices_types_unsplit[key].split_by(length) devices_types[key] = devices_types_unsplit[key] print "Resampled " + str(key) return devices_types
parser = argparse.ArgumentParser(description='create appliance detection datasets for pylearn2.') parser.add_argument('data_dir',type=str, help='directory in which to store data') parser.add_argument('prefix',type=str, help='prefix for dataset files') args = parser.parse_args() schema = 'shared' tables = [u'validated_01_2014', u'validated_02_2014', u'validated_03_2014', u'validated_04_2014', u'validated_05_2014',] db_url = "postgresql://*****:*****@db.wiki-energy.org:5432/postgres" psda.set_url(db_url) window_length = 10 window_stride = 1 prediction_index = 6 all_ids = [] for month in range(5): air1_ids = psda.get_dataids_with_real_values(schema,tables[month],'air1') furnace1_ids = psda.get_dataids_with_real_values(schema,tables[month],'furnace1') all_ids.append(air1_ids) all_ids.append(furnace1_ids) common_ids = da.utils.get_common_ids(all_ids) n = len(common_ids) n_train = n/2
type=str, help='directory in which to store data') parser.add_argument('prefix', type=str, help='prefix for dataset files') args = parser.parse_args() schema = 'shared' tables = [ u'validated_01_2014', u'validated_02_2014', u'validated_03_2014', u'validated_04_2014', u'validated_05_2014', ] db_url = "postgresql:/USERNAME:[email protected]:5432/postgres" psda.set_url(db_url) window_length = 10 window_stride = 1 prediction_index = 6 all_ids = [] for month in range(5): air1_ids = psda.get_dataids_with_real_values(schema, tables[month], 'air1') furnace1_ids = psda.get_dataids_with_real_values( schema, tables[month], 'furnace1') all_ids.append(air1_ids) all_ids.append(furnace1_ids) common_ids = da.utils.get_common_ids(all_ids)
def setUp(self): psda.set_url(settings.PECAN_STREET_DB_URL)
import sys sys.path.append('../') #print sys.path ''' An interface for adapting Pecan Street data. ''' import disaggregator.PecanStreetDatasetAdapter as pecan import pickle import disaggregator.utils as utils # Open db connection db_url = "postgresql://*****:*****@db.wiki-energy.org:5432/postgres" pecan.set_url(db_url) schema_names = { 'curated': '\"PecanStreet_CuratedSets\"', 'raw': '\"PecanStreet_RawData\"', 'shared': '\"PecanStreet_SharedData\"' } print '''There are two datasets you can view right now, one is called curated, and one is called shared. The shared data set has one minute interval data for Jan-May 2014, for about 200 homes. The curated data set has 15 minute interval data for 2013 and 2012 (the largest interval lasts from 12/12-11/13. If you want to analyze longer term data, the curated set is recommended,
#print sys.path ''' An interface for adapting Pecan Street data. ''' import disaggregator.PecanStreetDatasetAdapter as pecan import pickle import disaggregator.utils as utils # Open db connection db_url = "postgresql://*****:*****@db.wiki-energy.org:5432/postgres" pecan.set_url(db_url) schema_names = {'curated':'\"PecanStreet_CuratedSets\"', 'raw':'\"PecanStreet_RawData\"', 'shared':'\"PecanStreet_SharedData\"'} print '''There are two datasets you can view right now, one is called curated, and one is called shared. The shared data set has one minute interval data for Jan-May 2014, for about 200 homes. The curated data set has 15 minute interval data for 2013 and 2012 (the largest interval lasts from 12/12-11/13. If you want to analyze longer term data, the curated set is recommended, whereas if you want shorter but more frequent data the shared set is recommended.