Skip to content

Commit

Permalink
fixed paths
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Eggimann committed Mar 26, 2018
1 parent ec528cc commit 1014e52
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 39 deletions.
6 changes: 6 additions & 0 deletions energy_demand/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,13 @@ def energy_demand_model(data, assumptions, fuel_in=0, fuel_in_elec=0):
data['criterias']['beyond_supply_outputs'] = True # Wheater all results besides integraded smif run are calculated
data['criterias']['plot_tech_lp'] = True # Wheater all individual load profils are plotted

# Paths
data['paths'] = data_loader.load_paths(path_main)
data['local_paths'] = data_loader.load_local_paths(local_data_path)

result_path = os.path.dirname(__file__).split("energy_demand\\energy_demand")[0]
data['result_paths'] = data_loader.load_result_paths(os.path.join(result_path, 'result_data'))

data['lookups'] = lookup_tables.basic_lookups()
data['enduses'], data['sectors'], data['fuels'] = data_loader.load_fuels(data['paths'], data['lookups'])

Expand Down Expand Up @@ -238,6 +243,7 @@ def energy_demand_model(data, assumptions, fuel_in=0, fuel_in_elec=0):
pop_density[reg] = 1
data['regions'] = list(data['regions'].keys())
data['pop_density'] = pop_density

# ------------------------------
# Assumptions
# ------------------------------
Expand Down
2 changes: 0 additions & 2 deletions energy_demand/processing_multiple_scenarios.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ def process_scenarios(path_to_scenarios, year_to_model=2015):
# Delete folder results if existing
path_result_folder = os.path.join(path_to_scenarios, "results_multiple_scenarios")

#result_paths = load_result_paths(path_result_folder)

basic_functions.delete_folder(path_result_folder)

seasons = date_prop.get_season(
Expand Down
29 changes: 19 additions & 10 deletions energy_demand/read_write/data_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,22 +243,32 @@ def load_local_paths(path):

def load_result_paths(path):
"""Load all result paths
Argument
--------
path : str
Path to result folder
Return
-------
paths : dict
All result paths used in model
"""
paths = {
'data_results': os.path.join(
path, '_result_data'),
'data_results':
path,
'data_results_model_run_pop': os.path.join(
path, '_result_data', 'model_run_pop'),
path, 'model_run_pop'),
'data_results_model_runs': os.path.join(
path, '_result_data', 'model_run_results_txt'),
path, 'model_run_results_txt'),
'data_results_PDF': os.path.join(
path, '_result_data', 'PDF_results'),
path, 'PDF_results'),
'data_results_validation': os.path.join(
path, '_result_data', 'PDF_validation'),
path, 'PDF_validation'),
'model_run_pop': os.path.join(
path, '_result_data', 'model_run_pop'),
path, 'model_run_pop'),
'data_results_shapefiles': os.path.join(
path, '_result_data', 'spatial_results')}
path, 'spatial_results')}

return paths

Expand Down Expand Up @@ -357,8 +367,7 @@ def load_paths(path):
'yaml_parameters_keynames_unconstrained': os.path.join(
path, 'yaml_parameters_keynames_unconstrained.yml'),
'yaml_parameters_scenario': os.path.join(
path, 'yaml_parameters_scenario.yml')
}
path, 'yaml_parameters_scenario.yml')}

return paths

Expand Down
19 changes: 4 additions & 15 deletions energy_demand/scripts/s_post_installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def post_install_setup(args):

# Paths
path_main = resource_filename(Requirement.parse("energy_demand"), "config_data")

path_results = resource_filename(Requirement.parse("energy_demand"), "results")
local_data_path = args.local_data

# Initialise logger
Expand All @@ -41,11 +41,11 @@ def post_install_setup(args):

# Load data
base_yr = 2015

data = {}

data['paths'] = data_loader.load_paths(path_main)
data['local_paths'] = data_loader.load_local_paths(local_data_path)
data['result_paths'] = data_loader.load_result_paths(path_results)
data['lookups'] = lookup_tables.basic_lookups()
data['enduses'], data['sectors'], data['fuels'] = data_loader.load_fuels(
data['paths'], data['lookups'])
Expand All @@ -60,11 +60,11 @@ def post_install_setup(args):
fueltypes_nr=data['lookups']['fueltypes_nr'])

# Delete all previous data from previous model runs
basic_functions.del_previous_setup(data['result_paths']['data_processed'])
basic_functions.del_previous_setup(data['local_paths']['data_processed'])
basic_functions.del_previous_setup(data['result_paths']['data_results'])

