From c42f61a01642e4dea70e291aeddd44465873cec9 Mon Sep 17 00:00:00 2001 From: Sven Eggimann Date: Tue, 10 Apr 2018 08:23:52 +0100 Subject: [PATCH] before looking into hybrid again --- .../07-switches/rs_switches_service.csv | 1 - energy_demand/enduse_func.py | 12 +- energy_demand/main.py | 3 + energy_demand/plotting/plotting_results.py | 130 ++++++++++++++++++ energy_demand/plotting/plotting_styles.py | 1 - 5 files changed, 142 insertions(+), 5 deletions(-) diff --git a/config_data/07-switches/rs_switches_service.csv b/config_data/07-switches/rs_switches_service.csv index 8d283ec9..f7563a9d 100644 --- a/config_data/07-switches/rs_switches_service.csv +++ b/config_data/07-switches/rs_switches_service.csv @@ -1,2 +1 @@ enduse,tech,service_share_ey,switch_yr,sector -rs_space_heating,district_heating_CHP_gas,0.2,2050 diff --git a/energy_demand/enduse_func.py b/energy_demand/enduse_func.py index 8a9cc247..d07a36f6 100644 --- a/energy_demand/enduse_func.py +++ b/energy_demand/enduse_func.py @@ -339,6 +339,7 @@ def __init__( # --------------------------------------- if mode_constrained: self.techs_fuel_yh = {} + for tech in fuel_yh: self.techs_fuel_yh[tech] = demand_management( enduse, @@ -423,7 +424,8 @@ def demand_management( try: # Get assumed load shift param_name = 'demand_management_improvement__{}'.format(enduse) - + print("NAME " + str(param_name)) + print(strategy_variables[param_name]['scenario_value']) if strategy_variables[param_name]['scenario_value'] == 0: # no load management @@ -436,6 +438,9 @@ def demand_management( # no load management peak_shift_crit = False + if peak_shift_crit: + prnt("2oko") + # ------------------------------ # If peak shifting implemented, calculate new lp # ------------------------------ @@ -462,6 +467,7 @@ def demand_management( fuel_yh = lf.peak_shaving_max_min( lf_improved_cy, average_fuel_yd, fuel_yh, mode_constrained) + prnt("oko") else: # no peak shifting pass @@ -682,7 +688,7 @@ def get_peak_day_single_fueltype(fuel_yh): peak_day_nr = np.argmax(np.sum(fuel_yh, axis=1)) return peak_day_nr -def calc_peak_tech_dh( +'''def calc_peak_tech_dh( enduse, sector, enduse_techs, @@ -781,7 +787,7 @@ def calc_peak_tech_dh( fuels_peak_dh += fuel_tech_peak_dh return fuels_peak_dh - +''' def get_enduse_techs(fuel_fueltype_tech_p_by): """Get all defined technologies of an enduse diff --git a/energy_demand/main.py b/energy_demand/main.py index 023b0148..16fdfc98 100644 --- a/energy_demand/main.py +++ b/energy_demand/main.py @@ -29,6 +29,9 @@ TODO: WHAT ABOU NON_RESIDENTIAL FLOOR AREA: FOR WHAT? TODO: Spatial diffusion: Cap largest 5% of values and set to 1 TODO: CONTROL ALL PEAK RESULTS +TODO: HYBRID BOILER: + +Potential storline: different levels of hybrid boilers for heat? """ import os import sys diff --git a/energy_demand/plotting/plotting_results.py b/energy_demand/plotting/plotting_results.py index 21e9a0e6..55447b55 100644 --- a/energy_demand/plotting/plotting_results.py +++ b/energy_demand/plotting/plotting_results.py @@ -40,6 +40,7 @@ def run_all_plot_functions( plot_h_peak_fueltypes = True plot_averaged_season_fueltype = True # Compare for every season and daytype the daily loads plot_radar = False # Plot radar spider charts + # ---------- # Plot LAD differences for first and last year # ---------- @@ -58,6 +59,32 @@ def run_all_plot_functions( print("... plotted by-cy LAD energy demand compariosn") except: pass + + # ---------------- + # Plot demand for every region over time + # ------------------- + plot_line_for_every_region_of_peak_demand = True + if plot_line_for_every_region_of_peak_demand: + plt_one_fueltype_multiple_regions_peak_h( + results_container['results_every_year'], + lookups, + regions, + os.path.join( + result_paths['data_results_PDF'], + 'plt_one_fueltype_multiple_regions_peak_h_electricity.pdf'), + fueltype_str_to_plot="electricity") + + prnt(":") + + if plot_fuels_enduses_y: + logging.info("... plot fuel per fueltype for whole country over annual timesteps") + #... Plot total fuel (y) per fueltype as line chart" + plt_fuels_enduses_y( + results_container['results_every_year'], + lookups, + os.path.join( + result_paths['data_results_PDF'], + 'y_fueltypes_all_enduses.pdf')) # ------------ # Plot stacked annual enduses @@ -1908,3 +1935,106 @@ def plot_radar_plot_multiple_lines( plt.close() else: plt.close() + +def plt_one_fueltype_multiple_regions_peak_h(results_every_year, lookups, regions, path_plot_fig, fueltype_str_to_plot): + """Plot + Arguments + --------- + """ + # Set figure size + fig = plt.figure(figsize=plotting_program.cm2inch(14, 8)) + + ax = fig.add_subplot(1, 1, 1) + + nr_y_to_plot = len(results_every_year) + + legend_entries = [] + + for fueltype_str, fueltype in lookups['fueltypes'].items(): + + if fueltype_str != fueltype_str_to_plot: + pass + else: + # Legend + #legend_entries.append(fueltype_str) + + # Read out fueltype specific load + data_over_years = {} + for reg_nr, reg_geocode in enumerate(regions): + data_over_years[reg_nr] = [] + + for model_year_object in results_every_year.values(): + + # Reshape for finding peak day + nr_fueltypes = model_year_object.shape[0] + nr_regs = model_year_object.shape[1] + fuel_reg_reshaped = model_year_object.reshape(nr_fueltypes, nr_regs, 365, 24) + + for reg_nr, reg_geocode in enumerate(regions): + + # Get peak day across all enduses for every region + peak_day = enduse_func.get_peak_day_single_fueltype(fuel_reg_reshaped[fueltype][reg_nr]) + + tot_fuel_dh_peak = model_year_object[fueltype][reg_nr][peak_day] + + # Calculate max peak hour + peak_fueltyp_h = np.max(tot_fuel_dh_peak) + + # Add peak hour + data_over_years[reg_nr].append(peak_fueltyp_h) + + y_init = data_over_years + + # ---------- + # Plot lines + # ---------- + linestyles = plotting_styles.linestyles() + years = list(results_every_year.keys()) + #color_list_selection = plotting_styles.color_list_selection() + + for reg in y_init: + plt.plot( + years, + y_init[reg], + #linestyle=linestyles[fueltype], + color='lightblue', + linewidth=0.2,) + + ax.legend( + legend_entries, + prop={ + 'family': 'arial', + 'size': 8}, + frameon=False) + + # - + # Axis + # - + base_yr = 2015 + major_interval = 10 + minor_interval = 5 + + # Major ticks + major_ticks = np.arange(base_yr, years[-1] + major_interval, major_interval) + ax.set_xticks(major_ticks) + + # Minor ticks + minor_ticks = np.arange(base_yr, years[-1] + minor_interval, minor_interval) + ax.set_xticks(minor_ticks, minor=True) + + plt.xlim(2015, years[-1]) + + # -------- + # Labeling + # -------- + plt.ylabel("GW") + plt.xlabel("year") + plt.title("ED peak hour, y, all enduses, single regs") + + # Tight layout + plt.tight_layout() + plt.margins(x=0) + + # Save fig + fig.savefig(path_plot_fig) + plt.close() diff --git a/energy_demand/plotting/plotting_styles.py b/energy_demand/plotting/plotting_styles.py index 629ed15c..b642d293 100644 --- a/energy_demand/plotting/plotting_styles.py +++ b/energy_demand/plotting/plotting_styles.py @@ -7,7 +7,6 @@ def linestyles(): https://matplotlib.org/gallery/lines_bars_and_markers/linestyles.html """ - linestyles = OrderedDict( [ ('solid', (0, ())),