Skip to content

Commit

Permalink
before release
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Eggimann authored and Sven Eggimann committed Sep 3, 2018
1 parent 95a138c commit 7f939c9
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 59 deletions.
3 changes: 3 additions & 0 deletions energy_demand/enduse_func.py
Expand Up @@ -1411,6 +1411,9 @@ def calc_service_switch(
s_tech_cy_p = get_service_diffusion(
sig_param_tech[tech], curr_yr)

# KAMEL
#s_tech_cy_p = strategy_vars[tech][curr_yr]

if s_tech_cy_p == 'identical':
switched_s_tech_y_cy[tech] = s_tech_y_cy[tech]
else:
Expand Down
21 changes: 12 additions & 9 deletions energy_demand/main.py
Expand Up @@ -192,16 +192,16 @@ def energy_demand_model(regions, data, assumptions):
# -----------------------------
# Create new folders
# -----------------------------
basic_functions.del_previous_setup(data['data']['result_paths']['data_results'])
basic_functions.del_previous_setup(data['result_paths']['data_results'])

folders_to_create = [
data['data']['local_paths']['dir_services'],
data['data']['local_paths']['path_sigmoid_data'],
data['data']['result_paths']['data_results'],
data['data']['result_paths']['data_results_PDF'],
data['data']['result_paths']['data_results_model_run_pop'],
data['data']['result_paths']['data_results_validation'],
data['data']['result_paths']['data_results_model_runs']]
data['local_paths']['dir_services'],
data['local_paths']['path_sigmoid_data'],
data['result_paths']['data_results'],
data['result_paths']['data_results_PDF'],
data['result_paths']['data_results_model_run_pop'],
data['result_paths']['data_results_validation'],
data['result_paths']['data_results_model_runs']]

