Skip to content

Commit

Permalink
Added min and max wheater scenario from SNCWV
Browse files Browse the repository at this point in the history
  • Loading branch information
eggimasv authored and eggimasv committed Mar 23, 2017
1 parent 09be1d4 commit 9f06e42
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 120 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"0": 0.004024644211114904, "1": 0.003961694616880597, "2": 0.003963805778884183, "3": 0.004028933626003296, "4": 0.004022499503670708, "5": 0.004018210088782318, "6": 0.004016065381338123, "7": 0.004013920673893926, "8": 0.003955361130869844, "9": 0.003961694616880597, "10": 0.004035367748335882, "11": 0.00405038070044525, "12": 0.004061104237666228, "13": 0.00406968306744301, "14": 0.004076117189775597, "15": 0.004018695990977385, "16": 0.004018695990977385, "17": 0.004080406604663988, "18": 0.004080406604663988, "19": 0.004073972482331401, "20": 0.0040675383599988145, "21": 0.004061104237666228, "22": 0.003993362046934368, "23": 0.003987028560923614, "24": 0.004046091285556859, "25": 0.004041801870668468, "26": 0.004037512455780078, "27": 0.004035367748335882, "28": 0.004035367748335882, "29": 0.003974361588902106, "30": 0.003974361588902106, "31": 0.004033223040891687, "32": 0.00403107833344749, "33": 0.004028933626003296, "34": 0.00403107833344749, "35": 0.004033223040891687, "36": 0.00397647275090569, "37": 0.003980695074912859, "38": 0.004046091285556859, "39": 0.004041801870668468, "40": 0.004033223040891687, "41": 0.004024644211114904, "42": 0.004009631259005535, "43": 0.003934249510833996, "44": 0.003921582538812487, "45": 0.003966737110121626, "46": 0.0039560135729006475, "47": 0.003951724158012256, "48": 0.003941000620791279, "49": 0.003928132376126106, "50": 0.003860358840708529, "51": 0.003847691868687021, "52": 0.0038830935197980013, "53": 0.003859501737911849, "54": 0.0038444887858024813, "55": 0.003827331126248918, "56": 0.0038080287592511582, "57": 0.003735800282497029, "58": 0.0037252444724791057, "59": 0.0037758581475882255, "60": 0.003767279317811444, "61": 0.003752266365702074, "62": 0.003737253413592705, "63": 0.003722240461483337, "64": 0.00364713147834647, "65": 0.0036239086963070375, "66": 0.0036578992381574725, "67": 0.0036364521637155165, "68": 0.0036128603818293657, "69": 0.003591413307387412, "70": 0.0035785450627222382, "71": 0.0035056836241062917, "72": 0.0034866831660740286, "73": 0.003531361498949937, "74": 0.003516348546840569, "75": 0.0035077697170637872, "76": 0.0035013355947311996, "77": 0.003492756764954418, "78": 0.003429681791977241, "79": 0.0034191259819593175, "80": 0.0034520073235147024, "81": 0.0034305602490727486, "82": 0.003402679052298206, "83": 0.003366219025746883, "84": 0.0033319037066397543, "85": 0.003252344183676122, "86": 0.0032248990776295203, "87": 0.003252549531204521, "88": 0.00322895774931837, "89": 0.00320965538232061, "90": 0.003188208307878656, "91": 0.003171050648325092, "92": 0.003115118653443113, "93": 0.003106674005428775, "94": 0.0031431694515505495, "95": 0.0031281564994411815, "96": 0.003108854132443421, "97": 0.003085262350557271, "98": 0.003057381153782729, "99": 0.002988448933228029, "100": 0.0029673373131921814, "101": 0.00299518463790106, "102": 0.0029715928560149086, "103": 0.0029437116592403675, "104": 0.0029072516326890435, "105": 0.0028707916061377205, "106": 0.0027857773808838927, "107": 0.0027477764648193674, "108": 0.002761411526483749, "109": 0.0027378197445975983, "110": 0.002714227962711448, "111": 0.002688491473381102, "112": 0.002658465569162365, "113": 0.0025831058285397572, "114": 0.0025577718844967405, "115": 0.00257482197883874, "116": 0.0025640984416177622, "117": 0.0025555196118409802, "118": 0.0025405066597316115, "119": 0.002523349000178047, "120": 0.002462769594335427, "121": 0.00243743565029241, "122": 0.0024525736545195956, "123": 0.0024354159949660312, "124": 0.0024139689205240765, "125": 0.002390377138637926, "126": 0.002366785356751776, "127": 0.0023023212820629862, "128": 0.0022748761760163845, "129": 0.0022895758887607367, "130": 0.002270273521762977, "131": 0.0022488264473210224, "132": 0.002229524080323263, "133": 0.0022123664207696985, "134": 0.0021587622658192232, "135": 0.002139761807786961, "136": 0.0021544593197764202, "137": 0.0021351569527786607, "138": 0.0021115651708925095, "139": 0.0020858286815621636, "140": 0.0020579474847876216, "141": 0.0020004251155503676, "142": 0.001977202333510935, "143": 0.0019893168465733653, "144": 0.0019785933093523877, "145": 0.001972159187019801, "146": 0.001965725064687215, "147": 0.001955001527466238, "148": 0.001911756311399808, "149": 0.001896978177374715, "150": 0.0019121073785823277, "151": 0.0018928050115845677, "152": 0.0018777920594751992, "153": 0.0018649238148100258, "154": 0.0018563449850332442, "155": 0.0018146428592349096, "156": 0.0018083093732241555, "157": 0.001834897910591289, "158": 0.0018284637882587025, "159": 0.0018198849584819205, "160": 0.001813450836149334, "161": 0.0018005825914841607, "162": 0.001755530323134537, "163": 0.0017407521891094433, "164": 0.001755543735156055, "165": 0.0017405307830466864, "166": 0.0017298072458257093, "167": 0.0017212284160489264, "168": 0.0017147942937163403, "169": 0.0016837508150126554, "170": 0.0016774173290019007, "171": 0.0016954919267185811, "172": 0.0016890578043859948, "173": 0.0016804789746092121, "174": 0.0016719001448324306, "175": 0.001667610729944039, "176": 0.0016394164129373758, "177": 0.0016373052509337906, "178": 0.0016590319001672574, "179": 0.0016568871927230616, "180": 0.0016547424852788664, "181": 0.0016483083629462796, "182": 0.0016440189480578886, "183": 0.0016119713068907743, "184": 0.0016077489828836046, "185": 0.0016290059959485205, "186": 0.0016247165810601293, "187": 0.0016204271661717383, "188": 0.0016182824587275422, "189": 0.001616137751283347, "190": 0.0015908596868549267, "191": 0.0015887485248513417, "192": 0.0016139930438391513, "193": 0.0016097036289507603, "194": 0.0016097036289507603, "195": 0.0016075589215065649, "196": 0.001605414214062369, "197": 0.0015781927148334181, "198": 0.0015760815528298336, "199": 0.0016011247991739787, "200": 0.0015989800917297827, "201": 0.0015968353842855873, "202": 0.001592545969397196, "203": 0.001592545969397196, "204": 0.0015655257428119093, "205": 0.0015634145808083246, "206": 0.00158611184706461, "207": 0.00158611184706461, "208": 0.00158611184706461, "209": 0.0015839671396204145, "210": 0.0015839671396204145, "211": 0.0015570810947975705, "212": 0.0015570810947975705, "213": 0.001581822432176219, "214": 0.001581822432176219, "215": 0.0015796777247320236, "216": 0.0015796777247320236, "217": 0.0015796777247320236, "218": 0.001554969932793986, "219": 0.001554969932793986, "220": 0.001581822432176219, "221": 0.0015839671396204145, "222": 0.0015839671396204145, "223": 0.0015839671396204145, "224": 0.0015839671396204145, "225": 0.0015591922568011555, "226": 0.0015591922568011555, "227": 0.00158611184706461, "228": 0.001590401261953001, "229": 0.001594690676841392, "230": 0.0015989800917297827, "231": 0.0016011247991739787, "232": 0.0015803038768370024, "233": 0.0015803038768370024, "234": 0.0016075589215065649, "235": 0.0016097036289507603, "236": 0.0016139930438391513, "237": 0.0016182824587275422, "238": 0.0016225718736159335, "239": 0.00160141549687285, "240": 0.0016077489828836046, "241": 0.0016397295331694976, "242": 0.0016461636555020838, "243": 0.0016525977778346708, "244": 0.0016590319001672574, "245": 0.0016633213150556477, "246": 0.001643638736944545, "247": 0.0016478610609517148, "248": 0.0016783342671650167, "249": 0.0016847683894976031, "250": 0.001693347219274385, "251": 0.001699781341606972, "252": 0.0017083601713837539, "253": 0.001692195463026994, "254": 0.0017027512730449185, "255": 0.0017383860756024908, "256": 0.0017512543202676638, "257": 0.001766267272377033, "258": 0.0017791355170422055, "259": 0.00179629317659577, "260": 0.0017829754291811381, "261": 0.0017977535632062312, "262": 0.0018413320329238754, "263": 0.0018563449850332442, "264": 0.0018692132296984176, "265": 0.001884226181807786, "266": 0.0019013838413613497, "267": 0.001886422367356791, "268": 0.0019075339873926387, "269": 0.0019592909423546286, "270": 0.001985027431684975, "271": 0.0020129086284595165, "272": 0.0020450792401224493, "273": 0.002077249851785381, "274": 0.0021330122453344647, "275": 0.002122872511758283, "276": 0.002146095293797715, "277": 0.0022059322984371126, "278": 0.0022338134952116537, "279": 0.002263839399430391, "280": 0.0022938653036491275, "281": 0.00232174650042367, "282": 0.00231287709208091, "283": 0.0023403221981275115, "284": 0.0024053900907472945, "285": 0.0024397054098544224, "286": 0.002474020728961551, "287": 0.0025083360480686783, "288": 0.0025405066597316115, "289": 0.0025282156164465543, "290": 0.0025535495604895706, "291": 0.0026198608351668453, "292": 0.0026391632021646053, "293": 0.0026606102766065605, "294": 0.002686346765936906, "295": 0.0027077938403788616, "296": 0.00268655276671541, "297": 0.0027139978727620116, "298": 0.0027850033083699, "299": 0.002817173920032832, "300": 0.0028536339465841565, "301": 0.002887949265691285, "302": 0.0029222645847984123, "303": 0.002912447101098978, "304": 0.0029462256931563338, "305": 0.0030209211272314057, "306": 0.0030530917388943385, "307": 0.0030831176431130756, "308": 0.0031174329622202035, "309": 0.003151748281327332, "310": 0.003138341435482546, "311": 0.003172120027539902, "312": 0.003252549531204521, "313": 0.003276141313090671, "314": 0.003297588387532627, "315": 0.0033190354619745815, "316": 0.0033426272438607314, "317": 0.0033177902057872494, "318": 0.003347346473837436, "319": 0.0034284155416285525, "320": 0.0034541520309588985, "321": 0.0034755991054008536, "322": 0.003492756764954418, "323": 0.0035013355947311996, "324": 0.0034550157360202574, "325": 0.003465571546038182, "326": 0.0035292167915057415, "327": 0.0035356509138383284, "328": 0.0035506638659476963, "329": 0.0035678215255012602, "330": 0.003584979185054825, "331": 0.0035500180261815715, "332": 0.0035795742942317577, "333": 0.003664333360490059, "334": 0.0036900698498204053, "335": 0.0037072275093739692, "336": 0.0037243851689275327, "337": 0.003737253413592705, "338": 0.0036935770424253345, "339": 0.0037062440144468426, "340": 0.003786581684809203, "341": 0.0038058840518069618, "342": 0.0038166075890279398, "343": 0.003827331126248918, "344": 0.0038359099560256998, "345": 0.003780134684572309, "346": 0.0037885793325866477, "347": 0.0038616464453560453, "348": 0.0038723699825770224, "349": 0.0038788041049096084, "350": 0.003895961764463173, "351": 0.003913119424016738, "352": 0.0038666923267192833, "353": 0.003875136974733622, "354": 0.003953868865456452, "355": 0.003966737110121626, "356": 0.003979605354786799, "357": 0.00398818418456358, "358": 0.004003197136672949, "359": 0.003946916482855505, "360": 0.003953249968866258, "361": 0.004020354796226514, "362": 0.004020354796226514, "363": 0.004020354796226514, "364": 0.004024644211114904}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5.265526702501632e-05

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"0": 0.005488474199999999, "1": 0.005488474199999999, "2": 0.005488474199999999, "3": 0.005488474199999999, "4": 0.00658616905, "5": 0.02195389682, "6": 0.046103183320000005, "7": 0.06586169045, "8": 0.09659714599000001, "9": 0.03293084523, "10": 0.05049396268, "11": 0.054884742040000004, "12": 0.04171240395, "13": 0.04390779363, "14": 0.046103183320000005, "15": 0.05159165752, "16": 0.04720087816, "17": 0.0724478595, "18": 0.07464324918, "19": 0.07135016464999999, "20": 0.06476399561, "21": 0.054884742040000004, "22": 0.02195389682, "23": 0.01207464325}
135 changes: 60 additions & 75 deletions energy_demand/data_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,90 +5,97 @@
import unittest
from datetime import date
import matplotlib.pyplot as plt
import data_loader_functions as df
import energy_demand.data_loader_functions as df
import numpy as np
import main_functions as mf
# pylint: disable=I0011,C0321,C0301,C0103, C0325

