1
|
|
|
import pandas as pd |
2
|
|
|
from reegis import geometries as geo_reegis |
3
|
|
|
from deflex import geometries as geo_deflex |
4
|
|
|
from reegis import land_availability_glaes, demand_disaggregator |
5
|
|
|
from disaggregator import data |
6
|
|
|
|
7
|
|
|
def get_cost_emission_scenario_data(path_to_data): |
8
|
|
|
|
9
|
|
|
commodity_sources = dict.fromkeys({'StatusQuo', 'NEP2030', 'AllElectric', 'SynFuel'}) |
10
|
|
|
|
11
|
|
|
for n in commodity_sources.keys(): |
12
|
|
|
cost_data = pd.read_excel(path_to_data, n) |
13
|
|
|
cost_data.set_index('Unnamed: 0', drop=True, inplace=True) |
14
|
|
|
cost_data.drop(['costs', 'emission_cost', 'carbon_price'], inplace=True) |
15
|
|
|
commodity_sources[n] = cost_data |
16
|
|
|
|
17
|
|
|
return commodity_sources |
18
|
|
|
|
19
|
|
|
|
20
|
|
|
def return_normalized_domestic_profiles(regions, df): |
21
|
|
|
|
22
|
|
|
test = df.groupby(level=[0,2], axis=1).sum() |
23
|
|
|
profile_domestic = pd.DataFrame(index=test.index, columns=regions.index[0:18] ) |
24
|
|
|
|
25
|
|
|
for reg in regions.index[0:18]: |
26
|
|
|
profile_domestic[reg] = test[reg]["domestic"] + test[reg]["retail"] |
27
|
|
|
|
28
|
|
|
profile_domestic = profile_domestic.div(profile_domestic.sum()) |
29
|
|
|
|
30
|
|
|
return profile_domestic |
31
|
|
|
|
32
|
|
|
|
33
|
|
|
def return_normalized_industrial_profiles(regions,df): |
34
|
|
|
|
35
|
|
|
test = df.groupby(level=[0, 2], axis=1).sum() |
36
|
|
|
profile_domestic = pd.DataFrame(index=test.index, columns=regions.index[0:18]) |
37
|
|
|
|
38
|
|
|
for reg in regions.index[0:18]: |
39
|
|
|
profile_domestic[reg] = test[reg]["industrial"] |
40
|
|
|
|
41
|
|
|
profile_industrial = profile_domestic.div(profile_domestic.sum()) |
42
|
|
|
|
43
|
|
|
return profile_industrial |
44
|
|
|
|
45
|
|
|
|
46
|
|
|
def transform_NEP_capacities_to_de21(path_to_NEP_capacities): |
47
|
|
|
de21 = geo_deflex.deflex_regions(rmap='de21') |
48
|
|
|
fed_states = geo_reegis.get_federal_states_polygon() |
49
|
|
|
nuts3_index = data.database_shapes().index |
50
|
|
|
|
51
|
|
|
# Load NEP capacities |
52
|
|
|
NEP2030_capacity = pd.read_excel(path_to_NEP_capacities) |
53
|
|
|
NEP2030_capacity.set_index('fedstate', drop=True, inplace=True) |
54
|
|
|
NEP2030_capacity = NEP2030_capacity.multiply(1e3) |
55
|
|
|
|
56
|
|
|
#Fetch GLAES RES capacities and compare to NEP data |
57
|
|
|
glaes_capacity = land_availability_glaes.aggregate_capacity_by_region(fed_states) |
58
|
|
|
compare_RES = pd.concat([glaes_capacity, NEP2030_capacity['onshore'], NEP2030_capacity['offshore'], |
59
|
|
|
NEP2030_capacity['solar pv']], axis=1) |
60
|
|
|
|
61
|
|
|
compare_RES.drop(['N0', 'N1', 'O0', 'P0'], axis=0, inplace=True) |
62
|
|
|
|
63
|
|
|
scaling_wind = compare_RES['onshore'] / compare_RES['P_wind'] |
64
|
|
|
scaling_pv = compare_RES['solar pv'] / compare_RES['P_pv'] |
65
|
|
|
|
66
|
|
|
mapped_nuts = demand_disaggregator.get_nutslist_for_regions(fed_states) |
67
|
|
|
res_capacity_nuts3 = land_availability_glaes.get_pv_wind_capacity_potential_by_nuts3() |
68
|
|
|
|
69
|
|
|
# Zuordnung der installierten Leistungen zu den jeweiligen Landkreisen |
70
|
|
|
P_NEP_nuts3 = pd.DataFrame(index=nuts3_index, columns=['onshore', 'pv']) |
71
|
|
|
|
72
|
|
|
for zone in compare_RES.index: |
73
|
|
|
region_pick = mapped_nuts.loc[zone] |
74
|
|
|
for nuts3 in region_pick.iloc[0]: |
75
|
|
|
P_NEP_nuts3.loc[nuts3]['onshore'] = res_capacity_nuts3['P_wind'][nuts3] * scaling_wind[zone] |
76
|
|
|
P_NEP_nuts3.loc[nuts3]['pv'] = res_capacity_nuts3['P_pv'][nuts3] * scaling_pv[zone] |
77
|
|
|
|
78
|
|
|
NEP_capacity_de21 = pd.DataFrame( |
79
|
|
|
index=de21.index, columns=["P_wind", "P_pv"] |
80
|
|
|
) |
81
|
|
|
nuts3_list_de21 = demand_disaggregator.get_nutslist_for_regions(de21) |
82
|
|
|
|
83
|
|
|
for zone in de21.index: |
84
|
|
|
idx = nuts3_list_de21.loc[zone]["nuts"] |
85
|
|
|
NEP_capacity_de21.loc[zone]["P_wind"] = P_NEP_nuts3["onshore"][idx].sum() |
86
|
|
|
NEP_capacity_de21.loc[zone]["P_pv"] = P_NEP_nuts3["pv"][idx].sum() |
87
|
|
|
|
88
|
|
|
return NEP_capacity_de21 |
89
|
|
|
|