Skip to content

Commit

Permalink
before looking into hybrid again
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Eggimann committed Apr 10, 2018
1 parent eed915a commit c42f61a
Show file tree
Hide file tree
Showing 5 changed files with 142 additions and 5 deletions.
1 change: 0 additions & 1 deletion 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
12 changes: 9 additions & 3 deletions energy_demand/enduse_func.py
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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
# ------------------------------
Expand All @@ -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

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions energy_demand/main.py
Expand Up @@ -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
Expand Down
130 changes: 130 additions & 0 deletions energy_demand/plotting/plotting_results.py
Expand Up @@ -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
# ----------
Expand All @@ -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
Expand Down Expand Up @@ -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()
1 change: 0 additions & 1 deletion energy_demand/plotting/plotting_styles.py
Expand Up @@ -7,7 +7,6 @@ def linestyles():
https://matplotlib.org/gallery/lines_bars_and_markers/linestyles.html
"""

linestyles = OrderedDict(
[
('solid', (0, ())),
Expand Down

0 comments on commit c42f61a

Please sign in to comment.