def generate_data(data, run_data_collection):
"""This function loads all that which does not neet to be run every time"""
base_year_load_data = 2015

run_data_collection = False #Scrap
if run_data_collection is False:
# TODO
# Read in individual CSV files of load shapes
#run_data_collection = False #Scrap
# ---------------------------------------------------
# All pre-processed load shapes are read in from .txt files
# ---------------------------------------------------
def collect_shapes_from_txts(data):

# Iterate folders and get all enduse
path_txt = data['path_dict']['path_write_out_shape_txts']
all_csv_in_folder = os.listdir(path_txt)
# ----------------------------------------------------------------------
# RESIDENTIAL MODEL .txt files
# ----------------------------------------------------------------------
# Iterate folders and get all enduse
path_txt_shapes = data['path_dict']['path_txt_shapes_resid']
all_csv_in_folder = os.listdir(path_txt_shapes)

# Read all enduese from files
enduses = []
for file_name in all_csv_in_folder:
enduse = file_name.split("_")[0]
if enduse not in enduses:
enduses.append(enduse)

# Read shapes from txt files
for end_use in enduses:
shape_h_peak = df.read_txt_shape_h_peak(os.path.join(path_txt_shapes, str(end_use) + str("__") + str('shape_h_peak') + str('.txt')))
shape_h_non_peak = df.read_txt_shape_h_non_peak(os.path.join(path_txt_shapes, str(end_use) + str("__") + str('shape_h_non_peak') + str('.txt')))
shape_d_peak = df.read_txt_shape_d_peak(os.path.join(path_txt_shapes, str(end_use) + str("__") + str('shape_d_peak') + str('.txt')))
shape_d_non_peak = df.read_txt_shape_d_non_peak(os.path.join(path_txt_shapes, str(end_use) + str("__") + str('shape_d_non_peak') + str('.txt')))
data['dict_shp_enduse_h_resid'][end_use] = {'shape_h_peak': shape_h_peak, 'shape_h_non_peak': shape_h_non_peak}
data['dict_shp_enduse_d_resid'][end_use] = {'shape_d_peak': shape_d_peak, 'shape_d_non_peak': shape_d_non_peak}