# Create folders and subfolder for data_processed
basic_functions.create_folder(data['result_paths']['data_processed'])
basic_functions.create_folder(data['local_paths']['data_processed'])
basic_functions.create_folder(data['local_paths']['path_post_installation_data'])
basic_functions.create_folder(data['local_paths']['dir_raw_weather_data'])
basic_functions.create_folder(data['local_paths']['dir_changed_weather_station_data'])
Expand All @@ -91,16 +91,5 @@ def post_install_setup(args):
data['local_paths'],
base_yr)

logging.info("... finished setup")
print("... successfully finished setup")
return

# ------run locally
'''
class ClassTest():
def __init__(self, data_energy_demand):
self.data_energy_demand = data_energy_demand
#in_obj = ClassTest("C://Users//cenv0553//nismod//data_energy_demand")
in_obj = ClassTest("C://DATA_NISMODII//data_energy_demand")
post_install_setup(in_obj)
'''
25 changes: 13 additions & 12 deletions energy_demand/validation/lad_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def map_LAD_2011_2015(lad_data):
return mapped_lads

def temporal_validation(
local_paths,
result_paths,
elec_ed_fueltype_national_yh,
elec_factored_yh,
elec_2015_indo,
Expand All @@ -72,7 +72,7 @@ def temporal_validation(
Arguments
---------
local_paths :
result_paths :
elec_ed_fueltype_national_yh
elec_2015_indo
elec_2015_itsdo
Expand All @@ -85,7 +85,7 @@ def temporal_validation(
days_to_plot = list(range(0, 365))
elec_national_data.compare_results(
'validation_temporal_electricity_8760h.pdf',
local_paths['data_results_validation'],
result_paths['data_results_validation'],
elec_2015_indo,
elec_2015_itsdo,
elec_factored_yh,
Expand Down Expand Up @@ -121,7 +121,7 @@ def temporal_validation(

elec_national_data.compare_results(
'validation_temporal_electricity_weeks_selection.pdf',
local_paths['data_results_validation'],
result_paths['data_results_validation'],
elec_2015_indo,
elec_2015_itsdo,
elec_factored_yh,
Expand All @@ -143,6 +143,7 @@ def tempo_spatial_validation(
fueltypes,
fueltypes_nr,
local_paths,
result_paths,
paths,
regions,
reg_coord,
Expand Down Expand Up @@ -221,7 +222,7 @@ def tempo_spatial_validation(
subnational_elec,
regions,
'elec',
os.path.join(local_paths['data_results_validation'], 'validation_spatial_elec.pdf'),
os.path.join(result_paths['data_results_validation'], 'validation_spatial_elec.pdf'),
label_points=False,
plotshow=plot_crit)

Expand All @@ -232,7 +233,7 @@ def tempo_spatial_validation(
subnational_gas,
regions,
'gas',
os.path.join(local_paths['data_results_validation'], 'validation_spatial_gas.pdf'),
os.path.join(result_paths['data_results_validation'], 'validation_spatial_gas.pdf'),
label_points=False,
plotshow=plot_crit)

Expand All @@ -250,7 +251,7 @@ def tempo_spatial_validation(
elec_factored_yh = f_diff_elec * elec_2015_indo

temporal_validation(
local_paths,
result_paths,
ed_fueltype_national_yh[fueltypes['electricity']],
elec_factored_yh,
elec_2015_indo,
Expand All @@ -274,9 +275,9 @@ def tempo_spatial_validation(

# Plot average daily loads
plotting_results.plot_load_profile_dh_multiple(
path_fig_folder=local_paths['data_results_validation'],
path_fig_folder=result_paths['data_results_validation'],
path_plot_fig=os.path.join(
local_paths['data_results_validation'],
result_paths['data_results_validation'],
'validation_all_season_daytypes.pdf'),
calc_av_lp_modelled=calc_av_lp_modelled,
calc_av_lp_real=calc_av_lp_real,
Expand All @@ -302,14 +303,14 @@ def tempo_spatial_validation(

elec_national_data.compare_peak(
"validation_elec_peak_comparison_peakday_yh.pdf",
local_paths['data_results_validation'],
result_paths['data_results_validation'],
elec_2015_indo[peak_day],
ed_fueltype_national_yh[fueltypes['electricity']][peak_day])

logging.info("...compare peak from max peak factors")
elec_national_data.compare_peak(
"validation_elec_peak_comparison_peak_shapes.pdf",
local_paths['data_results_validation'],
result_paths['data_results_validation'],
elec_2015_indo[peak_day],
tot_fuel_peak_dh[fueltypes['electricity']])

Expand All @@ -318,7 +319,7 @@ def tempo_spatial_validation(
# ---------------------------------------------------
elec_national_data.compare_results_hour_boxplots(
"validation_hourly_boxplots_electricity_01.pdf",
local_paths['data_results_validation'],
result_paths['data_results_validation'],
elec_2015_indo,
ed_fueltype_national_yh[fueltypes['electricity']])

Expand Down

0 comments on commit 1014e52

Please sign in to comment.