Skip to content

Commit

Permalink
Paths corrected
Browse files Browse the repository at this point in the history
  • Loading branch information
eggimasv authored and eggimasv committed Mar 24, 2017
1 parent 6c1ff39 commit e726b45
Show file tree
Hide file tree
Showing 13 changed files with 157,869 additions and 157,880 deletions.
54 changes: 54 additions & 0 deletions energy_demand/_scrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,57 @@
fig, ax = plt.subplots()
ax.stackplot(x, y)
plt.show()

"""A one-line summary that does not use variable names or the
function name.
Several sentences providing an extended description. Refer to
variables using back-ticks, e.g. `var`.
Parameters
----------
var1 : array_like
Array_like means all those objects -- lists, nested lists, etc. --
that can be converted to an array. We can also refer to
variables like `var1`.
var2 : int
The type above can either refer to an actual Python type
(e.g. ``int``), or describe the type of the variable in more
detail, e.g. ``(N,) ndarray`` or ``array_like``.
long_var_name : {'hi', 'ho'}, optional
Choices in brackets, default first when optional.
Returns
-------
type
Explanation of anonymous return value of type ``type``.
describe : type
Explanation of return value named `describe`.
out : type
Explanation of `out`.
Other Parameters
----------------
only_seldom_used_keywords : type
Explanation
common_parameters_listed_above : type
Explanation
Raises
------
BadException
Because you shouldn't have done that.
See Also
--------
otherfunc : relationship (optional)
newfunc : Relationship (optional), which could be fairly long, in which
case the line wraps here.
thirdfunc, fourthfunc, fifthfunc
Notes
-----
Notes about the implementation algorithm (if needed).
This can have multiple paragraphs.
You may include some math:
"""
125 changes: 122 additions & 3 deletions energy_demand/data_loader.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,132 @@
""" new load profile generator """

"""Loads all necessary data"""
import os
import csv
import unittest
import matplotlib.pyplot as plt
import numpy as np
import energy_demand.data_loader_functions as df
import main_functions as mf
import energy_demand.main_functions as mf
# pylint: disable=I0011,C0321,C0301,C0103, C0325

def load_data(data, path_main, data_ext):
"""All base data no provided externally are loaded
All necessary data to run energy demand model is loaded.
This data is loaded in the wrapper.
Parameters
----------
data : dict
Dict with own data
path_main : str
Path to all data of model run which are not provided externally by wrapper
Returns
-------
data : list
Returns a list where storing all data
"""
path_dict = {

# Residential
# -----------
'path_main': path_main,
'path_pop_reg_lu': os.path.join(path_main, 'scenario_and_base_data/lookup_nr_regions.csv'),
'path_dwtype_lu': os.path.join(path_main, 'residential_model/lookup_dwelling_type.csv'),
'path_lookup_appliances':os.path.join(path_main, 'residential_model/lookup_appliances_HES.csv'),
'path_fuel_type_lu': os.path.join(path_main, 'scenario_and_base_data/lookup_fuel_types.csv'),
'path_day_type_lu': os.path.join(path_main, 'residential_model/lookup_day_type.csv'),
'path_bd_e_load_profiles': os.path.join(path_main, 'residential_model/HES_base_appliances_eletricity_load_profiles.csv'),
'path_temp_2015': os.path.join(path_main, 'residential_model/SNCWV_YEAR_2015.csv'),
'path_hourly_gas_shape_resid': os.path.join(path_main, 'residential_model/SANSOM_residential_gas_hourly_shape.csv'),
'path_dwtype_dist': os.path.join(path_main, 'residential_model/data_residential_model_dwtype_distribution.csv'),
'path_dwtype_age': os.path.join(path_main, 'residential_model/data_residential_model_dwtype_age.csv'),
'path_dwtype_floorarea_dw_type': os.path.join(path_main, 'residential_model/data_residential_model_dwtype_floorarea.csv'),
'path_reg_floorarea': os.path.join(path_main, 'residential_model/data_residential_model_floorarea.csv'),
'path_reg_dw_nr': os.path.join(path_main, 'residential_model/data_residential_model_nr_dwellings.csv'),
'path_data_residential_by_fuel_end_uses': os.path.join(path_main, 'residential_model/data_residential_by_fuel_end_uses.csv'),
'path_lu_appliances_HES_matched': os.path.join(path_main, 'residential_model/lookup_appliances_HES_matched.csv'),
'path_txt_shapes_resid': os.path.join(path_main, 'residential_model/txt_load_shapes')

# Service
# -----------
#'path_temp_2015_service': os.path.join(path_main, 'service_model/CSV_YEAR_2015_service.csv')
}