enduses = []
# ----------------------------------------------------------------------
# SERVICE MODEL .txt files
# ----------------------------------------------------------------------

# Read all enduese from files
for file_name in all_csv_in_folder:
enduse = file_name.split("_")[0]
if enduse not in enduses:
enduses.append(enduse)

# get all enduses
for end_use in enduses:
# ----------------------------------------------------------------------
# Industry MODEL .txt files
# ----------------------------------------------------------------------

# Read shapes from txt files
shape_h_peak = df.read_txt_shape_h_peak(os.path.join(path_txt, str(end_use) + str("__") + str('shape_h_peak') + str('.txt')))
shape_h_non_peak = df.read_txt_shape_h_non_peak(os.path.join(path_txt, str(end_use) + str("__") + str('shape_h_non_peak') + str('.txt')))
shape_d_peak = df.read_txt_shape_d_peak(os.path.join(path_txt, str(end_use) + str("__") + str('shape_d_peak') + str('.txt')))
shape_d_non_peak = df.read_txt_shape_d_non_peak(os.path.join(path_txt, str(end_use) + str("__") + str('shape_d_non_peak') + str('.txt')))
return data

data['dict_shp_enduse_h_resid'][end_use] = {'shape_h_peak': shape_h_peak, 'shape_h_non_peak': shape_h_non_peak}
data['dict_shp_enduse_d_resid'][end_use] = {'shape_d_peak': shape_d_peak, 'shape_d_non_peak': shape_d_non_peak}

