Skip to content

Commit

Permalink
updated Proj package
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Eggimann committed Feb 5, 2019
1 parent 0ab27d8 commit 91df046
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 9 deletions.
5 changes: 2 additions & 3 deletions energy_demand/basic/basic_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,8 @@ def get_long_lat_decimal_degrees(reg_centroids):
"""
reg_coord = {}
for centroid in reg_centroids:

in_projection = Proj(init='epsg:27700') # OSGB_1936_British_National_Grid
put_projection = Proj(init='epsg:4326') # WGS 84 projection
in_projection = Proj(init="epsg:27700") # OSGB_1936_British_National_Grid
put_projection = Proj(init="epsg:4326") # WGS 84 projection

# Convert to decimal degrees
long_dd, lat_dd = transform(
Expand Down
15 changes: 9 additions & 6 deletions energy_demand/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def energy_demand_model(

data = {}
sim_yrs = [2015, 2020, 2025, 2030, 2035, 2040, 2045, 2050]
#sim_yrs = [2015, 2030, 2050]
sim_yrs = [2015, 2030, 2050]


if len(sys.argv) > 3: #user defined arguments are provide
Expand Down Expand Up @@ -160,6 +160,7 @@ def energy_demand_model(
# ----------------------------------------------------------------------
# Load data
# ----------------------------------------------------------------------
print("a " + str(name_region_set))
data['scenario_data'] = defaultdict(dict)
data['enduses'], data['sectors'], data['fuels'], lookup_enduses, lookup_sector_enduses = data_loader.load_fuels(data['paths'])
data['regions'] = read_data.get_region_names(name_region_set)
Expand Down Expand Up @@ -340,11 +341,6 @@ def energy_demand_model(
except:
service_switches = []

#print("ddddddddddd")
print(service_switches_raw)
print(service_switches)
#raise Exception("TTT")

fuel_switches = read_data.read_fuel_switches(os.path.join(path_strategy_vars, "switches_fuel.csv"), data['enduses'], data['assumptions'].fueltypes, data['assumptions'].technologies)
capacity_switches = read_data.read_capacity_switch(os.path.join(path_strategy_vars, "switches_capacity.csv"))

Expand Down Expand Up @@ -543,6 +539,13 @@ def energy_demand_model(
sim_obj.ed_fueltype_regs_yh,
'fueltype_reg_8760')

# Write only peak day for space and water heating
write_data.write_space_and_water_heating(
sim_yr,
data['weather_yr_result_paths']['data_results_model_run_results_txt'],
sim_obj.tot_fuel_y_enduse_specific_yh,
"out_enduse_specific")

# PLot only residential total regional annual demand and
'''write_data.write_residential_tot_demands(
sim_yr,
Expand Down
65 changes: 65 additions & 0 deletions energy_demand/read_write/write_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,71 @@ def write_residential_tot_demands(

np.save(path_file, tot_fuel_y_enduse_specific_yh)

def write_space_and_water_heating(
sim_yr,
path_result,
tot_fuel_y_enduse_specific_yh,
filename
):
"""Write out enduse specific results for every hour and store to
`.npy` file
Arguments
-----------
sim_yr : int
Simulation year
path_result : str
Path
tot_fuel_y_enduse_specific_yh : dict
Modelling results
filename : str
File name
"""
statistics_to_print = []
statistics_to_print.append("{}\t \t \t \t{}".format(
"Enduse", "total_annual_GWh"))

# Create folder for model simulation year
basic_functions.create_folder(path_result)

basic_functions.create_folder(
path_result, "enduse_specific_results")

for enduse, fuel in tot_fuel_y_enduse_specific_yh.items():
logging.info(" ... Enduse specific writing to file: %s Total demand: %s ", enduse, np.sum(fuel))

if enduse in [
'rs_space_heating',
'ss_space_heating',
'is_space_heating',
'rs_water_heating',
'ss_water_heating']:

path_file = os.path.join(
os.path.join(path_result, "enduse_specific_results"),
"{}__{}__{}{}".format(
filename,
enduse,
sim_yr,
".npy"))

np.save(path_file, fuel)

statistics_to_print.append("{}\t\t\t\t{}".format(
enduse, np.sum(fuel)))

# Create statistic files with sum of all end uses
path_file = os.path.join(
os.path.join(path_result, "enduse_specific_results"),
"{}__{}__{}".format(
"statistics_end_uses",
sim_yr,
".txt"))

write_list_to_txt(
path_file,
statistics_to_print)

def write_enduse_specific(
sim_yr,
path_result,
Expand Down

0 comments on commit 91df046

Please sign in to comment.