energy_demand.scripts package¶
The scripts are necessary for all calculations outside the main energy_demand function.
Subpackages¶
- energy_demand.scripts.smif_data_related package
- energy_demand.scripts.weather_scripts package
- Submodules
- energy_demand.scripts.weather_scripts.map_2015data_to_MARIUS module
- energy_demand.scripts.weather_scripts.s_clean_weather_hourly module
- energy_demand.scripts.weather_scripts.s_clean_weather_t_min_max module
- energy_demand.scripts.weather_scripts.weather_scenario module
- energy_demand.scripts.weather_scripts.weather_scenario_generate_instance module
Submodules¶
energy_demand.scripts.batch_commands_main module¶
energy_demand.scripts.cluster_execution module¶
energy_demand.scripts.cluster_execution_paperI module¶
energy_demand.scripts.cluster_execution_weather_scenarios module¶
energy_demand.scripts.folder_size module¶
energy_demand.scripts.init_scripts module¶
energy_demand.scripts.s_LAD_MSOA module¶
energy_demand.scripts.s_disaggregation module¶
energy_demand.scripts.s_fuel_to_service module¶
energy_demand.scripts.s_generate_sigmoid module¶
Script to fit technology diffusion
This script calculates the three parameters of a sigmoid diffusion for every technology which is diffused and has a larger service fraction at the model end year
-
energy_demand.scripts.s_generate_sigmoid.
calc_service_fuel_switched
(fuel_switches, technologies, s_fueltype_by_p, s_tech_by_p, fuel_tech_p_by, switch_type)[source]¶ Calculate energy service demand percentages after fuel switches.
- Parameters
fuel_switches (dict) – Fuel switches of a specific enduse
technologies (dict) – Technologies
s_fueltype_by_p (dict) – Service share per fueltype in base year
s_tech_by_p (dict) – Share of service demand per technology for base year
fuel_tech_p_by (dict) – Fuel shares for each technology of an enduse for base year
switch_type (str) – If either switch is for maximum theoretical switch of with defined switch until end year
- Returns
s_tech_switched_p – Service in future year with added and substracted service demand for every technology
- Return type
Note
Assertion may be removed to increase speed
-
energy_demand.scripts.s_generate_sigmoid.
calc_sigmoid_parameters
(l_value, xdata, ydata, fit_assump_init=0.001, error_range=2e-05, number_of_iterations=1000)[source]¶ Calculate sigmoid parameters. Check if fitting is good enough.
- Parameters
l_value (float) – Maximum upper level
xdata (array) – X data
ydata (array) – Y data
fit_assump_init (float) – Small value for correct sigmoid diffusion in case start value is equal to L
fit_crit_max (float) – Criteria to control and abort fit
fit_crit_min (float) – Criteria to control and abort fit (slope must be posititive)
error_range (float,default=0.00002) – Allowed fitting offset in percent
Note
error_range can be changed if the plotting is weird. If you increase chances are however higher that the fitting does not work anymore.
- Returns
fit_parameter – Parameters (first position: midpoint, second position: slope)
- Return type
array
-
energy_demand.scripts.s_generate_sigmoid.
fit_sigmoid_diffusion
(l_value, x_data, y_data, start_parameters, number_of_iterations=10000)[source]¶ Fit sigmoid curve based on two points on the diffusion curve
- Parameters
- Returns
popt – Fitting parameters (l_value, midpoint, steepness)
- Return type
Note
The Sigmoid is substacted - 2000 to allow for better fit with low values
Warning
It cannot fit a value starting from 0. Therefore, some initial penetration needs to be assumed (e.g. 0.001%) RuntimeWarning is ignored https://stackoverflow.com/questions/4359959/overflow-in-exp-in-scipy-numpy-in-python
-
energy_demand.scripts.s_generate_sigmoid.
get_l_values
(technologies, technologies_to_consider, regions=False)[source]¶ Get l values (Maximum shares of each technology) for all installed technologies
-
energy_demand.scripts.s_generate_sigmoid.
get_tech_installed
(enduse, fuel_switches)[source]¶ Read out all technologies which are specifically switched to of a specific enduse
- endusestr
enduse
- fuel_switchesdict
All fuel switches where a share of a fuel of an enduse is switched to a specific technology
- Returns
installed_tech (list) – List with all technologies where a fuel share is switched to
crit_fuel_switch (bool) – Criteria wheter swich is defined or not
-
energy_demand.scripts.s_generate_sigmoid.
plotout_sigmoid_tech_diff
(L_value, technology, xdata, ydata, fit_parameter, plot_crit=False, close_window_crit=True)[source]¶ Plot sigmoid diffusion
-
energy_demand.scripts.s_generate_sigmoid.
tech_l_sigmoid
(s_tech_switched_ey, enduse_fuel_switches, technologies, installed_tech, s_fueltype_by_p, s_tech_by_p, fuel_tech_p_by)[source]¶ Calculate L value (maximum possible theoretical market penetration) for every installed technology with maximum theoretical replacement share (calculate second sigmoid point).
- Parameters
s_tech_switched_ey (dict) – Ey service tech
enduse_fuel_switches (dict) – Fuel switches of enduse
installed_tech (dict) – Installed technologies (as keys)
s_fueltype_by_p (dict) – Service share per fueltye of base year
s_tech_by_p (dict) – Percentage of service demands for every technology
fuel_tech_p_by (dict) – Fuel share per technology of base year
- Returns
l_values_sig – L value for sigmoid diffusion of all technologies for which a switch is implemented
- Return type
-
energy_demand.scripts.s_generate_sigmoid.
tech_sigmoid_parameters
(yr_until_switched, switch_yr_start, technologies, l_values, s_tech_by_p, s_tech_switched_p, fit_assump_init=0.001, plot_sigmoid_diffusion=False)[source]¶ Calculate sigmoid diffusion parameters based on energy service demand in base year and projected future energy service demand. The future energy servie demand is calculated based on fuel switches.
Three potential sigmoid outputs are possible:
- ‘linear’: No sigmoid fitting possible because the
service in the future year is identical to the service in the base year
- None: No sigmoid is fitted if the future
service share is zero.
fit_parameters Sigmoid diffusion parameters
Because the sigmoid fitting does not work if the initial and end values are zero, small approximatie values fit_assump_init are inserted to allow the function ‘calc_sigmoid_parameters’ to fit.
- Parameters
yr_until_switched (int) – Year until switch is fully realised
switch_yr_start (int) – Start year of story in narrative
technologies (dict) – technologies
l_values (dict) – L values for maximum possible diffusion of technologies
s_tech_by_p (dict) – Energy service demand for base year (1. sigmoid point)
s_tech_switched_p (dict) – Service demand after fuelswitch
fit_assump_init (float) – Approximation helping small number to allow fit
plot_sigmoid_diffusion (bool,default=True) – Criteria whether sigmoid are plotted
- Returns
sig_params (dict) – Sigmoid diffusion parameters to read energy service demand percentage (not fuel!)
Info
—– –
- rounding_accuracy This rounds the by and ey service share
to the defined number of digits. Because of rounding error, there might be very small differences in percentual service demand.