diff --git a/energy_demand/enduse_func.py b/energy_demand/enduse_func.py index ee7c650d..bb513b02 100644 --- a/energy_demand/enduse_func.py +++ b/energy_demand/enduse_func.py @@ -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: diff --git a/energy_demand/main.py b/energy_demand/main.py index 83f27221..6e753ce6 100644 --- a/energy_demand/main.py +++ b/energy_demand/main.py @@ -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) @@ -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 diff --git a/energy_demand/scripts/init_scripts.py b/energy_demand/scripts/init_scripts.py index 28398d24..3bec04a9 100644 --- a/energy_demand/scripts/init_scripts.py +++ b/energy_demand/scripts/init_scripts.py @@ -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 # --------------------------------------- @@ -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, @@ -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( @@ -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, @@ -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) # ------------------------------------------ @@ -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 = {} diff --git a/energy_demand/scripts/s_generate_scenario_parameters.py b/energy_demand/scripts/s_generate_scenario_parameters.py index 3502cf7d..cf697706 100644 --- a/energy_demand/scripts/s_generate_scenario_parameters.py +++ b/energy_demand/scripts/s_generate_scenario_parameters.py @@ -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, diff --git a/energy_demand/scripts/s_post_installation.py b/energy_demand/scripts/s_post_installation.py index cbbc4b5a..d008f189 100644 --- a/energy_demand/scripts/s_post_installation.py +++ b/energy_demand/scripts/s_post_installation.py @@ -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 = [ @@ -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(