Skip to content

Commit

Permalink
fixed generator
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Eggimann committed Feb 26, 2019
1 parent 45524c8 commit 0ca72f6
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 22 deletions.
11 changes: 5 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,14 @@ More information on the model can be found in:

1. Download input data
-------------------------------------
Most data for running HIRE are freely available online. However,
for certain input data it is necessary to request access (for more information
on all necessary input datasets see `here <https://ed.readthedocs.io/en/latest/documentation.html#data-sets>`_)
Most data for running HIRE are freely available online. For some input data it is necessary to request access.
For more information on all necessary input datasets see `here <https://ed.readthedocs.io/en/latest/documentation.html#data-sets>`_)

All necessary input data to run HIRE can be downloaded (`here <http://dx.doi.org/10.17632/wc8pxynv7b.1>`_), where
for the restricted datasets a dummy input dataset is available.
All necessary input data to run HIRE can be downloaded (`here <TODO_DATA_LINK>`_), where
for the restricted datasets a dummy input dataset is used instead.

For data inquires, plese contact sven.eggimann@ouce.ox.ac.uk or `the consortium <https://www.itrc.org.uk/contact-us/>`_).
Also check whether data area available `here <https://www.nismod.ac.uk>`_).
Also check whether data area available `here <https://www.nismod.ac.uk>`_.

2. Initialising and running the model (local)
-------------------------------------
Expand Down
5 changes: 2 additions & 3 deletions energy_demand/basic/demand_supply_interaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ def constrained_results(
# ----------------------------------------
for submodel_nr, submodel in enumerate(submodels_names):
for tech, fuel_tech in results_constrained.items():

# ----
# Technological simplifications because of different technology definition
# and because not all technologies are used in supply model
Expand All @@ -96,7 +95,7 @@ def constrained_results(
pass #Do not add non_heating demand for fueltype heat
else:
key_name = "{}_{}_{}".format(submodel, fueltype_str, "non_heating")
logging.info("key_name d: " + str(key_name))

# Add fuel for all regions for specific fueltype
supply_results[key_name] = non_heating_ed[submodel_nr][:, fueltype_int, :]

Expand All @@ -105,7 +104,7 @@ def constrained_results(
# --------------------------------------------
for key_name, values in supply_results.items():
if testing_functions.test_if_minus_value_in_array(values):
logging.info("info: {} {}".format(values, np.sum(values)))
logging.info("info tt: {} {}".format(values, np.sum(values)))
raise Exception("Error d: Negative entry in results " + str(key_name))

logging.info("... Prepared results for energy supply model in constrained mode")
Expand Down
14 changes: 6 additions & 8 deletions energy_demand/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ def __init__(
# Aggregate results specifically over regions
# ---------------------------------------------
aggr_results = aggregate_results_constrained(
assumptions,
assumptions.reg_nrs,
assumptions.lookup_enduses,
aggr_results,
Expand All @@ -136,9 +135,6 @@ def __init__(
assumptions.fueltypes_nr,
assumptions.enduse_space_heating,
assumptions.technologies)

#print("_all_closest_weather_stations")
#print(_all_closest_weather_stations)

# ---------------------------------------------------
# Aggregate results for all regions
Expand Down Expand Up @@ -774,7 +770,6 @@ def aggregate_result_unconstrained(
return constrained_array

def aggregate_results_constrained(
assumptions,
reg_nrs,
lookup_enduses,
aggr_results,
Expand Down Expand Up @@ -817,6 +812,9 @@ def aggregate_results_constrained(
aggr_results : dict
Contains all aggregated results
"""
#Convert generator into list #TODO TOM
all_submodels = list(all_submodels)

aggr_results['ed_submodel_enduse_fueltype_regs_yh'] = aggr_complete_result(
aggr_results['ed_submodel_enduse_fueltype_regs_yh'],
lookup_enduses,
Expand Down Expand Up @@ -846,7 +844,6 @@ def aggregate_results_constrained(

# Iterate technologies and get fuel per technology
for heating_tech in heating_techs:

tech_fuel = techs_fueltypes_yh[heating_tech] # Fuel of technology
fueltype_tech_int = technologies[heating_tech].fueltype_int # Fueltype of technology

Expand All @@ -855,8 +852,9 @@ def aggregate_results_constrained(
aggr_results['results_constrained'][heating_tech][submodel_nr][reg_array_nr][fueltype_tech_int] += tech_fuel.reshape(8760)
else:
# TODO query this - are we overwriting otherwise
if heating_tech not in aggr_results['results_constrained']:
aggr_results['results_constrained'][heating_tech] = np.zeros((len(submodel_to_idx), reg_nrs, fueltypes_nr, 8760), dtype="float")
#if heating_tech not in aggr_results['results_constrained']:
# aggr_results['results_constrained'][heating_tech] = np.zeros((len(submodel_to_idx), reg_nrs, fueltypes_nr, 8760), dtype="float")
aggr_results['results_constrained'][heating_tech] = np.zeros((len(submodel_to_idx), reg_nrs, fueltypes_nr, 8760), dtype="float")
aggr_results['results_constrained'][heating_tech][submodel_nr][reg_array_nr][fueltype_tech_int] += tech_fuel.reshape(8760)

return aggr_results
Expand Down
7 changes: 3 additions & 4 deletions energy_demand/scripts/init_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,7 @@ def switch_calculations(
for enduse in data['enduses'][submodel_name]:
for sector in data['sectors'][submodel_name]:
print("... calculating fuel switches {} {} {}".format(submodel_name, enduse, sector))
print("======d======= " + str(data['assumptions'].fuel_tech_p_by[enduse][sector]))
#print("Z " + str(s_fueltype_by_p[sector][enduse]))

diffusion_param_tech[enduse][sector] = sig_param_calc_incl_fuel_switch(
narrative_timesteps,
data['assumptions'].base_yr,
Expand Down Expand Up @@ -277,7 +276,7 @@ def switch_calculations(
for region in annual_tech_diff_params:
for enduse in annual_tech_diff_params[region]:
for sector in annual_tech_diff_params[region][enduse]:
#print("TTI: {} {} {}".format(enduse, sector, annual_tech_diff_params[region][enduse][sector]))

for year in sim_yrs:
if annual_tech_diff_params[region][enduse][sector] != []:
assigned_service_p = 0
Expand Down Expand Up @@ -770,7 +769,7 @@ def sig_param_calc_incl_fuel_switch(
# Calculates parameters for sigmoid diffusion of
# technologies which are switched to/installed.
# -----------------------------------------------
print("---------- switches %s %s %s", enduse, crit_switch_service, crit_fuel_switch)
#print("---------- switches %s %s %s", enduse, crit_switch_service, crit_fuel_switch)
if crit_all_the_same:
print("... calc parameters of `{}` for year `{}` {}".format(enduse, switch_yr, sector))
sig_param_tech_all_regs_value = s_generate_sigmoid.tech_sigmoid_parameters(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,4 +177,4 @@ def package_data(
"""
# Map command line arguments to function arguments.
#package_data(*sys.argv[1:])
package_data('v_082', 'C:/Users/cenv0553/ED/data')
package_data('v_083', 'C:/Users/cenv0553/ED/data')

0 comments on commit 0ca72f6

Please sign in to comment.