return data
def generate_data(data):
"""This function loads all that which does not neet to be run every time"""

# ----------------------------------------------------------------------
# RESIDENTIAL MODEL
# ----------------------------------------------------------------------
base_year_load_data = 2015

# --HES data
# ===========================================-
# RESIDENTIAL MODEL
# ===========================================
path_txt_shapes = data['path_dict']['path_txt_shapes_resid']

# Generate generic load profiles (shapes) for all electricity appliances from HES data [ % ]
# HES data -- Generate generic load profiles (shapes) for all electricity appliances from HES data [ % ]
hes_data, hes_y_peak, _ = df.read_hes_data(data)
year_raw_values_hes = df.assign_hes_data_to_year(data, hes_data, base_year_load_data)

# Load shape for all end_uses
for end_use in data['data_residential_by_fuel_end_uses']:
#print("ENDUSE: " + str(i))
#end_use = i # End use read from avaialble fuels...
data, shape_h_peak, shape_h_non_peak, shape_d_peak, shape_d_non_peak = df.get_hes_end_uses_shape(data, hes_data, year_raw_values_hes, hes_y_peak, _, end_use)
df.create_txt_shapes(end_use, path_txt_shapes, shape_h_peak, shape_h_non_peak, shape_d_peak, shape_d_non_peak) # Write shapes to txt