data['path_dict'] = path_dict

# -- Reads in all csv files and store them in a dictionary
data['path_main'] = path_main

# Lookup data
data['reg_lu'] = mf.read_csv_dict_no_header(path_dict['path_pop_reg_lu']) # Region lookup table
data['dwtype_lu'] = mf.read_csv_dict_no_header(path_dict['path_dwtype_lu']) # Dwelling types lookup table
data['app_type_lu'] = mf.read_csv(path_dict['path_lookup_appliances']) # Appliances types lookup table
data['fuel_type_lu'] = mf.read_csv_dict_no_header(path_dict['path_fuel_type_lu']) # Fuel type lookup
data['day_type_lu'] = mf.read_csv(path_dict['path_day_type_lu']) # Day type lookup

#fuel_bd_data = read_csv_float(path_dict['path_base_data_fuel']) # All disaggregated fuels for different regions
data['path_temp_2015'] = mf.read_csv(path_dict['path_temp_2015']) # csv_temp_2015 #TODO: Delete because loaded in read_shp_heating_gas
data['hourly_gas_shape'] = mf.read_csv_float(path_dict['path_hourly_gas_shape_resid']) # Load hourly shape for gas from Robert Sansom #TODO: REmove because in read_shp_heating_gas

#path_dwtype_age = read_csv_float(['path_dwtype_age'])
data['dwtype_distr'] = mf.read_csv_nested_dict(path_dict['path_dwtype_dist']) # dISTRIBUTION of dwelligns base year #TODO: REMOVE AND ONLY LOAD YEAR 2015
data['dwtype_age_distr'] = mf.read_csv_nested_dict(path_dict['path_dwtype_age'])
data['dwtype_floorarea'] = mf.read_csv_dict(path_dict['path_dwtype_floorarea_dw_type'])
data['reg_floorarea'] = mf.read_csv_dict_no_header(path_dict['path_reg_floorarea'])
data['reg_dw_nr'] = mf.read_csv_dict_no_header(path_dict['path_reg_dw_nr'])

# load shapes
data['dict_shp_enduse_h_resid'] = {}
data['dict_shp_enduse_d_resid'] = {}

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

scrap = 0
for enduse in data_residential_by_fuel_end_uses:
scrap += np.sum(data_residential_by_fuel_end_uses[enduse])
print("scrap FUELS READ IN FROM EXCEL: " + str(scrap))

# Add the yearly fuel data of the external Wrapper to the enduses (RESIDENTIAL HERE)
###data = add_yearly_external_fuel_data(data, data_ext, data_residential_by_fuel_end_uses) #TODO: ALSO IMPORT ALL OTHER END USE RELATED THINS SUCH AS SHAPE

data['lu_appliances_HES_matched'] = mf.read_csv(path_dict['path_lu_appliances_HES_matched'])

# SERVICE SECTOR
#data['csv_temp_2015_service'] = mf.read_csv(path_dict['path_temp_2015_service']) # csv_temp_2015 #TODO: Dele
data['dict_shp_enduse_h_service'] = {}
data['dict_shp_enduse_d_service'] = {}

