-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprepare_input_data_for_deflex_scenario_basic.py
78 lines (55 loc) · 3.55 KB
/
prepare_input_data_for_deflex_scenario_basic.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
from disaggregator import data, config, spatial
from deflex import geometries as geo_deflex
from reegis import geometries as geo_reegis
import integrate_demandregio, Land_Availability_GLAES
import pandas as pd
import os
#data.cfg['base_year'] = 2015
nuts3_regions = list(config.dict_region_code(keys='natcode_nuts3', values='name').keys())
nuts3_regions[0:2]=[]
# Fetch electricity consumption for all NUTS3-Regions
elc_consumption = integrate_demandregio.get_demandregio_electricity_consumption_by_nuts3(2015, nuts3_regions)
# Fetch heat consumption for all NUTS3-Regions
heat_consumption = integrate_demandregio.get_combined_heatload_for_region(2015, nuts3_regions)
# Load suitable PV/Wind-areas from csv
#filename = os.getcwd() + '/GLAES_Eignungsflaechen_Wind_PV.csv'
#suitable_area = pd.read_csv(filename)
#suitable_area.set_index('nuts3', drop=True, inplace=True)
# Alternatively if no precalculation is available:
path = os.getcwd() + '/nuts3_geojson/'
suitable_area = Land_Availability_GLAES.get_pv_wind_areas_by_nuts3(path, create_geojson=True)
# Define installable capacity per square meter in MW
p_per_qm_wind = 8 / 1e6 # 8 W/m² Fläche
p_per_qm_pv = 200 / 1e6 # 200 W/m² Fläche -> eta=20%
# Calculate maximum installable capacity for onshore wind and rooftop-PV
P_max_wind = suitable_area['wind_area'] * p_per_qm_wind
P_max_pv = suitable_area['pv_area'] * p_per_qm_pv
# Load NUTS3-mixed-COPS
nuts3_cops = pd.read_csv('/home/dbeier/Daten/COP_NUTS3.csv')
nuts3_cops.drop('Unnamed: 0', axis='columns', inplace=True)
nuts3_cops.set_index(pd.date_range('1/1/2014', periods=8760, freq='H'), inplace=True)
# Get indices for zones of interest
de22_list = geo_deflex.deflex_regions(rmap='de22', rtype='polygons').index
de17_list = geo_reegis.get_federal_states_polygon().index
# Aggregate values for de17 and de22 regions to prepare for
# Create empty Dataframes
dflx_input = pd.DataFrame(index=de22_list, columns = ['power','lt-heat','ht-heat','P_wind', 'P_pv'])
dflx_input_fedstates = pd.DataFrame(index=de17_list, columns = ['power','lt-heat','ht-heat','P_wind', 'P_pv'])
dflx_cop_de17_heat = pd.DataFrame(index=pd.date_range('1/1/2014', periods=8760, freq='H'), columns=de17_list)
dflx_cop_de22_heat = pd.DataFrame(index=pd.date_range('1/1/2014', periods=8760, freq='H'), columns=de22_list)
for zone in de22_list:
region_pick = integrate_demandregio.get_nutslist_per_zone(region_sel=zone, zones='de22')
dflx_input.loc[zone]['power'] = elc_consumption.sum(axis=1)[region_pick].sum()
dflx_input.loc[zone]['lt-heat'] = (heat_consumption['Households']+heat_consumption['CTS']+heat_consumption['Industry'])[region_pick].sum()
dflx_input.loc[zone]['ht-heat'] = heat_consumption['ProcessHeat'][region_pick].sum()
dflx_input.loc[zone]['P_wind'] = P_max_wind[region_pick].sum()
dflx_input.loc[zone]['P_pv'] = P_max_pv[region_pick].sum()
dflx_cop_de22_heat[zone] = nuts3_cops[region_pick].mean(axis=1)
for zone in de17_list:
region_pick = integrate_demandregio.get_nutslist_per_zone(region_sel=zone, zones='fed_states')
dflx_input_fedstates.loc[zone]['power'] = elc_consumption.sum(axis=1)[region_pick].sum()
dflx_input_fedstates.loc[zone]['lt-heat'] = (heat_consumption['Households']+heat_consumption['CTS']+heat_consumption['Industry'])[region_pick].sum()
dflx_input_fedstates.loc[zone]['ht-heat'] = heat_consumption['ProcessHeat'][region_pick].sum()
dflx_input_fedstates.loc[zone]['P_wind'] = P_max_wind[region_pick].sum()
dflx_input_fedstates.loc[zone]['P_pv'] = P_max_pv[region_pick].sum()
dflx_cop_de17_heat[zone] = nuts3_cops[region_pick].mean(axis=1)