for folder in folders_to_create:
basic_functions.create_folder(folder)
Expand Down Expand Up @@ -310,12 +310,15 @@ def energy_demand_model(regions, data, assumptions):
# ------------------------------------------------
# Initialise scenario
# ------------------------------------------------
data['assumptions']['rs_sig_param_tech'], data['assumptions']['ss_sig_param_tech'], data['assumptions']['is_sig_param_tech'] = switch_calculations(
rs_sig_param_tech, ss_sig_param_tech, is_sig_param_tech = switch_calculations(
data,
f_reg,
f_reg_norm,
f_reg_norm_abs,
crit_all_the_same)
data['assumptions'].update('rs_sig_param_tech', rs_sig_param_tech)
data['assumptions'].update('ss_sig_param_tech', ss_sig_param_tech)
data['assumptions'].update('is_sig_param_tech', is_sig_param_tech)

# ------------------------------------------------
# Calculate parameter values for every region
Expand Down
66 changes: 20 additions & 46 deletions energy_demand/scripts/init_scripts.py
Expand Up @@ -94,29 +94,6 @@ def switch_calculations(
rs_sig_param_tech, ss_sig_param_tech, is_sig_param_tech : dict
Sigmoid diffusion parameters
"""
'''# --------------------------------------------
# Delete results from previous model runs
# and initialise folders
# --------------------------------------------
#basic_functions.del_previous_results(
# data['local_paths']['data_processed'],
# data['local_paths']['path_post_installation_data'])
basic_functions.del_previous_setup(
data['result_paths']['data_results'])
folders_to_create = [
data['local_paths']['dir_services'],
data['local_paths']['path_sigmoid_data'],
data['result_paths']['data_results'],
data['result_paths']['data_results_PDF'],
data['result_paths']['data_results_model_run_pop'],
data['result_paths']['data_results_validation'],
data['result_paths']['data_results_model_runs']]
for folder in folders_to_create:
basic_functions.create_folder(folder)'''

# ---------------------------------------
# Convert base year fuel input assumptions to energy service
# ---------------------------------------
Expand Down Expand Up @@ -152,36 +129,32 @@ def switch_calculations(
data['technologies'],
sector)

# ===========================================
# I. Switches
# ===========================================

# ========================================================================================
# Capacity switches
#
# Calculate service shares considering potential capacity installations
# ========================================================================================
ss_aggr_sector_fuels = s_fuel_to_service.sum_fuel_enduse_sectors(
data['fuels']['ss_fuel_raw'],
data['enduses']['ss_enduses'])

is_aggr_sector_fuels = s_fuel_to_service.sum_fuel_enduse_sectors(
data['fuels']['is_fuel_raw'],
data['enduses']['is_enduses'])

# ----------------------
# Select diffusion value
# ----------------------
f_diffusion = f_reg_norm_abs #TODO EXPLAIN

# Convert globally defined switches to regional switches
f_diffusion = f_reg_norm_abs #TODO EXPLAIN # Select diffusion value

reg_capacity_switches_rs = global_to_reg_capacity_switch(
data['regions'], data['assumptions'].rs_capacity_switches, f_diffusion=f_diffusion)
reg_capacity_switches_ss = global_to_reg_capacity_switch(
data['regions'], data['assumptions'].ss_capacity_switches, f_diffusion=f_diffusion)
reg_capacity_switches_is = global_to_reg_capacity_switch(
data['regions'], data['assumptions'].is_capacity_switches, f_diffusion=f_diffusion)

# sum across sectors
ss_aggr_sector_fuels = s_fuel_to_service.sum_fuel_enduse_sectors(
data['fuels']['ss_fuel_raw'],
data['enduses']['ss_enduses'])

is_aggr_sector_fuels = s_fuel_to_service.sum_fuel_enduse_sectors(
data['fuels']['is_fuel_raw'],
data['enduses']['is_enduses'])

# Capacity switches
rs_service_switches_incl_cap = fuel_service_switch.capacity_switch(
data['regions'],
reg_capacity_switches_rs,
Expand Down Expand Up @@ -335,6 +308,10 @@ def switch_calculations(
sector=sector,
crit_all_the_same=crit_all_the_same)

# ------------------
# Convert to annual values TODO
# ------------------

return rs_sig_param_tech, ss_sig_param_tech, is_sig_param_tech

def spatial_explicit_modelling_strategy_vars(
Expand Down Expand Up @@ -645,12 +622,11 @@ def sig_param_calc_incl_fuel_switch(
# ------------------------------------------
sig_param_tech = {}
service_switches_out = {}

for region in regions:
sig_param_tech[region] = []
service_switches_out[region] = service_switches_enduse[region]

# Test if swithc is defined
# Test if switch is defined
crit_switch_service = fuel_service_switch.get_switch_criteria(
enduse,
sector,
Expand All @@ -667,12 +643,10 @@ def sig_param_calc_incl_fuel_switch(
# Calculate only from service switch
s_tech_switched_p = share_s_tech_ey_p

all_techs = s_tech_by_p.keys()

# Calculate sigmoid diffusion parameters
l_values_sig = s_generate_sigmoid.get_l_values(
technologies,
all_techs,
technologies=technologies,
technologies_to_consider=s_tech_by_p.keys(),
regions=regions)

# ------------------------------------------
Expand All @@ -687,7 +661,7 @@ def sig_param_calc_incl_fuel_switch(
enduse_fuel_switches = fuel_service_switch.get_fuel_switches_enduse(
fuel_switches, enduse)

# ONly calculate for one reg
# Only calculate for one reg
any_region = regions[0]

l_values_sig = {}
Expand Down
31 changes: 30 additions & 1 deletion energy_demand/scripts/s_generate_scenario_parameters.py
Expand Up @@ -2,9 +2,38 @@
"""
import os
from collections import defaultdict
#import pandas as pd
from energy_demand.technologies import diffusion_technologies

def calc_annual_switch_params(
reg_strategy_vars,
rs_sig_param_tech,
ss_sig_param_tech,
is_sig_param_tech):
"""
"""
'''annual_tech_diff_params = {}
for enduse, region_tech_vals in rs_sig_param_tech.items():
for region in region_tech_vals.keys():
for tech in region_tech_vals[region].keys():
# Sigmoid diffusion values
midpoint = region_tech_vals[tech]['midpoint']
steepness = region_tech_vals[tech]['steepness']
l_parameter = region_tech_vals[tech]['l_parameter']
# Iterate every year
for sim_yr in range(2015, 2051):
if midpoint = 'linear':
else:
annual_tech_diff_params[region][enduse][tech][sim_yr] =
reg_strategy_vars["annual_tech_diff_params"] = annual_tech_diff_params'''
return reg_strategy_vars

def generate_annual_param_vals(
regions,
strategy_vars,
Expand Down
4 changes: 1 addition & 3 deletions energy_demand/scripts/s_post_installation.py
Expand Up @@ -60,7 +60,7 @@ def post_install_setup(args):
# Delete all previous data from previous model runs
basic_functions.del_previous_setup(data['local_paths']['data_processed'])
basic_functions.del_previous_setup(data['result_paths']['data_results'])
basic_functions.del_previous_setup(data['result_paths']['path_post_installation_data'])
basic_functions.del_previous_setup(data['local_paths']['path_post_installation_data'])

# Create folders and subfolder for data_processed
folders_to_create = [
Expand Down Expand Up @@ -104,8 +104,6 @@ def post_install_setup(args):

# Complete gva and pop data for every sector
data_pop = os.path.join(local_data_path, "scenarios", "MISTRAL_pop_gva", "data")

#"uk_pop_principal_2015_2050_MSOA_england.csv"
path_geography = os.path.join(local_data_path, "scenarios", "uk_pop_principal_2015_2050_MSOA_england.csv")

script_data_preparation_MISTRAL_pop_gva.run(
Expand Down

0 comments on commit 7f939c9

Please sign in to comment.