Skip to content

Commit

Permalink
fixed reording of multiple val
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Eggimann committed Oct 12, 2018
1 parent b21001e commit dd043da
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions energy_demand/basic/date_prop.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
Contains funtions related to handeling date and
time related functionality
"""
import numpy as np
from datetime import date
from datetime import timedelta
import numpy as np

from energy_demand.basic import basic_functions

def convert_h_to_day_year_and_h(hour):
Expand Down Expand Up @@ -46,7 +47,6 @@ def get_seasonal_weeks():
autumn_week = list(range(
date_prop.date_to_yearday(year_to_model, 10, 12),
date_prop.date_to_yearday(year_to_model, 10, 26))) #Oct'''

winter_week = list(range(
date_to_yearday(2015, 1, 12), date_to_yearday(2015, 1, 19))) #Jan
spring_week = list(range(
Expand Down
2 changes: 1 addition & 1 deletion energy_demand/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ def energy_demand_model(
# Main model run function
# -----------------------
for sim_yr in data['assumptions'].simulated_yrs:
print("Loal simulation for year: " + str(sim_yr), flush=True)
print("Local simulation for year: " + str(sim_yr), flush=True)

# Set current year
setattr(data['assumptions'], 'curr_yr', sim_yr)
Expand Down
8 changes: 1 addition & 7 deletions energy_demand/plotting/fig_spatial_distribution_of_peak.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@
from energy_demand.basic import date_prop
from energy_demand.basic import basic_functions
from energy_demand.basic import lookup_tables
from energy_demand.basic import basic_functions
from energy_demand.basic import conversions
from energy_demand.technologies import tech_related
from energy_demand.plotting import basic_plot_functions
from energy_demand.read_write import write_data
from energy_demand.plotting import result_mapping
from energy_demand.plotting import fig_p2_weather_val

Expand Down Expand Up @@ -86,11 +83,8 @@ def run(
# Calculate hour with national peak demand
# This may be different depending on the weather yr
# ---------------------------------------------------
print("sstr")
print(results_container['ed_fueltype_regs_yh'][simulation_yr][fueltype_int].shape)
sum_all_regs_fueltype_8760 = np.sum(results_container['ed_fueltype_regs_yh'][simulation_yr][fueltype_int], axis=0) # Sum for every hour
print("sum_all_regs_fueltype_8760")
print(sum_all_regs_fueltype_8760.shape)

max_day = int(basic_functions.round_down((np.argmax(sum_all_regs_fueltype_8760) / 24), 1))
max_h = np.argmax(sum_all_regs_fueltype_8760)

Expand Down
6 changes: 4 additions & 2 deletions energy_demand/plotting/figs_p2.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ def plot_fig_spatio_temporal_validation(
weather_yr_station_tot_fueltype_yh = defaultdict(dict)
residential_results = defaultdict(dict)
for scenario_folder in all_result_folders:
print("Scenario folder: " + str(scenario_folder))
result_folders = os.listdir(os.path.join(path_regional_calculations, scenario_folder))
for result_folder in result_folders:
try:
Expand Down Expand Up @@ -236,7 +235,10 @@ def plot_fig_spatio_temporal_validation(
# Compare regional and non regional and actual demand over time
# *****************************************************************
simulation_yr_to_plot = 2015
period_to_plot = list(range(0, 8760))
period_to_plot = list(range(0, 8760)) #TODO PLANE
winter_week, _, _, _ = date_prop.get_seasonal_weeks()
period_to_plot = winter_week

fig_p2_temporal_validation.run(
data_input=data_container['tot_fueltype_yh'],
weather_yr=2015,
Expand Down
1 change: 1 addition & 0 deletions energy_demand/scripts/batch_commands_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def my_function(simulation_number):
weather_yrs = list(weather_yrs_stations.keys())
print("all weather yrs: " + str(weather_yrs))
print("Total nr of stations: " + str(len(weather_yrs)))

if same_weather_yr:
weather_yr = defined_weather_yr
else:
Expand Down
17 changes: 10 additions & 7 deletions energy_demand/validation/lad_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,15 @@ def spatial_validation_multiple(
y_real_demand = []
y_modelled_demand = []

for reg_geocode in regions:
# -----------------
# Sort results according to size
# -----------------
sorted_dict_real = sorted(
result_dict['real_demand'].items(),
key=operator.itemgetter(1))

#for reg_geocode in regions:
for reg_geocode, _ in sorted_dict_real:
# Test if real and modelled data are both available
try:
real = result_dict['real_demand'][reg_geocode]
Expand All @@ -811,12 +819,7 @@ def spatial_validation_multiple(
std_dev_p = np.std(diff_real_modelled_p) # Given as percent
std_dev_abs = np.std(diff_real_modelled_abs) # Given as energy unit

# -----------------
# Sort results according to size
# -----------------
sorted_dict_real = sorted(
result_dict['real_demand'].items(),
key=operator.itemgetter(1))


x_values = np.arange(0, len(y_real_demand), 1)

Expand Down

0 comments on commit dd043da

Please sign in to comment.