Skip to content

Commit

Permalink
add the possibility to calibrate spatial disaggregation on LAD level …
Browse files Browse the repository at this point in the history
…with electricity demand data
  • Loading branch information
Sven Eggimann committed Oct 4, 2018
1 parent 8fa6fca commit 95df0f5
Show file tree
Hide file tree
Showing 11 changed files with 247 additions and 93 deletions.
Binary file not shown.
84 changes: 42 additions & 42 deletions energy_demand/config_data/05-technologies/technology_definition.csv
@@ -1,48 +1,48 @@
technology,fueltype,efficiency in base year,efficiency in future year,year when efficiency is fully realised,diffusion method (sigmoid or linear),market_entry,technology type,maximum theoretical service share of technology,description
standard_lighting_bulb,electricity,0.029,0.034,2050,linear,2000,lighting,1,
halogen,electricity,0.037,0.073,2050,linear,2000,lighting,1,
energy_saving_lighting_bulb,electricity,0.220,0.293,2050,linear,2000,lighting,1,
fluorescent_strip_lighting,electricity,0.146,0.220,2050,linear,2000,lighting,1,
LED,electricity,0.220,0.439,2050,linear,2000,lighting,1,
washing_machine,electricity,1.000,1.334,2050,linear,2000,wet,1,
tumble_dryer,electricity,1.000,3.076,2050,linear,2000,wet,1,
dishwasher,electricity,1.000,1.367,2050,linear,2000,wet,1,
washer_dryer,electricity,1.000,1.334,2050,linear,2000,wet,1,
hob_gas,gas,0.400,0.500,2050,linear,2000,cooking,1,
hob_electricity,electricity,0.600,0.700,2050,linear,2000,cooking,1,
hob_induction_electricity,electricity,0.750,0.900,2050,linear,2000,cooking,1,
hob_hydrogen,hydrogen,0.400,0.500,2050,linear,2000,cooking,1,
hob_biomass,biomass,0.400,0.500,2050,linear,2000,cooking,1,
chest_freezer,electricity,1.000,2.709,2050,linear,2000,cold,1,
fridge_freezer,electricity,1.000,2.405,2050,linear,2000,cold,1,
refrigerator,electricity,1.000,2.408,2050,linear,2000,cold,1,
upright_freezer,electricity,1.000,2.500,2050,linear,2000,cold,1,
central_air_conditioner_electricity,electricity,1.000,2.000,2050,linear,2000,cooling_const,1,
decentral_air_conditioner_electricity,electricity,1.000,2.000,2050,linear,2000,cooling_const,1,
central_air_conditioner_oil,oil,1.000,2.000,2050,linear,2000,cooling_const,1,
decentral_air_conditioner_oil,oil,1.000,2.000,2050,linear,2000,cooling_const,1,
central_air_conditioner_gas,gas,1.000,2.000,2050,linear,2000,cooling_const,0.89,
decentral_air_conditioner_gas,gas,1.000,2.000,2050,linear,2000,cooling_const,0.89,
boiler_solid_fuel,solid_fuel,0.600,0.700,2050,linear,2000,heating_const,1,
boiler_gas,gas,0.650,0.940,2050,linear,2000,heating_const,0.89,
boiler_electricity,electricity,0.990,0.990,2050,linear,2000,heating_const,1,
boiler_oil,oil,0.700,0.940,2050,linear,2000,heating_const,1,
boiler_biomass,biomass,0.600,0.950,2050,linear,2000,heating_const,1,
boiler_hydrogen,hydrogen,0.850,0.950,2050,linear,2000,heating_const,0.89,
boiler_condensing_gas,gas,0.850,0.950,2050,linear,2000,heating_const,1,
boiler_condensing_oil,oil,0.850,0.950,2050,linear,2000,heating_const,1,
stirling_micro_CHP_gas,gas,0.800,0.950,2050,linear,2000,tech_CHP,0.89,
fuel_cell_hydrogen,hydrogen,0.850,0.950,2050,linear,2000,tech_CHP,0.89,
storage_heater_electricity,electricity,0.990,0.990,2050,linear,2000,storage_heating_electricity,1,
secondary_heater_electricity,electricity,0.990,0.990,2050,linear,2000,secondary_heating_electricity,1,
heat_pump_ASHP_electricity,electricity,3.600,4.000,2050,linear,2000,heating_non_const,1,
heat_pump_GSHP_electricity,electricity,4.900,5.400,2050,linear,2000,heating_non_const,1,
heat_pump_ASHP_hydrogen,hydrogen,3.600,4.000,2050,linear,2000,heating_non_const,0.89,
heat_pump_GSHP_hydrogen,hydrogen,4.900,5.400,2050,linear,2000,heating_non_const,0.89,
district_heating_CHP_gas,gas,0.450,0.450,2050,linear,2000,tech_CHP,0.2,thermal efficiency
district_heating_electricity,electricity,1.000,1.000,2050,linear,2000,tech_district_heating,0.2,
district_heating_biomass,biomass,0.600,0.600,2050,linear,2000,tech_district_heating,0.2,
district_heating_fuel_cell,hydrogen,0.850,0.850,2050,linear,2000,tech_district_heating,0.2,
energy_saving_lighting_bulb,electricity,0.22,0.293,2050,linear,2000,lighting,1,
fluorescent_strip_lighting,electricity,0.146,0.22,2050,linear,2000,lighting,1,
LED,electricity,0.22,0.439,2050,linear,2000,lighting,1,
washing_machine,electricity,1,1.334,2050,linear,2000,wet,1,
tumble_dryer,electricity,1,3.076,2050,linear,2000,wet,1,
dishwasher,electricity,1,1.367,2050,linear,2000,wet,1,
washer_dryer,electricity,1,1.334,2050,linear,2000,wet,1,
hob_gas,gas,0.4,0.5,2050,linear,2000,cooking,1,
hob_electricity,electricity,0.6,0.7,2050,linear,2000,cooking,1,
hob_induction_electricity,electricity,0.75,0.9,2050,linear,2000,cooking,1,
hob_hydrogen,hydrogen,0.4,0.5,2050,linear,2000,cooking,1,
hob_biomass,biomass,0.4,0.5,2050,linear,2000,cooking,1,
chest_freezer,electricity,1,2.709,2050,linear,2000,cold,1,
fridge_freezer,electricity,1,2.405,2050,linear,2000,cold,1,
refrigerator,electricity,1,2.408,2050,linear,2000,cold,1,
upright_freezer,electricity,1,2.5,2050,linear,2000,cold,1,
central_air_conditioner_electricity,electricity,1,2,2050,linear,2000,cooling_const,1,
decentral_air_conditioner_electricity,electricity,1,2,2050,linear,2000,cooling_const,1,
central_air_conditioner_oil,oil,1,2,2050,linear,2000,cooling_const,1,
decentral_air_conditioner_oil,oil,1,2,2050,linear,2000,cooling_const,1,
central_air_conditioner_gas,gas,1,2,2050,linear,2000,cooling_const,0.89,
decentral_air_conditioner_gas,gas,1,2,2050,linear,2000,cooling_const,0.89,
boiler_solid_fuel,solid_fuel,0.6,0.7,2050,linear,2000,heating_const,1,
boiler_gas,gas,0.65,0.94,2050,linear,2000,heating_const,0.89,
boiler_electricity,electricity,0.99,0.99,2050,linear,2000,heating_const,1,
boiler_oil,oil,0.7,0.94,2050,linear,2000,heating_const,1,
boiler_biomass,biomass,0.6,0.95,2050,linear,2000,heating_const,1,
boiler_hydrogen,hydrogen,0.85,0.95,2050,linear,2000,heating_const,0.89,
boiler_condensing_gas,gas,0.85,0.95,2050,linear,2000,heating_const,1,
boiler_condensing_oil,oil,0.85,0.95,2050,linear,2000,heating_const,1,
stirling_micro_CHP_gas,gas,0.8,0.95,2050,linear,2000,tech_CHP,0.89,
fuel_cell_hydrogen,hydrogen,0.85,0.95,2050,linear,2000,tech_CHP,0.89,
storage_heater_electricity,electricity,0.99,0.99,2050,linear,2000,storage_heating_electricity,1,
secondary_heater_electricity,electricity,0.99,0.99,2050,linear,2000,secondary_heating_electricity,1,
heat_pump_ASHP_electricity,electricity,3.6,4,2050,linear,2000,heating_non_const,1,
heat_pump_GSHP_electricity,electricity,4.9,5.4,2050,linear,2000,heating_non_const,1,
heat_pump_ASHP_hydrogen,hydrogen,3.6,4,2050,linear,2000,heating_non_const,0.89,
heat_pump_GSHP_hydrogen,hydrogen,4.9,5.4,2050,linear,2000,heating_non_const,0.89,
district_heating_CHP_gas,gas,0.45,0.45,2050,linear,2000,tech_CHP,0.2,thermal efficiency
district_heating_electricity,electricity,1,1,2050,linear,2000,tech_district_heating,0.2,
district_heating_biomass,biomass,0.6,0.6,2050,linear,2000,tech_district_heating,0.2,
district_heating_fuel_cell,hydrogen,0.85,0.85,2050,linear,2000,tech_district_heating,0.2,
basic_oxygen_furnace,solid_fuel,1,1,2050,linear,2010,steel_production,1,assumed no technology imporvement
electric_arc_furnace,electricity,6.1,6.1,2050,linear,2010,steel_production,1,assumed no technology imporvement
SNG_furnace,gas,1,1,2050,linear,2020,steel_production,1,assumed no technology imporvement
Expand Down
4 changes: 3 additions & 1 deletion energy_demand/main.py
Expand Up @@ -119,6 +119,7 @@ def energy_demand_model(
data['criterias'] = {}
data['criterias']['mode_constrained'] = True # True: Technologies are defined in ED model and fuel is provided, False: Heat is delievered not per technologies
data['criterias']['virtual_building_stock_criteria'] = True # True: Run virtual building stock model
data['criterias']['spatial_calibration'] = False

fast_model_run = False
if fast_model_run == True:
Expand Down Expand Up @@ -326,7 +327,8 @@ def energy_demand_model(
# ------------------------------------------------------------
# Disaggregate national energy demand to regional demands
# ------------------------------------------------------------
data['fuel_disagg'] = s_disaggregation.disaggr_demand(data)
data['fuel_disagg'] = s_disaggregation.disaggr_demand(
data, spatial_calibration=data['criterias']['spatial_calibration'])

# ------------------------------------------------------------
# Calculate spatial diffusion factors
Expand Down
59 changes: 59 additions & 0 deletions energy_demand/plotting/_scrap.py
@@ -1,5 +1,64 @@
"""Fig 2 figure
"""

import numpy as np


a = np.ones((3,3))

calc_lf_y(a)

def calc_lf_y(fuel_yh):
"""Calculate the yearly load factor for every fueltype
by dividing the yearly average load by the peak hourly
load in a year.
Arguments
---------
fuel_yh : array (fueltypes, 365, 24) or (fueltypes, 8760)
Yh fuel
Returns
-------
load_factor_y : array
Yearly load factors as percentage (100% = 100)
Note
-----
LECTRICAL AND PRODUCTION LOAD FACTORS
## WRONG Load factor = average load / maximum load in given time period
Load factor = average load / peak load # * meausred hours
https://en.wikipedia.org/wiki/Load_factor_(electrical)
https://circuitglobe.com/load-factor.html
"""
if fuel_yh.shape[1] == 365:
fuel_yh_8760 = fuel_yh.reshape(fuel_yh.shape[0], 8760)
else:
fuel_yh_8760 = fuel_yh

# Get total sum per fueltype
tot_load_y = np.sum(fuel_yh_8760, axis=1)

# Calculate maximum hour in every day of a year
max_load_h = np.max(fuel_yh_8760, axis=1)

# Caclualte yearly load factor for every fueltype
with np.errstate(divide='ignore', invalid='ignore'):
load_factor_y = tot_load_y / (max_load_h * 8760)
load_factor_y[np.isnan(load_factor_y)] = 0

return load_factor_y * 100










import numpy as np
import matplotlib.pyplot as plt
#from scipy.stats import mstats
Expand Down
12 changes: 5 additions & 7 deletions energy_demand/profiles/load_factors.py
Expand Up @@ -121,12 +121,9 @@ def calc_lf_y(fuel_yh):
Note
-----
LECTRICAL AND PRODUCTION LOAD FACTORS
## WRONG Load factor = average load / maximum load in given time period
Load factor = energy consumption (kWH) / peak demand (kW) * meausred hours
https://en.wikipedia.org/wiki/Load_factor_(electrical)
https://circuitglobe.com/load-factor.html
Load factor = average load / peak load
https://en.wikipedia.org/wiki/Load_factor_(electrical)
https://circuitglobe.com/load-factor.html
"""
if fuel_yh.shape[1] == 365:
fuel_yh_8760 = fuel_yh.reshape(fuel_yh.shape[0], 8760)
Expand All @@ -141,7 +138,8 @@ def calc_lf_y(fuel_yh):

# Caclualte yearly load factor for every fueltype
with np.errstate(divide='ignore', invalid='ignore'):
load_factor_y = tot_load_y / (max_load_h * 8760)
load_factor_y = (tot_load_y / 8760) / max_load_h

load_factor_y[np.isnan(load_factor_y)] = 0

return load_factor_y * 100
Expand Down
36 changes: 18 additions & 18 deletions energy_demand/read_write/data_loader.py
Expand Up @@ -306,7 +306,11 @@ def read_national_real_elec_data(path_to_csv):
for row in rows:
geocode = str.strip(row[read_data.get_position(headings, 'LA Code')])
tot_consumption_unclean = row[read_data.get_position(headings, 'Total consumption')].strip()
national_fuel_data[geocode] = float(tot_consumption_unclean.replace(",", ""))
try:
national_fuel_data[geocode] = float(tot_consumption_unclean.replace(",", ""))
except:
# no data provided
logging.debug("No validation data available for region %s", geocode)

return national_fuel_data

Expand Down Expand Up @@ -518,19 +522,15 @@ def get_local_paths(path):
'lad_shapefile': os.path.join(
path, '_raw_data', 'C_LAD_geography', 'same_as_pop_scenario', 'lad_2016_uk_simplified.shp'),
'path_post_installation_data': os.path.join(
path, '_processed_data', '_post_installation_data'),
'data_processed_disaggregated': os.path.join(
path, '_processed_data', '_post_installation_data', 'disaggregated'),
path, '_processed_data'),
'weather_data': os.path.join(
path, '_raw_data', 'A-temperature_data', 'cleaned_weather_stations_data'),
'load_profiles': os.path.join(
path, '_processed_data', '_post_installation_data', 'load_profiles'),
'dir_disaggregated': os.path.join(
path, '_processed_data', '_post_installation_data', 'disaggregated'),
path, '_processed_data', 'load_profiles'),
'rs_load_profile_txt': os.path.join(
path, '_processed_data', '_post_installation_data', 'load_profiles', 'rs_submodel'),
path, '_processed_data', 'load_profiles', 'rs_submodel'),
'ss_load_profile_txt': os.path.join(
path, '_processed_data', '_post_installation_data', 'load_profiles', 'ss_submodel'),
path, '_processed_data', 'load_profiles', 'ss_submodel'),
'yaml_parameters': os.path.join(
path, '..', 'config', 'yaml_parameters.yml'),
'yaml_parameters_constrained': os.path.join(
Expand Down Expand Up @@ -630,23 +630,23 @@ def load_paths(path):
path, '04-census_data', 'LAD_census_data.csv'),

# Validation datasets
'path_val_subnational_elec': os.path.join(
'val_subnational_elec': os.path.join(
path, '01-validation_datasets', '02_subnational_elec', 'data_2015_elec.csv'),
'path_val_subnational_elec_residential': os.path.join(
'val_subnational_elec_residential': os.path.join(
path, '01-validation_datasets', '02_subnational_elec', 'data_2015_elec_domestic.csv'),
'path_val_subnational_elec_non_residential': os.path.join(
'val_subnational_elec_non_residential': os.path.join(
path, '01-validation_datasets', '02_subnational_elec', 'data_2015_elec_non_domestic.csv'),
'path_val_subnational_elec_msoa_residential': os.path.join(
'val_subnational_elec_msoa_residential': os.path.join(
path, '01-validation_datasets', '02_subnational_elec', 'MSOA_domestic_electricity_2015_cleaned.csv'),
'path_val_subnational_elec_msoa_non_residential': os.path.join(
'val_subnational_elec_msoa_non_residential': os.path.join(
path, '01-validation_datasets', '02_subnational_elec', 'MSOA_non_dom_electricity_2015_cleaned.csv'),
'path_val_subnational_gas': os.path.join(
'val_subnational_gas': os.path.join(
path, '01-validation_datasets', '03_subnational_gas', 'data_2015_gas.csv'),
'path_val_subnational_gas_residential': os.path.join(
'val_subnational_gas_residential': os.path.join(
path, '01-validation_datasets', '03_subnational_gas', 'data_2015_gas_domestic.csv'),
'path_val_subnational_gas_non_residential': os.path.join(
'val_subnational_gas_non_residential': os.path.join(
path, '01-validation_datasets', '03_subnational_gas', 'data_2015_gas_non_domestic.csv'),
'path_val_nat_elec_data': os.path.join(
'val_nat_elec_data': os.path.join(
path, '01-validation_datasets', '01_national_elec_2015', 'elec_demand_2015.csv')}

return paths
Expand Down
10 changes: 1 addition & 9 deletions energy_demand/result_processing/multiple_scenarios.py
Expand Up @@ -43,15 +43,7 @@ def process_result_multi_scen(
"plot_radar": True,
"plot_radar_seasonal": True, # Plot radar spider charts
"plot_line_for_every_region_of_peak_demand": True,
"plot_lad_cross_graphs": True,

# NEW
#"plot_weather_day_year": False, #plot for a period (e.g. day) the hourly profile of all weather plots

# Specific figures
#"plot_figII_specific": False, #
#"plot_spatial_weather_var_peak": True #
}
"plot_lad_cross_graphs": True}

# Get all folders with scenario run results (name of folder is scenario)
scenarios = os.listdir(path_to_folder_with_scenarios)
Expand Down

0 comments on commit 95df0f5

Please sign in to comment.