Skip to content

Commit

Permalink
switch fuel implementing
Browse files Browse the repository at this point in the history
  • Loading branch information
eggimasv authored and eggimasv committed Mar 13, 2017
1 parent 2fb5387 commit 3e25f00
Show file tree
Hide file tree
Showing 4 changed files with 292 additions and 51 deletions.
140 changes: 137 additions & 3 deletions energy_demand/assumptions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
""" This file contains all assumptions of the energy demand model"""
# pylint: disable=I0011,C0321,C0301,C0103, C0325
import numpy as np

def load_assumptions(data):
"""All assumptions
Expand All @@ -15,11 +16,9 @@ def load_assumptions(data):
"""
assump_dict = {}


# Load assumptions from csv files
dwtype_floorarea = data['dwtype_floorarea']


# ============================================================
# Assumptions Technological Stock
# ============================================================
Expand Down Expand Up @@ -58,7 +57,141 @@ def load_assumptions(data):
}

# Share of fuel types (base year could also be calculated and loaded)
fuel_type_p_by = {
fuel_type_p_by = {'light': {
'0' : 0.0182,
'1' : 0.7633,
'2' : 0.0791,
'3' : 0.0811,
'4' : 0.0,
'5' : 0.0581,
'6' : 0.0
},
'cold': {
'0' : 0.0182,
'1' : 0.7633,
'2' : 0.0791,
'3' : 0.0811,
'4' : 0.0,
'5' : 0.0581,
'6' : 0.0
},
'wet': {
'0' : 0.0182,
'1' : 0.7633,
'2' : 0.0791,
'3' : 0.0811,
'4' : 0.0,
'5' : 0.0581,
'6' : 0.0
},
'consumer_electronics': {
'0' : 0.0182,
'1' : 0.7633,
'2' : 0.0791,
'3' : 0.0811,
'4' : 0.0,
'5' : 0.0581,
'6' : 0.0
},
'home_computing': {
'0' : 0.0182,
'1' : 0.7633,
'2' : 0.0791,
'3' : 0.0811,
'4' : 0.0,
'5' : 0.0581,
'6' : 0.0
},
'cooking': {
'0' : 0.0182,
'1' : 0.7633,
'2' : 0.0791,
'3' : 0.0811,
'4' : 0.0,
'5' : 0.0581,
'6' : 0.0
}
}

# Convert to array
for i in fuel_type_p_by:
a = fuel_type_p_by[i].items()
a = list(a)
fuel_type_p_by[i] = np.array(a, dtype=float)


fuel_type_p_ey = {'light': {
'0' : 0.2,
'1' : 0.3,
'2' : 0.4,
'3' : 0.0,
'4' : 0.0,
'5' : 0.0,
'6' : 0.0
},
'cold': {
'0' : 0.0182,
'1' : 0.7633,
'2' : 0.0791,
'3' : 0.0811,
'4' : 0.0,
'5' : 0.0581,
'6' : 0.0
},
'cooking': {
'0' : 0.2,
'1' : 0.3,
'2' : 0.4,
'3' : 0.0,
'4' : 0.0,
'5' : 0.0,
'6' : 0.0
},
'wet': {
'0' : 0.0182,
'1' : 0.7633,
'2' : 0.0791,
'3' : 0.0811,
'4' : 0.0,
'5' : 0.0581,
'6' : 0.0
},
'consumer_electronics': {
'0' : 0.0182,
'1' : 0.7633,
'2' : 0.0791,
'3' : 0.0811,
'4' : 0.0,
'5' : 0.0581,
'6' : 0.0
},
'home_computing': {
'0' : 0.0182,
'1' : 0.7633,
'2' : 0.0791,
'3' : 0.0811,
'4' : 0.0,
'5' : 0.0581,
'6' : 0.0
},
'cooking': {
'0' : 0.0182,
'1' : 0.7633,
'2' : 0.0791,
'3' : 0.0811,
'4' : 0.0,
'5' : 0.0581,
'6' : 0.0
}
}

# Convert to array
for i in fuel_type_p_ey:
a = fuel_type_p_ey[i].items()
a = list(a)
fuel_type_p_ey[i] = np.array(a, dtype=float)

'''fuel_type_p_by = {
'space_heating_solid' : 0.0182,
'space_heating_gas' : 0.7633,
'space_heating_elec' : 0.0791,
Expand All @@ -77,6 +210,7 @@ def load_assumptions(data):
'space_heating_renew' : 0.0581,
'space_heating_hydro' : 0.0,
}
'''


# ----------------------------------
Expand Down
28 changes: 2 additions & 26 deletions energy_demand/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,34 +73,10 @@ def energy_demand_model(data, assumptions, data_ext):
'''


# new approach
# new approach - OBJECT ORIENTED
# ------------------
import energy_demand.main_object_approach as tttt


print(data['fuel_type_lu'])
print(data['reg_lu'])
print(data['fuel_bd_data'])
print(data['data_residential_by_fuel_end_uses'])
print(data['fueldata_disagg'])

# Testdata
test_fuel = {0:
{'heating': np.array((len(data['fuel_type_lu']), 1)),
'cooking': np.array((len(data['fuel_type_lu']), 1))
}
}
data['fueldata_disagg'] = test_fuel

# Iterate regions
for reg in data['reg_lu']:
print("Region: " + str(reg))
a = tttt.Region(reg, data, data_ext)

print(len(a.end_uses))

prnt("..")

tttt.test_run_new_model(data, data_ext, assumptions)



Expand Down
59 changes: 58 additions & 1 deletion energy_demand/main_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,62 @@ def read_csv(path_to_csv):
elements_array = np.array(list_elements)
return elements_array

def read_csv_base_data_resid(path_to_csv):
"""This function reads in base_data_CSV all fuel types (first row is fueltype, subkey), header is appliances
Parameters
----------
path_to_csv : str
Path to csv file
_dt : str
Defines dtype of array to be read in (takes float)
Returns
-------
elements_array : dict
Returns an dict with arrays
Notes
-----
the first row is the fuel_ID
The header is the sub_key
# Quick and dirty
"""
l = []
end_uses_dict = {}

with open(path_to_csv, 'r') as csvfile: # Read CSV file
read_lines = csv.reader(csvfile, delimiter=',') # Read line
_headings = next(read_lines) # Skip first row

# Iterate rows
for row in read_lines: # select row
l.append(row)

for i in _headings[1:]: # skip first
end_uses_dict[i] = np.zeros((len(l), 1)) # len fuel_ids

cnt_fueltype = 0
for row in l:
cnt = 1 #skip first
for i in row[1:]:
end_use = _headings[cnt]
end_uses_dict[end_use][cnt_fueltype] = i
cnt += 1

cnt_fueltype += 1

#import pprint
'''for i in end_uses_dict:
print("Appliances" + str(i))
print(end_uses_dict[i])
print("--")
'''
return end_uses_dict




def create_timesteps_app(fuel_type, date_list, bd_app_elec, reg_lu, fuel_type_lu, app_type_lu, timestep_dates):
"""Creates the timesteps for which the energy demand of the appliances is calculated.
Then base energy demand is added for each timestep read in from yearly demand aray.
Expand Down Expand Up @@ -1154,7 +1210,8 @@ def read_data(path_main):


# Data new approach
data_residential_by_fuel_end_uses = read_csv_dict(path_dict['path_data_residential_by_fuel_end_uses'])
#print(path_dict['path_data_residential_by_fuel_end_uses'])
data_residential_by_fuel_end_uses = read_csv_base_data_resid(path_dict['path_data_residential_by_fuel_end_uses']) # Yearly end use data



Expand Down

0 comments on commit 3e25f00

Please sign in to comment.