Skip to content

Commit

Permalink
before removing shape_peak_yd_factor
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Eggimann authored and Sven Eggimann committed Jun 1, 2018
1 parent 1d97b23 commit 4e896f9
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 42 deletions.
1 change: 0 additions & 1 deletion energy_demand/enduse_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -1609,7 +1609,6 @@ def industry_enduse_changes(
Info
----
OLD MODEL TODO
"""
factor = 1

Expand Down
2 changes: 1 addition & 1 deletion energy_demand/plotting/plotting_multiple_scenarios.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ def plot_heat_pump_chart(
# -----

# Criteria to plot maximum boundaries
plot_max_min_polygon = False #TODO
plot_max_min_polygon = False
plot_all_regs = False

# Set figure size
Expand Down
11 changes: 5 additions & 6 deletions energy_demand/plotting/result_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -810,12 +810,11 @@ def create_geopanda_files(
if np.sum(results_container['results_every_year'][base_year][fueltype]) == 0:
continue

# TODO Check if 'nan' entry or total sum is 0. (Remove as soon as nan error is removed)
if np.isnan(np.sum(results_container['results_every_year'][base_year][fueltype])):
logging.info("Error: Contains nan entry {} {}".format(year, fueltype))
continue
logging.info("============ {} {}".format(fueltype, np.isnan(np.sum(results_container['results_every_year'][base_year][fueltype]))))
logging.info(results_container['results_every_year'][base_year][fueltype])
##if np.isnan(np.sum(results_container['results_every_year'][base_year][fueltype])):
# logging.info("Error: Contains nan entry {} {}".format(year, fueltype))
# continue
#logging.info("============ {} {}".format(fueltype, np.isnan(np.sum(results_container['results_every_year'][base_year][fueltype]))))
#logging.info(results_container['results_every_year'][base_year][fueltype])
fueltype_str = tech_related.get_fueltype_str(fueltypes, fueltype)

# Calculate peak h across all regions
Expand Down
2 changes: 1 addition & 1 deletion energy_demand/processing/scenario_charts.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def process_scenarios(path_to_scenarios, year_to_model=2015):
# Generate plot with heat pump ranges
# -------------------------------
if heat_pump_range_plot:
#TODO WRITE THAT FROM SEVERAL FOLDERS CAN BE GENERATED (i.e. different scenario)

plotting_multiple_scenarios.plot_heat_pump_chart(
lookups,
regions,
Expand Down
2 changes: 1 addition & 1 deletion energy_demand/read_write/read_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def read_in_results(path_runs, seasons, model_yeardays_daytype):

fueltype_str = tech_related.get_fueltype_str(lookups['fueltypes'], fueltype_int)

# Calculate peak per fueltype for all regions (reg_ed_yh= np.array(fueltype, reg, yh)) TODO CHECK
# Calculate peak per fueltype for all regions (reg_ed_yh= np.array(fueltype, reg, yh))
all_regs_yh = np.sum(reg_ed_yh, axis=0) # sum regs
peak_h = np.max(all_regs_yh) # select max of 8760 h
results_container['ed_peak_h'][year][fueltype_str] = peak_h
Expand Down
12 changes: 11 additions & 1 deletion energy_demand/scripts/init_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,17 @@ def global_to_reg_capacity_switch(
"""Conversion of global capacity switch installations
to regional installation
TODO
Arguments
---------
regions : list
Regions
global_capactiy_switch : float
Global switch
spatial_factors : dict
Returns
-------
"""
reg_capacity_switch = {}
for reg in regions:
Expand Down
2 changes: 1 addition & 1 deletion energy_demand/technologies/fuel_service_switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ def autocomplete_switches(
enduse_switches.append(switch_new)
switch_yr = switch.switch_yr

# Create switch TODO TODO SHIFTED ONE TAB CHECK 03.05.2018
# Create switch
switches_new = create_switches_from_s_shares(
enduse=enduse,
s_tech_by_p=s_tech_by_p,
Expand Down
8 changes: 3 additions & 5 deletions energy_demand/validation/lad_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def spatial_validation_lad_level(
logging.info("comparison real: {} modelled: {}".format(100, (100 / tot_sum_real_gas) * tot_sum_modelled_gas))
#'''
# ----------------------------------------------
# TODO Correct REAL Values that sum is the same
# Correct REAL Values that sum is the same
# ----------------------------------------------
data_inputlist = [
(fuel_elec_residential_regs_yh, subnational_elec_residential), # domestic
Expand Down Expand Up @@ -323,7 +323,7 @@ def spatial_validation_lad_level(
os.path.join(result_paths['data_results_validation'], 'validation_spatial_residential_gas.pdf'),
label_points=True,
plotshow=plot_crit)

logging.info("... ================= Validaiton of non residential gas")
spatial_validation(
reg_coord,
Expand Down Expand Up @@ -361,7 +361,7 @@ def temporal_validation_lad(
logging.info("... temporal validation")

# -------------------------------------------
# Spatial validation after calculations TODO REMOVE SPATIAL
# Spatial validation after calculations
# -------------------------------------------
subnational_elec = data_loader.read_national_real_elec_data(
paths['path_val_subnational_elec'])
Expand Down Expand Up @@ -580,9 +580,7 @@ def spatial_validation(
try:
real = result_dict['real_demand'][reg_geocode]
modelled = result_dict['modelled_demand'][reg_geocode]
#diff_real_modelled_p.append((100 / real) * modelled)
diff_real_modelled_p.append(abs(100 - ((100 / real) * modelled)))
#logging.info("Absolute difference in percentage {}".format(abs(100 - ((100 / real) * modelled)))) #TODO
diff_real_modelled_abs.append(real - modelled)
except KeyError:
pass
Expand Down
41 changes: 21 additions & 20 deletions tests/scripts/test_s_disaggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import numpy as np
from energy_demand.scripts import s_disaggregation
from energy_demand.assumptions import non_param_assumptions
'''
#'''
def test_rs_disaggregate():
"""testing
"""
Expand All @@ -23,9 +23,9 @@ def test_rs_disaggregate():
'sig_midpoint': 0,
'sig_steepness': 1,
'yr_until_changed': 2020},
'strategy_variables': {'rs_t_base_heating_future_yr': {'scenario_value': 0}}}
'strategy_variables': {'rs_t_base_heating_future_yr': {'scenario_value': 15}}}
assumptions = non_param_assumptions.DummyClass(assumptions)
assumptions.__setattr__('t_bases', non_param_assumptions.DummyClass({'rs_t_heating_by': 0}))
assumptions.__setattr__('t_bases', non_param_assumptions.DummyClass({'rs_t_heating_by': 15}))

reg_coord = {
'regA': {'longitude': 0,'latitude': 0},
Expand Down Expand Up @@ -68,23 +68,20 @@ def test_rs_disaggregate():

assert result['regA']['rs_space_heating'] == national_fuel / 2

test_rs_disaggregate() #TODO FIX
'''
#TODO TODO FIX
'''def test_ss_disaggregate():
def test_ss_disaggregate():
"""testing
"""
regions = ['regA', 'regB']
national_fuel = 100
raw_fuel_sectors_enduses = {'ss_space_heating': {'sectorA': national_fuel}}
raw_fuel_sectors_enduses = {'ss_space_heating': {'offices': national_fuel}}

scenario_data = {
'population': {2015: {'regA': 10, 'regB': 10}},
'floor_area': {
'ss_floorarea_newcastle': {
2015: {'regA': 10, 'regB': 10}},
'ss_floorarea' :{
2015: {'regA': {'sectorA': 100}, 'regB': {'sectorA': 100}}}
2015: {'regA': {'offices': 100}, 'regB': {'offices': 100}}}
},
}

Expand All @@ -95,25 +92,31 @@ def test_rs_disaggregate():
'sig_midpoint': 0,
'sig_steepness': 1,
'yr_until_changed': 2020},
'strategy_variables': {'ss_t_base_heating_future_yr': {'scenario_value': 0}, 'ss_t_base_cooling_future_yr': {'scenario_value': 0}}}
'strategy_variables': {
'ss_t_base_heating_future_yr': {'scenario_value': 15},
'ss_t_base_cooling_future_yr': {'scenario_value': 20}}}

assumptions = non_param_assumptions.DummyClass(assumptions)
assumptions.__setattr__('t_bases', non_param_assumptions.DummyClass({'ss_t_heating_by': 0, 'ss_t_cooling_by': 0}))
assumptions.__setattr__('t_bases', non_param_assumptions.DummyClass(
{'ss_t_heating_by': 15, 'ss_t_cooling_by': 20}))

reg_coord = {
'regA': {'longitude': 0,'latitude': 0},
'regB': {'longitude': 0,'latitude': 0}}
'regA': {'longitude': 0, 'latitude': 0},
'regB': {'longitude': 0, 'latitude': 0}}

weather_stations = {
'stationID_1': {'station_longitude': 1,'station_latitude': 1}}

temp_data = {'stationID_1': np.ones((365, 24)) + 10}

enduses = ['ss_space_heating']
sectors = ['sectorA']
all_sectors = ['sectorA']
sectors = ['offices']
all_sectors = ['offices']

service_building_count = None
service_building_count = {}
service_building_count[9] = {}
service_building_count[9]['regA'] = 10
service_building_count[9]['regB'] = 10

result = s_disaggregation.ss_disaggregate(
raw_fuel_sectors_enduses,
Expand All @@ -131,8 +134,8 @@ def test_rs_disaggregate():
crit_limited_disagg_pop=True,
crit_full_disagg=False)

assert result['regA']['ss_space_heating']['sectorA'] == national_fuel / 2
'''
assert result['regA']['ss_space_heating']['offices'] == national_fuel / 2
test_ss_disaggregate()
def test_is_disaggregate():
"""TESTING"""
temp_data = {'stationID_1': np.ones((365, 24)) + 10}
Expand Down Expand Up @@ -209,5 +212,3 @@ def test_is_disaggregate():
assert round(result['regA']['is_space_heating']['pharmaceuticals'], 3) == round(10.0/15.0 * 100,3)
assert result['regB']['is_space_heating']['mining'] == 100
assert round(result['regB']['is_space_heating']['pharmaceuticals'], 3) == round(5.0/15.0 * 100, 3)

test_is_disaggregate()
7 changes: 2 additions & 5 deletions tests/test_enduse_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ def test_enduse():
criterias='test',
strategy_variables='test',
fueltypes_nr='test',
fueltypes='test',
model_yeardays_nrs='test')
fueltypes='test')

assert out.flat_profile_crit == True

Expand Down Expand Up @@ -621,8 +620,7 @@ def test_calc_fuel_tech_yh():
load_profiles=lp_stock_obj,
fueltypes_nr=2,
fueltypes=fueltypes,
mode_constrained=False,
model_yeardays_nrs=365)
mode_constrained=False)

assert results[1][3][0] == 3.0 / float(np.sum(range(365)) * 24) * 200

Expand All @@ -635,7 +633,6 @@ def test_calc_fuel_tech_yh():
load_profiles=lp_stock_obj,
fueltypes_nr=2,
fueltypes=fueltypes,
model_yeardays_nrs=365,
mode_constrained=True)

assert results['techA'][3][0] == 3.0 / float(np.sum(range(365)) * 24) * 200
Expand Down

0 comments on commit 4e896f9

Please sign in to comment.