# ----------------------------------------
# --Convert loaded data into correct units
# ----------------------------------------

# Fuel residential
for enduse in data_residential_by_fuel_end_uses:
data_residential_by_fuel_end_uses[enduse] = mf.conversion_ktoe_gwh(data_residential_by_fuel_end_uses[enduse])

data['data_residential_by_fuel_end_uses'] = data_residential_by_fuel_end_uses


# --- Generate load_shapes ##TODO
data = generate_data(data) # Otherwise already read out files are read in from txt files

# -- Read in load shapes from files
data = collect_shapes_from_txts(data)

# ---TESTS
# Test if numer of fuel types is identical (Fuel lookup needs to have same dimension as end-use fuels)
for end_use in data['data_residential_by_fuel_end_uses']:
assert len(data['fuel_type_lu']) == len(data['data_residential_by_fuel_end_uses'][end_use]) # Fuel in fuel distionary does not correspond to len of input fuels

scrap = 0
for enduse in data['data_residential_by_fuel_end_uses']:
scrap += np.sum(data_residential_by_fuel_end_uses[enduse])
print("scrap FUELS FINAL FOR OUT: " + str(scrap))

return data

#run_data_collection = False #Scrap
# ---------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion energy_demand/data_loader_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import unittest
import json
from datetime import date
import main_functions as mf
import energy_demand.main_functions as mf


# HES-----------------------------------
Expand Down
66 changes: 2 additions & 64 deletions energy_demand/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
import energy_demand.residential_model as rm
import energy_demand.plot_functions as pf
import energy_demand.national_dissaggregation as nd
#import energy_demand.data_loader as dl
import energy_demand.data_loader as dl

print("Start Energy Demand Model with python version: " + str(sys.version))
import numpy as np
Expand Down Expand Up @@ -109,10 +109,6 @@ def energy_demand_model(data, data_ext):
#pf.plot_x_days(result_dict[2], 0, 2)
return result_dict





# Run
if __name__ == "__main__":

Expand Down Expand Up @@ -145,7 +141,7 @@ def energy_demand_model(data, data_ext):

# Model calculations outside main function
path_main = r'C:/Users/cenv0553/GIT/NISMODII/data/' #path_main = '../data'
base_data = mf.load_data(base_data, path_main, data_external) # Load and generate data
base_data = dl.load_data(base_data, path_main, data_external) # Load and generate data

# Load assumptions
print("Load Assumptions")
Expand All @@ -163,61 +159,3 @@ def energy_demand_model(data, data_ext):
# Run main function
energy_demand_model(base_data, data_external)
print("Finished running Energy Demand Model")





"""A one-line summary that does not use variable names or the
function name.
Several sentences providing an extended description. Refer to
variables using back-ticks, e.g. `var`.
Parameters
----------
var1 : array_like
Array_like means all those objects -- lists, nested lists, etc. --
that can be converted to an array. We can also refer to
variables like `var1`.
var2 : int
The type above can either refer to an actual Python type
(e.g. ``int``), or describe the type of the variable in more
detail, e.g. ``(N,) ndarray`` or ``array_like``.
long_var_name : {'hi', 'ho'}, optional
Choices in brackets, default first when optional.
Returns
-------
type
Explanation of anonymous return value of type ``type``.
describe : type
Explanation of return value named `describe`.
out : type
Explanation of `out`.
Other Parameters
----------------
only_seldom_used_keywords : type
Explanation
common_parameters_listed_above : type
Explanation
Raises
------
BadException
Because you shouldn't have done that.
See Also
--------
otherfunc : relationship (optional)
newfunc : Relationship (optional), which could be fairly long, in which
case the line wraps here.
thirdfunc, fourthfunc, fifthfunc
Notes
-----
Notes about the implementation algorithm (if needed).
This can have multiple paragraphs.
You may include some math:
"""

0 comments on commit e726b45

Please sign in to comment.