# Dump to txt files
path_txt = data['path_dict']['path_write_out_shape_txts']
#print(shape_h_peak.shape) # 24
#print(shape_h_non_peak.shape) # 365, 24
#print(shape_d_peak.shape) # ()
#print(shape_d_non_peak.shape) # 365, 1
df.jason_to_txt_shape_h_peak(shape_h_peak, os.path.join(path_txt, str(end_use) + str("__") + str('shape_h_peak') + str('.txt')))
df.jason_to_txt_shape_h_non_peak(shape_h_non_peak, os.path.join(path_txt, str(end_use) + str("__") + str('shape_h_non_peak') + str('.txt')))
df.jason_to_txt_shape_d_peak(shape_d_peak, os.path.join(path_txt, str(end_use) + str("__") + str('shape_d_peak') + str('.txt')))
df.jason_to_txt_shape_d_non_peak(shape_d_non_peak, os.path.join(path_txt, str(end_use) + str("__") + str('shape_d_non_peak') + str('.txt')))
# Robert Sansom, Yearly peak from CSWV - Residential Gas demand, Daily shapes
shape_h_peak, shape_h_non_peak, shape_d_peak, shape_d_non_peak = df.read_shp_heating_gas(data, 'residential', 'actual') # Composite Wheater Variable for residential gas heating
df.create_txt_shapes('heating', path_txt_shapes, shape_h_peak, shape_h_non_peak, shape_d_peak, shape_d_non_peak) # Write shapes to txt






# ===========================================
# SERVICE MODEL DATA GENERATION
# ===========================================

# ----------------------------
# Residential Gas demand ()
# Daily shapes taken from Robert Sansom
# Yearly peak from CSWV
# Service Gas demand, Daily shapes taken from Robert Sansom, Yearly peak from CSWV
# ----------------------------
# CSV Residential
data = df.read_shp_heating_gas(data, 'heating', 'dict_shp_enduse_h_resid', 'dict_shp_enduse_d_resid', 'path_temp_2015')

#CSV Service
#data = df.read_shp_heating_gas(data, 'heating', 'dict_shp_enduse_h_service', 'dict_shp_enduse_d_service', 'path_temp_2015_service')


# ---------------------
# Load Carbon Trust data
# - electricity for non-residential
# -
# ---------------------

# ENDUSE XY
folder_path = r'C:\Users\cenv0553\Dropbox\00-Office_oxford\07-Data\09_Carbon_Trust_advanced_metering_trial_(owen)\__OWN_SEWAGE' #Community _OWN_SEWAGE
out_dict_av, out_dict_not_av, hourly_shape_of_maximum_days = df.read_raw_carbon_trust_data(data, folder_path)
Expand All @@ -99,33 +106,11 @@ def generate_data(data, run_data_collection):
enduse = 'WHATEVERENDUSE'
year_data = df.assign_carbon_trust_data_to_year(data, enduse, out_dict_av, base_year_load_data)

'''import matplotlib.pyplot as plt
import numpy as np
x_values = range(365 * 24)
y_values = []
#y_values = all_hours_year[region].values()
for day, daily_values in enumerate(year_data):
# ONLY PLOT HALF A YEAR
if day < 365:
for hour in daily_values:
y_values.append(hour)
plt.plot(x_values, y_values)
plt.legend()
plt.show()
print("")
'''
#out_dict_av [daytype, month, ...] ---> Calculate yearly profile with averaged monthly profiles

# ENDUSE XY
folder_path = r'C:\Users\cenv0553\Dropbox\00-Office_oxford\07-Data\09_Carbon_Trust_advanced_metering_trial_(owen)\__OWN_SEWAGE' #Community _OWN_SEWAGE

#folder_path = r'C:\Users\cenv0553\Dropbox\00-Office_oxford\07-Data\09_Carbon_Trust_advanced_metering_trial_(owen)\__OWN_SEWAGE' #Community _OWN_SEWAGE

# ADD DICTS TO data


return data

0 comments on commit 9f06e42

Please sign in to comment.