1
|
|
|
# coding: utf-8 |
2
|
|
|
import datetime |
3
|
|
|
import json |
4
|
|
|
|
5
|
|
|
from geoalchemy2.types import Geometry |
6
|
|
|
from shapely.geometry import LineString |
7
|
|
|
from sqlalchemy import ( |
8
|
|
|
ARRAY, |
9
|
|
|
BigInteger, |
10
|
|
|
Boolean, |
11
|
|
|
Column, |
12
|
|
|
DateTime, |
13
|
|
|
Float, |
14
|
|
|
Integer, |
15
|
|
|
Numeric, |
16
|
|
|
String, |
17
|
|
|
Text, |
18
|
|
|
text, |
19
|
|
|
) |
20
|
|
|
from sqlalchemy.ext.declarative import declarative_base |
21
|
|
|
import geopandas as gpd |
22
|
|
|
import pandas as pd |
23
|
|
|
import pypsa |
24
|
|
|
|
25
|
|
|
from egon.data import db |
26
|
|
|
from egon.data.datasets import Dataset |
27
|
|
|
from egon.data.metadata import ( |
28
|
|
|
context, |
29
|
|
|
contributors, |
30
|
|
|
license_egon_data_odbl, |
31
|
|
|
meta_metadata, |
32
|
|
|
sources |
33
|
|
|
) |
34
|
|
|
|
35
|
|
|
Base = declarative_base() |
36
|
|
|
metadata = Base.metadata |
37
|
|
|
|
38
|
|
|
network = pypsa.Network() |
39
|
|
|
# add Storage key (called StorageUnit in PyPSA) |
40
|
|
|
network.component_attrs["Storage"] = network.component_attrs["StorageUnit"] |
41
|
|
|
|
42
|
|
|
|
43
|
|
|
def get_pypsa_field_descriptors(component, timeseries=False): |
44
|
|
|
|
45
|
|
|
ident = component.lower() + "_id" |
46
|
|
|
|
47
|
|
|
data = network.component_attrs[component].rename({"name": ident}) |
48
|
|
|
data = data[data.status != "Output"] |
49
|
|
|
|
50
|
|
|
if timeseries: |
51
|
|
|
data = data[data["type"].str.contains("series")] |
52
|
|
|
data.loc["temp_id"] = [ |
53
|
|
|
"integer", |
54
|
|
|
"n/a", |
55
|
|
|
"n/a", |
56
|
|
|
"Unique identifyier of temporal index", |
57
|
|
|
"Input", |
58
|
|
|
] |
59
|
|
|
|
60
|
|
|
data.loc[ident, "type"] = "int" |
61
|
|
|
data.loc["scn_name"] = [ |
62
|
|
|
"string", |
63
|
|
|
"n/a", |
64
|
|
|
"n/a", |
65
|
|
|
"Name of the eGon scenario", |
66
|
|
|
"Input", |
67
|
|
|
] |
68
|
|
|
data.unit.fillna("none", inplace=True) |
69
|
|
|
data.default.fillna("n/a", inplace=True) |
70
|
|
|
return data |
71
|
|
|
|
72
|
|
|
|
73
|
|
|
def get_meta( |
74
|
|
|
schema, |
75
|
|
|
component, |
76
|
|
|
description="TODO", |
77
|
|
|
source_list=[], |
78
|
|
|
contributor_list=[], |
79
|
|
|
timeseries=False, |
80
|
|
|
): |
81
|
|
|
|
82
|
|
|
table = "egon_etrago_" + component.lower() |
83
|
|
|
|
84
|
|
|
if timeseries: |
85
|
|
|
table = table + "_timeseries" |
86
|
|
|
fields = ( |
87
|
|
|
get_pypsa_field_descriptors(component, timeseries) |
88
|
|
|
.reset_index() |
89
|
|
|
.to_dict(orient="records") |
90
|
|
|
) |
91
|
|
|
# geometry column still missing |
92
|
|
|
|
93
|
|
|
meta = { |
94
|
|
|
"name": schema + "." + table, |
95
|
|
|
"title": component, |
96
|
|
|
"id": "WILL_BE_SET_AT_PUBLICATION", |
97
|
|
|
# no automatic description? PyPSA descriptions do not quite fit our |
98
|
|
|
# scope |
99
|
|
|
"description": description, |
100
|
|
|
"language": ["en-EN"], |
101
|
|
|
"publicationDate": datetime.date.today().isoformat(), |
102
|
|
|
"context": context(), |
103
|
|
|
"spatial": { |
104
|
|
|
"location": None, |
105
|
|
|
"extent": "Germany", |
106
|
|
|
"resolution": None, |
107
|
|
|
}, |
108
|
|
|
"sources": source_list, |
109
|
|
|
"licenses": [license_egon_data_odbl()], |
110
|
|
|
"contributors": contributor_list, |
111
|
|
|
"resources": [ |
112
|
|
|
{ |
113
|
|
|
"profile": "tabular-data-resource", |
114
|
|
|
"name": schema + "." + table, |
115
|
|
|
"path": None, |
116
|
|
|
"format": "PostgreSQL", |
117
|
|
|
"encoding": "UTF-8", |
118
|
|
|
"schema": { |
119
|
|
|
"fields": fields, |
120
|
|
|
"primaryKey": ["scn_name", component.lower() + "_id"], |
121
|
|
|
"foreignKeys": [], |
122
|
|
|
}, |
123
|
|
|
"dialect": { |
124
|
|
|
"delimiter": "", |
125
|
|
|
"decimalSeparator": "" |
126
|
|
|
}, |
127
|
|
|
} |
128
|
|
|
], |
129
|
|
|
"metaMetadata": meta_metadata(), |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
# Create json dump |
133
|
|
|
meta_json = "'" + json.dumps(meta, indent=4, ensure_ascii=False) + "'" |
134
|
|
|
|
135
|
|
|
return meta_json |
136
|
|
|
|
137
|
|
|
|
138
|
|
|
class EtragoSetup(Dataset): |
139
|
|
|
def __init__(self, dependencies): |
140
|
|
|
super().__init__( |
141
|
|
|
name="EtragoSetup", |
142
|
|
|
version="0.0.11", |
143
|
|
|
dependencies=dependencies, |
144
|
|
|
tasks=(create_tables, {temp_resolution, insert_carriers}), |
145
|
|
|
) |
146
|
|
|
|
147
|
|
|
|
148
|
|
|
class EgonPfHvBus(Base): |
149
|
|
|
|
150
|
|
|
source_list = [ |
151
|
|
|
sources()["egon-data"], |
152
|
|
|
sources()["openstreetmap"], |
153
|
|
|
sources()["peta"], |
154
|
|
|
sources()["SciGRID_gas"], |
155
|
|
|
sources()["bgr_inspeeds_data_bundle"], |
156
|
|
|
] |
157
|
|
|
|
158
|
|
|
contributor_list = contributors(["ic", "cb", "ke", "an", "fw"]) |
159
|
|
|
contributor_list[0]["comment"] = "Added electricity substations" |
160
|
|
|
contributor_list[1]["comment"] = "Added heat buses" |
161
|
|
|
contributor_list[2]["comment"] = "Added DSM buses" |
162
|
|
|
contributor_list[3]["comment"] = "Added CH4 sector buses" |
163
|
|
|
contributor_list[4]["comment"] = "Added H2 sector buses" |
164
|
|
|
|
165
|
|
|
|
166
|
|
|
__tablename__ = "egon_etrago_bus" |
167
|
|
|
__table_args__ = { |
168
|
|
|
"schema": "grid", |
169
|
|
|
"comment": get_meta( |
170
|
|
|
"grid", |
171
|
|
|
"Bus", |
172
|
|
|
source_list=source_list, |
173
|
|
|
contributor_list=contributor_list, |
174
|
|
|
), |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
scn_name = Column(String, primary_key=True, nullable=False) |
178
|
|
|
bus_id = Column(BigInteger, primary_key=True, nullable=False) |
179
|
|
|
v_nom = Column(Float(53), server_default="1.") |
180
|
|
|
type = Column(Text) |
181
|
|
|
carrier = Column(Text) |
182
|
|
|
v_mag_pu_set = Column(Float(53)) |
183
|
|
|
v_mag_pu_min = Column(Float(53), server_default="0.") |
184
|
|
|
v_mag_pu_max = Column(Float(53), server_default="inf") |
185
|
|
|
x = Column(Float(53), server_default="0.") |
186
|
|
|
y = Column(Float(53), server_default="0.") |
187
|
|
|
geom = Column(Geometry("POINT", 4326), index=True) |
188
|
|
|
country = Column(Text, server_default=text("'DE'::text")) |
189
|
|
|
|
190
|
|
|
|
191
|
|
View Code Duplication |
class EgonPfHvBusTimeseries(Base): |
|
|
|
|
192
|
|
|
|
193
|
|
|
source_list = [ |
194
|
|
|
sources()["egon-data"], |
195
|
|
|
] |
196
|
|
|
|
197
|
|
|
contributor_list = contributors(["cb"]) |
198
|
|
|
contributor_list[0]["comment"] = "Added metadata" |
199
|
|
|
|
200
|
|
|
__tablename__ = "egon_etrago_bus_timeseries" |
201
|
|
|
__table_args__ = { |
202
|
|
|
"schema": "grid", |
203
|
|
|
"comment": get_meta( |
204
|
|
|
"grid", |
205
|
|
|
"Bus", |
206
|
|
|
source_list=source_list, |
207
|
|
|
contributor_list=contributor_list, |
208
|
|
|
timeseries=True, |
209
|
|
|
), |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
scn_name = Column(String, primary_key=True, nullable=False) |
213
|
|
|
bus_id = Column(BigInteger, primary_key=True, nullable=False) |
214
|
|
|
v_mag_pu_set = Column(ARRAY(Float(precision=53))) |
215
|
|
|
|
216
|
|
|
|
217
|
|
|
class EgonPfHvGenerator(Base): |
218
|
|
|
|
219
|
|
|
source_list = [ |
220
|
|
|
sources()["egon-data"], |
221
|
|
|
sources()["openstreetmap"], |
222
|
|
|
sources()["mastr"], |
223
|
|
|
sources()["nep2021"], |
224
|
|
|
sources()["tyndp"], |
225
|
|
|
sources()["SciGRID_gas"], |
226
|
|
|
sources()["Einspeiseatlas"], |
227
|
|
|
sources()["technology-data"], |
228
|
|
|
sources()["vg250"], |
229
|
|
|
] |
230
|
|
|
|
231
|
|
|
contributor_list = contributors(["ic", "cb", "ce", "an", "ke"]) |
232
|
|
|
contributor_list[0]["comment"] = "Added hydro and biomass plants" |
233
|
|
|
contributor_list[1]["comment"] = "Added solar and geothermal plants" |
234
|
|
|
contributor_list[2]["comment"] = "Added wind on- and offshore plants" |
235
|
|
|
contributor_list[3]["comment"] = "Added gas feedin generators" |
236
|
|
|
contributor_list[4]["comment"] = "Added pv ground mounted" |
237
|
|
|
|
238
|
|
|
|
239
|
|
|
__tablename__ = "egon_etrago_generator" |
240
|
|
|
__table_args__ = { |
241
|
|
|
"schema": "grid", |
242
|
|
|
"comment": get_meta( |
243
|
|
|
"grid", |
244
|
|
|
"Generator", |
245
|
|
|
source_list=source_list, |
246
|
|
|
contributor_list=contributor_list, |
247
|
|
|
), |
248
|
|
|
} |
249
|
|
|
|
250
|
|
|
scn_name = Column(String, primary_key=True, nullable=False) |
251
|
|
|
generator_id = Column(BigInteger, primary_key=True, nullable=False) |
252
|
|
|
bus = Column(BigInteger) |
253
|
|
|
control = Column(Text) |
254
|
|
|
type = Column(Text) |
255
|
|
|
carrier = Column(Text) |
256
|
|
|
p_nom = Column(Float(53), server_default="0.") |
257
|
|
|
p_nom_extendable = Column(Boolean, server_default="False") |
258
|
|
|
p_nom_min = Column(Float(53), server_default="0.") |
259
|
|
|
p_nom_max = Column(Float(53), server_default="inf") |
260
|
|
|
p_min_pu = Column(Float(53), server_default="0.") |
261
|
|
|
p_max_pu = Column(Float(53), server_default="1.") |
262
|
|
|
p_set = Column(Float(53)) |
263
|
|
|
q_set = Column(Float(53)) |
264
|
|
|
sign = Column(Float(53), server_default="1.") |
265
|
|
|
marginal_cost = Column(Float(53), server_default="0.") |
266
|
|
|
build_year = Column(BigInteger, server_default="0") |
267
|
|
|
lifetime = Column(Float(53), server_default="inf") |
268
|
|
|
capital_cost = Column(Float(53), server_default="0.") |
269
|
|
|
efficiency = Column(Float(53), server_default="1.") |
270
|
|
|
committable = Column(Boolean, server_default="False") |
271
|
|
|
start_up_cost = Column(Float(53), server_default="0.") |
272
|
|
|
shut_down_cost = Column(Float(53), server_default="0.") |
273
|
|
|
min_up_time = Column(BigInteger, server_default="0") |
274
|
|
|
min_down_time = Column(BigInteger, server_default="0") |
275
|
|
|
up_time_before = Column(BigInteger, server_default="0") |
276
|
|
|
down_time_before = Column(BigInteger, server_default="0") |
277
|
|
|
ramp_limit_up = Column(Float(53), server_default="NaN") |
278
|
|
|
ramp_limit_down = Column(Float(53), server_default="NaN") |
279
|
|
|
ramp_limit_start_up = Column(Float(53), server_default="1.") |
280
|
|
|
ramp_limit_shut_down = Column(Float(53), server_default="1.") |
281
|
|
|
e_nom_max = Column( |
282
|
|
|
Float(53), server_default="inf" |
283
|
|
|
) # [MWh(/y)] Value to be used in eTraGo to set constraint for the production over the year |
284
|
|
|
|
285
|
|
|
|
286
|
|
|
class EgonPfHvGeneratorTimeseries(Base): |
287
|
|
|
|
288
|
|
|
source_list = [ |
289
|
|
|
sources()["egon-data"], |
290
|
|
|
sources()["era5"], |
291
|
|
|
] |
292
|
|
|
|
293
|
|
|
contributor_list = contributors(["cb"]) |
294
|
|
|
contributor_list[0][ |
295
|
|
|
"comment" |
296
|
|
|
] = "Added p_max_pu timeseries for pv and wind" |
297
|
|
|
|
298
|
|
|
|
299
|
|
|
__tablename__ = "egon_etrago_generator_timeseries" |
300
|
|
|
__table_args__ = { |
301
|
|
|
"schema": "grid", |
302
|
|
|
"comment": get_meta( |
303
|
|
|
"grid", |
304
|
|
|
"Generator", |
305
|
|
|
source_list=source_list, |
306
|
|
|
contributor_list=contributor_list, |
307
|
|
|
timeseries=True, |
308
|
|
|
), |
309
|
|
|
} |
310
|
|
|
|
311
|
|
|
scn_name = Column(String, primary_key=True, nullable=False) |
312
|
|
|
generator_id = Column(Integer, primary_key=True, nullable=False) |
313
|
|
|
temp_id = Column(Integer, primary_key=True, nullable=False) |
314
|
|
|
p_set = Column(ARRAY(Float(precision=53))) |
315
|
|
|
q_set = Column(ARRAY(Float(precision=53))) |
316
|
|
|
p_min_pu = Column(ARRAY(Float(precision=53))) |
317
|
|
|
p_max_pu = Column(ARRAY(Float(precision=53))) |
318
|
|
|
marginal_cost = Column(ARRAY(Float(precision=53))) |
319
|
|
|
|
320
|
|
|
|
321
|
|
View Code Duplication |
class EgonPfHvLine(Base): |
|
|
|
|
322
|
|
|
|
323
|
|
|
source_list = [ |
324
|
|
|
sources()["egon-data"], |
325
|
|
|
sources()["openstreetmap"], |
326
|
|
|
] |
327
|
|
|
|
328
|
|
|
contributor_list = contributors(["ic", "cb"]) |
329
|
|
|
contributor_list[0]["comment"] = "Added lines from osmTGmod tables" |
330
|
|
|
contributor_list[1]["comment"] = "Added meta data" |
331
|
|
|
|
332
|
|
|
__tablename__ = "egon_etrago_line" |
333
|
|
|
__table_args__ = { |
334
|
|
|
"schema": "grid", |
335
|
|
|
"comment": get_meta( |
336
|
|
|
"grid", |
337
|
|
|
"Line", |
338
|
|
|
source_list=source_list, |
339
|
|
|
contributor_list=contributor_list, |
340
|
|
|
), |
341
|
|
|
} |
342
|
|
|
|
343
|
|
|
scn_name = Column(String, primary_key=True, nullable=False) |
344
|
|
|
line_id = Column(BigInteger, primary_key=True, nullable=False) |
345
|
|
|
bus0 = Column(BigInteger) |
346
|
|
|
bus1 = Column(BigInteger) |
347
|
|
|
type = Column(Text) |
348
|
|
|
carrier = Column(Text) |
349
|
|
|
x = Column(Numeric, server_default="0.") |
350
|
|
|
r = Column(Numeric, server_default="0.") |
351
|
|
|
g = Column(Numeric, server_default="0.") |
352
|
|
|
b = Column(Numeric, server_default="0.") |
353
|
|
|
s_nom = Column(Numeric, server_default="0.") |
354
|
|
|
s_nom_extendable = Column(Boolean, server_default="False") |
355
|
|
|
s_nom_min = Column(Float(53), server_default="0.") |
356
|
|
|
s_nom_max = Column(Float(53), server_default="inf") |
357
|
|
|
s_max_pu = Column(Float(53), server_default="1.") |
358
|
|
|
build_year = Column(BigInteger, server_default="0") |
359
|
|
|
lifetime = Column(Float(53), server_default="inf") |
360
|
|
|
capital_cost = Column(Float(53), server_default="0.") |
361
|
|
|
length = Column(Float(53), server_default="0.") |
362
|
|
|
cables = Column(Integer) |
363
|
|
|
terrain_factor = Column(Float(53), server_default="1.") |
364
|
|
|
num_parallel = Column(Float(53), server_default="1.") |
365
|
|
|
v_ang_min = Column(Float(53), server_default="-inf") |
366
|
|
|
v_ang_max = Column(Float(53), server_default="inf") |
367
|
|
|
v_nom = Column(Float(53)) |
368
|
|
|
geom = Column(Geometry("MULTILINESTRING", 4326)) |
369
|
|
|
topo = Column(Geometry("LINESTRING", 4326)) |
370
|
|
|
|
371
|
|
|
|
372
|
|
|
class EgonPfHvLineTimeseries(Base): |
373
|
|
|
|
374
|
|
|
source_list = [ |
375
|
|
|
sources()["egon-data"], |
376
|
|
|
sources()["nep2021"], |
377
|
|
|
sources()["era5"], |
378
|
|
|
] |
379
|
|
|
|
380
|
|
|
contributor_list = contributors(["ce", "cb"]) |
381
|
|
|
contributor_list[0]["comment"] = "Added s_max_pu timeseries" |
382
|
|
|
contributor_list[1]["comment"] = "Added meta data" |
383
|
|
|
|
384
|
|
|
__tablename__ = "egon_etrago_line_timeseries" |
385
|
|
|
__table_args__ = { |
386
|
|
|
"schema": "grid", |
387
|
|
|
"comment": get_meta( |
388
|
|
|
"grid", |
389
|
|
|
"Line", |
390
|
|
|
source_list=source_list, |
391
|
|
|
contributor_list=contributor_list, |
392
|
|
|
timeseries=True, |
393
|
|
|
), |
394
|
|
|
} |
395
|
|
|
|
396
|
|
|
scn_name = Column(String, primary_key=True, nullable=False) |
397
|
|
|
line_id = Column(BigInteger, primary_key=True, nullable=False) |
398
|
|
|
temp_id = Column(Integer, primary_key=True, nullable=False) |
399
|
|
|
s_max_pu = Column(ARRAY(Float(precision=53))) |
400
|
|
|
|
401
|
|
|
|
402
|
|
|
class EgonPfHvLink(Base): |
403
|
|
|
|
404
|
|
|
source_list = [ |
405
|
|
|
sources()["egon-data"], |
406
|
|
|
sources()["openstreetmap"], |
407
|
|
|
sources()["nep2021"], |
408
|
|
|
sources()["peta"], |
409
|
|
|
sources()["mastr"], |
410
|
|
|
sources()["SciGRID_gas"], |
411
|
|
|
sources()["pipeline_classification"], |
412
|
|
|
sources()["technology-data"], |
413
|
|
|
sources()["dsm-heitkoetter"], |
414
|
|
|
sources()["schmidt"], |
415
|
|
|
sources()["hotmaps_industrial_sites"], |
416
|
|
|
sources()["demandregio"], |
417
|
|
|
] |
418
|
|
|
|
419
|
|
|
contributor_list = contributors(["ic", "cb", "ke", "ja", "fw", "an"]) |
420
|
|
|
contributor_list[0]["comment"] = "Added DC lines from osmTGmod tables" |
421
|
|
|
contributor_list[1]["comment"] = "Added CHPs and heat links" |
422
|
|
|
contributor_list[2]["comment"] = "Added DSM links" |
423
|
|
|
contributor_list[3]["comment"] = "Added e-Mobility links" |
424
|
|
|
contributor_list[4]["comment"] = "Added H2 related links" |
425
|
|
|
contributor_list[5]["comment"] = "Added CH4 links" |
426
|
|
|
|
427
|
|
|
|
428
|
|
|
__tablename__ = "egon_etrago_link" |
429
|
|
|
__table_args__ = { |
430
|
|
|
"schema": "grid", |
431
|
|
|
"comment": get_meta( |
432
|
|
|
"grid", |
433
|
|
|
"Link", |
434
|
|
|
source_list=source_list, |
435
|
|
|
contributor_list=contributor_list, |
436
|
|
|
), |
437
|
|
|
} |
438
|
|
|
|
439
|
|
|
__tablename__ = "egon_etrago_link" |
440
|
|
|
__table_args__ = {"schema": "grid", "comment": get_meta("grid", "Link")} |
441
|
|
|
|
442
|
|
|
scn_name = Column(String, primary_key=True, nullable=False) |
443
|
|
|
link_id = Column(BigInteger, primary_key=True, nullable=False) |
444
|
|
|
bus0 = Column(BigInteger) |
445
|
|
|
bus1 = Column(BigInteger) |
446
|
|
|
type = Column(Text) |
447
|
|
|
carrier = Column(Text) |
448
|
|
|
efficiency = Column(Float(53), server_default="1.") |
449
|
|
|
build_year = Column(BigInteger, server_default="0") |
450
|
|
|
lifetime = Column(Float(53), server_default="inf") |
451
|
|
|
p_nom = Column(Numeric, server_default="0.") |
452
|
|
|
p_nom_extendable = Column(Boolean, server_default="False") |
453
|
|
|
p_nom_min = Column(Float(53), server_default="0.") |
454
|
|
|
p_nom_max = Column(Float(53), server_default="inf") |
455
|
|
|
p_min_pu = Column(Float(53), server_default="0.") |
456
|
|
|
p_max_pu = Column(Float(53), server_default="1.") |
457
|
|
|
p_set = Column(Float(53)) |
458
|
|
|
capital_cost = Column(Float(53), server_default="0.") |
459
|
|
|
marginal_cost = Column(Float(53), server_default="0.") |
460
|
|
|
length = Column(Float(53), server_default="0.") |
461
|
|
|
terrain_factor = Column(Float(53), server_default="1.") |
462
|
|
|
geom = Column(Geometry("MULTILINESTRING", 4326)) |
463
|
|
|
topo = Column(Geometry("LINESTRING", 4326)) |
464
|
|
|
|
465
|
|
|
|
466
|
|
|
class EgonPfHvLinkTimeseries(Base): |
467
|
|
|
source_list = [ |
468
|
|
|
sources()["egon-data"], |
469
|
|
|
sources()["era5"], |
470
|
|
|
sources()["dsm-heitkoetter"], |
471
|
|
|
sources()["schmidt"], |
472
|
|
|
sources()["hotmaps_industrial_sites"], |
473
|
|
|
sources()["openstreetmap"], |
474
|
|
|
sources()["demandregio"], |
475
|
|
|
] |
476
|
|
|
|
477
|
|
|
contributor_list = contributors(["cb", "ke", "ja"]) |
478
|
|
|
contributor_list[0][ |
479
|
|
|
"comment" |
480
|
|
|
] = "Added efficiency timeseries for heat pumps" |
481
|
|
|
contributor_list[1]["comment"] = "Added dsm link timeseries" |
482
|
|
|
contributor_list[2]["comment"] = "Added e mobility link timeseries" |
483
|
|
|
|
484
|
|
|
__tablename__ = "egon_etrago_link_timeseries" |
485
|
|
|
__table_args__ = { |
486
|
|
|
"schema": "grid", |
487
|
|
|
"comment": get_meta( |
488
|
|
|
"grid", |
489
|
|
|
"Link", |
490
|
|
|
source_list=source_list, |
491
|
|
|
contributor_list=contributor_list, |
492
|
|
|
timeseries=True, |
493
|
|
|
), |
494
|
|
|
} |
495
|
|
|
|
496
|
|
|
scn_name = Column(String, primary_key=True, nullable=False) |
497
|
|
|
link_id = Column(BigInteger, primary_key=True, nullable=False) |
498
|
|
|
temp_id = Column(Integer, primary_key=True, nullable=False) |
499
|
|
|
p_set = Column(ARRAY(Float(precision=53))) |
500
|
|
|
p_min_pu = Column(ARRAY(Float(precision=53))) |
501
|
|
|
p_max_pu = Column(ARRAY(Float(precision=53))) |
502
|
|
|
efficiency = Column(ARRAY(Float(precision=53))) |
503
|
|
|
marginal_cost = Column(ARRAY(Float(precision=53))) |
504
|
|
|
|
505
|
|
|
|
506
|
|
|
class EgonPfHvLoad(Base): |
507
|
|
|
|
508
|
|
|
source_list = [ |
509
|
|
|
sources()["egon-data"], |
510
|
|
|
sources()["demandregio"], |
511
|
|
|
sources()["nep2021"], |
512
|
|
|
sources()["peta"], |
513
|
|
|
sources()["schmidt"], |
514
|
|
|
sources()["hotmaps_industrial_sites"], |
515
|
|
|
sources()["openstreetmap"], |
516
|
|
|
sources()["openffe_gas"], |
517
|
|
|
sources()["tyndp"], |
518
|
|
|
] |
519
|
|
|
|
520
|
|
|
contributor_list = contributors(["ic", "cb", "an", "ja"]) |
521
|
|
|
contributor_list[0]["comment"] = "Added electrical demands" |
522
|
|
|
contributor_list[1]["comment"] = "Added heat deands" |
523
|
|
|
contributor_list[2]["comment"] = "Added gas demands" |
524
|
|
|
contributor_list[3]["comment"] = "Added mobility demands" |
525
|
|
|
|
526
|
|
|
|
527
|
|
|
__tablename__ = "egon_etrago_load" |
528
|
|
|
__table_args__ = { |
529
|
|
|
"schema": "grid", |
530
|
|
|
"comment": get_meta( |
531
|
|
|
"grid", |
532
|
|
|
"Load", |
533
|
|
|
source_list=source_list, |
534
|
|
|
contributor_list=contributor_list, |
535
|
|
|
), |
536
|
|
|
} |
537
|
|
|
|
538
|
|
|
scn_name = Column(String, primary_key=True, nullable=False) |
539
|
|
|
load_id = Column(BigInteger, primary_key=True, nullable=False) |
540
|
|
|
bus = Column(BigInteger) |
541
|
|
|
type = Column(Text) |
542
|
|
|
carrier = Column(Text) |
543
|
|
|
p_set = Column(Float(53)) |
544
|
|
|
q_set = Column(Float(53)) |
545
|
|
|
sign = Column(Float(53), server_default="-1.") |
546
|
|
|
|
547
|
|
|
|
548
|
|
|
class EgonPfHvLoadTimeseries(Base): |
549
|
|
|
source_list = [ |
550
|
|
|
sources()["egon-data"], |
551
|
|
|
sources()["demandregio"], |
552
|
|
|
sources()["nep2021"], |
553
|
|
|
sources()["peta"], |
554
|
|
|
sources()["openffe_gas"], |
555
|
|
|
sources()["tyndp"], |
556
|
|
|
sources()["era5"], |
557
|
|
|
sources()["schmidt"], |
558
|
|
|
sources()["hotmaps_industrial_sites"], |
559
|
|
|
sources()["openstreetmap"], |
560
|
|
|
] |
561
|
|
|
|
562
|
|
|
contributor_list = contributors(["cb", "ic", "ja", "an"]) |
563
|
|
|
contributor_list[0]["comment"] = "Added heat load timeseries" |
564
|
|
|
contributor_list[1]["comment"] = "Added electricity load timeseries" |
565
|
|
|
contributor_list[2]["comment"] = "Added e mobility load timeseries" |
566
|
|
|
contributor_list[3]["comment"] = "Added gas load timeseries" |
567
|
|
|
|
568
|
|
|
|
569
|
|
|
__tablename__ = "egon_etrago_load_timeseries" |
570
|
|
|
__table_args__ = { |
571
|
|
|
"schema": "grid", |
572
|
|
|
"comment": get_meta( |
573
|
|
|
"grid", |
574
|
|
|
"Load", |
575
|
|
|
source_list=source_list, |
576
|
|
|
contributor_list=contributor_list, |
577
|
|
|
timeseries=True, |
578
|
|
|
), |
579
|
|
|
} |
580
|
|
|
|
581
|
|
|
scn_name = Column(String, primary_key=True, nullable=False) |
582
|
|
|
load_id = Column(BigInteger, primary_key=True, nullable=False) |
583
|
|
|
temp_id = Column(Integer, primary_key=True, nullable=False) |
584
|
|
|
p_set = Column(ARRAY(Float(precision=53))) |
585
|
|
|
q_set = Column(ARRAY(Float(precision=53))) |
586
|
|
|
|
587
|
|
|
|
588
|
|
|
class EgonPfHvCarrier(Base): |
589
|
|
|
source_list = [ |
590
|
|
|
sources()["egon-data"], |
591
|
|
|
] |
592
|
|
|
|
593
|
|
|
contributor_list = contributors(["fw"]) |
594
|
|
|
contributor_list[0]["comment"] = "Added list of carriers" |
595
|
|
|
|
596
|
|
|
|
597
|
|
|
__tablename__ = "egon_etrago_carrier" |
598
|
|
|
__table_args__ = { |
599
|
|
|
"schema": "grid", |
600
|
|
|
"comment": get_meta( |
601
|
|
|
"grid", |
602
|
|
|
"Carrier", |
603
|
|
|
source_list=source_list, |
604
|
|
|
contributor_list=contributor_list, |
605
|
|
|
), |
606
|
|
|
} |
607
|
|
|
|
608
|
|
|
name = Column(Text, primary_key=True, nullable=False) |
609
|
|
|
co2_emissions = Column(Float(53), server_default="0.") |
610
|
|
|
color = Column(Text) |
611
|
|
|
nice_name = Column(Text) |
612
|
|
|
commentary = Column(Text) |
613
|
|
|
|
614
|
|
|
|
615
|
|
|
class EgonPfHvStorage(Base): |
616
|
|
|
|
617
|
|
|
source_list = [ |
618
|
|
|
sources()["egon-data"], |
619
|
|
|
sources()["nep2021"], |
620
|
|
|
sources()["mastr"], |
621
|
|
|
sources()["technology-data"], |
622
|
|
|
] |
623
|
|
|
|
624
|
|
|
contributor_list = contributors(["ic"]) |
625
|
|
|
contributor_list[0][ |
626
|
|
|
"comment" |
627
|
|
|
] = "Added battery and pumped hydro storage units" |
628
|
|
|
|
629
|
|
|
|
630
|
|
|
__tablename__ = "egon_etrago_storage" |
631
|
|
|
__table_args__ = { |
632
|
|
|
"schema": "grid", |
633
|
|
|
"comment": get_meta( |
634
|
|
|
"grid", |
635
|
|
|
"Storage", |
636
|
|
|
source_list=source_list, |
637
|
|
|
contributor_list=contributor_list, |
638
|
|
|
), |
639
|
|
|
} |
640
|
|
|
|
641
|
|
|
scn_name = Column(String, primary_key=True, nullable=False) |
642
|
|
|
storage_id = Column(BigInteger, primary_key=True, nullable=False) |
643
|
|
|
bus = Column(BigInteger) |
644
|
|
|
control = Column(Text) |
645
|
|
|
type = Column(Text) |
646
|
|
|
carrier = Column(Text) |
647
|
|
|
p_nom = Column(Float(53), server_default="0.") |
648
|
|
|
p_nom_extendable = Column((Boolean), server_default="False") |
649
|
|
|
p_nom_min = Column(Float(53), server_default="0.") |
650
|
|
|
p_nom_max = Column(Float(53), server_default="inf") |
651
|
|
|
p_min_pu = Column(Float(53), server_default="-1.") |
652
|
|
|
p_max_pu = Column(Float(53), server_default="1.") |
653
|
|
|
p_set = Column(Float(53)) |
654
|
|
|
q_set = Column(Float(53)) |
655
|
|
|
sign = Column(Float(53), server_default="1") |
656
|
|
|
marginal_cost = Column(Float(53), server_default="0.") |
657
|
|
|
capital_cost = Column(Float(53), server_default="0.") |
658
|
|
|
build_year = Column(BigInteger, server_default="0") |
659
|
|
|
lifetime = Column(Float(53), server_default="inf") |
660
|
|
|
state_of_charge_initial = Column(Float(53), server_default="0") |
661
|
|
|
cyclic_state_of_charge = Column(Boolean, server_default="False") |
662
|
|
|
state_of_charge_set = Column(Float(53)) |
663
|
|
|
max_hours = Column(Float(53), server_default="1") |
664
|
|
|
efficiency_store = Column(Float(53), server_default="1.") |
665
|
|
|
efficiency_dispatch = Column(Float(53), server_default="1.") |
666
|
|
|
standing_loss = Column(Float(53), server_default="0.") |
667
|
|
|
inflow = Column(Float(53), server_default="0.") |
668
|
|
|
|
669
|
|
|
|
670
|
|
|
class EgonPfHvStorageTimeseries(Base): |
671
|
|
|
source_list = [ |
672
|
|
|
sources()["egon-data"], |
673
|
|
|
] |
674
|
|
|
|
675
|
|
|
contributor_list = contributors(["cb"]) |
676
|
|
|
contributor_list[0]["comment"] = "Added metadata" |
677
|
|
|
|
678
|
|
|
|
679
|
|
|
__tablename__ = "egon_etrago_storage_timeseries" |
680
|
|
|
__table_args__ = { |
681
|
|
|
"schema": "grid", |
682
|
|
|
"comment": get_meta( |
683
|
|
|
"grid", |
684
|
|
|
"Storage", |
685
|
|
|
source_list=source_list, |
686
|
|
|
contributor_list=contributor_list, |
687
|
|
|
timeseries=True, |
688
|
|
|
), |
689
|
|
|
} |
690
|
|
|
|
691
|
|
|
scn_name = Column(String, primary_key=True, nullable=False) |
692
|
|
|
storage_id = Column(BigInteger, primary_key=True, nullable=False) |
693
|
|
|
temp_id = Column(Integer, primary_key=True, nullable=False) |
694
|
|
|
p_set = Column(ARRAY(Float(precision=53))) |
695
|
|
|
q_set = Column(ARRAY(Float(precision=53))) |
696
|
|
|
p_min_pu = Column(ARRAY(Float(precision=53))) |
697
|
|
|
p_max_pu = Column(ARRAY(Float(precision=53))) |
698
|
|
|
state_of_charge_set = Column(ARRAY(Float(precision=53))) |
699
|
|
|
inflow = Column(ARRAY(Float(precision=53))) |
700
|
|
|
marginal_cost = Column(ARRAY(Float(precision=53))) |
701
|
|
|
|
702
|
|
|
|
703
|
|
|
class EgonPfHvStore(Base): |
704
|
|
|
source_dict = sources() |
705
|
|
|
|
706
|
|
|
source_list = [ |
707
|
|
|
source_dict["bgr_inspee"], |
708
|
|
|
source_dict["bgr_inspeeds"], |
709
|
|
|
source_dict["bgr_inspeeds_data_bundle"], |
710
|
|
|
source_dict["bgr_inspeeds_report"], |
711
|
|
|
source_dict["SciGRID_gas"], |
712
|
|
|
sources()["technology-data"], |
713
|
|
|
sources()["dsm-heitkoetter"], |
714
|
|
|
sources()["schmidt"], |
715
|
|
|
sources()["hotmaps_industrial_sites"], |
716
|
|
|
sources()["openstreetmap"], |
717
|
|
|
sources()["demandregio"], |
718
|
|
|
] |
719
|
|
|
contributor_list = contributors(["an", "fw", "ke", "cb", "ja"]) |
720
|
|
|
contributor_list[0]["comment"] = "Add H2 storage" |
721
|
|
|
contributor_list[1]["comment"] = "Add CH4 storage" |
722
|
|
|
contributor_list[2]["comment"] = "Add DSM storage" |
723
|
|
|
contributor_list[3]["comment"] = "Add heat storage" |
724
|
|
|
contributor_list[4]["comment"] = "Add e-mobility storage" |
725
|
|
|
|
726
|
|
|
__tablename__ = "egon_etrago_store" |
727
|
|
|
__table_args__ = { |
728
|
|
|
"schema": "grid", |
729
|
|
|
"comment": get_meta( |
730
|
|
|
"grid", |
731
|
|
|
"Store", |
732
|
|
|
source_list=source_list, |
733
|
|
|
contributor_list=contributor_list, |
734
|
|
|
), |
735
|
|
|
} |
736
|
|
|
|
737
|
|
|
scn_name = Column(String, primary_key=True, nullable=False) |
738
|
|
|
store_id = Column(BigInteger, primary_key=True, nullable=False) |
739
|
|
|
bus = Column(BigInteger) |
740
|
|
|
type = Column(Text) |
741
|
|
|
carrier = Column(Text) |
742
|
|
|
e_nom = Column(Float(53), server_default="0.") |
743
|
|
|
e_nom_extendable = Column((Boolean), server_default="False") |
744
|
|
|
e_nom_min = Column(Float(53), server_default="0.") |
745
|
|
|
e_nom_max = Column(Float(53), server_default="inf") |
746
|
|
|
e_min_pu = Column(Float(53), server_default="0.") |
747
|
|
|
e_max_pu = Column(Float(53), server_default="1.") |
748
|
|
|
p_set = Column(Float(53)) |
749
|
|
|
q_set = Column(Float(53)) |
750
|
|
|
e_initial = Column(Float(53), server_default="0.") |
751
|
|
|
e_cyclic = Column(Boolean, server_default="False") |
752
|
|
|
sign = Column(Float(53), server_default="1") |
753
|
|
|
marginal_cost = Column(Float(53), server_default="0.") |
754
|
|
|
capital_cost = Column(Float(53), server_default="0.") |
755
|
|
|
standing_loss = Column(Float(53), server_default="0.") |
756
|
|
|
build_year = Column(BigInteger, server_default="0") |
757
|
|
|
lifetime = Column(Float(53), server_default="inf") |
758
|
|
|
|
759
|
|
|
|
760
|
|
|
class EgonPfHvStoreTimeseries(Base): |
761
|
|
|
source_dict = sources() |
762
|
|
|
# TODO: Add other sources for dsm |
763
|
|
|
source_list = [ |
764
|
|
|
sources()["technology-data"], |
765
|
|
|
sources()["dsm-heitkoetter"], |
766
|
|
|
sources()["schmidt"], |
767
|
|
|
sources()["hotmaps_industrial_sites"], |
768
|
|
|
sources()["openstreetmap"], |
769
|
|
|
sources()["demandregio"], |
770
|
|
|
] |
771
|
|
|
contributor_list = contributors(["ke", "ja"]) |
772
|
|
|
contributor_list[0]["comment"] = "Add DSM storage" |
773
|
|
|
contributor_list[1]["comment"] = "Add e-mobility storage" |
774
|
|
|
|
775
|
|
|
__tablename__ = "egon_etrago_store_timeseries" |
776
|
|
|
__table_args__ = { |
777
|
|
|
"schema": "grid", |
778
|
|
|
"comment": get_meta( |
779
|
|
|
"grid", |
780
|
|
|
"Store", |
781
|
|
|
source_list=source_list, |
782
|
|
|
contributor_list=contributor_list, |
783
|
|
|
timeseries=True, |
784
|
|
|
), |
785
|
|
|
} |
786
|
|
|
scn_name = Column(String, primary_key=True, nullable=False) |
787
|
|
|
store_id = Column(BigInteger, primary_key=True, nullable=False) |
788
|
|
|
temp_id = Column(Integer, primary_key=True, nullable=False) |
789
|
|
|
p_set = Column(ARRAY(Float(precision=53))) |
790
|
|
|
q_set = Column(ARRAY(Float(precision=53))) |
791
|
|
|
e_min_pu = Column(ARRAY(Float(precision=53))) |
792
|
|
|
e_max_pu = Column(ARRAY(Float(precision=53))) |
793
|
|
|
marginal_cost = Column(ARRAY(Float(precision=53))) |
794
|
|
|
|
795
|
|
|
|
796
|
|
|
class EgonPfHvTempResolution(Base): |
797
|
|
|
__tablename__ = "egon_etrago_temp_resolution" |
798
|
|
|
__table_args__ = {"schema": "grid"} |
799
|
|
|
|
800
|
|
|
temp_id = Column(BigInteger, primary_key=True, nullable=False) |
801
|
|
|
timesteps = Column(BigInteger, nullable=False) |
802
|
|
|
resolution = Column(Text) |
803
|
|
|
start_time = Column(DateTime) |
804
|
|
|
|
805
|
|
|
|
806
|
|
View Code Duplication |
class EgonPfHvTransformer(Base): |
|
|
|
|
807
|
|
|
|
808
|
|
|
source_list = [ |
809
|
|
|
sources()["egon-data"], |
810
|
|
|
sources()["openstreetmap"], |
811
|
|
|
] |
812
|
|
|
|
813
|
|
|
contributor_list = contributors(["ic", "cb"]) |
814
|
|
|
contributor_list[0]["comment"] = "Added transformes from osmTGmod tables" |
815
|
|
|
contributor_list[1]["comment"] = "Added meta data" |
816
|
|
|
|
817
|
|
|
|
818
|
|
|
__tablename__ = "egon_etrago_transformer" |
819
|
|
|
__table_args__ = { |
820
|
|
|
"schema": "grid", |
821
|
|
|
"comment": get_meta( |
822
|
|
|
"grid", |
823
|
|
|
"Transformer", |
824
|
|
|
source_list=source_list, |
825
|
|
|
contributor_list=contributor_list, |
826
|
|
|
), |
827
|
|
|
} |
828
|
|
|
|
829
|
|
|
scn_name = Column(String, primary_key=True, nullable=False) |
830
|
|
|
trafo_id = Column(BigInteger, primary_key=True, nullable=False) |
831
|
|
|
bus0 = Column(BigInteger) |
832
|
|
|
bus1 = Column(BigInteger) |
833
|
|
|
type = Column(Text) |
834
|
|
|
model = Column((Text), server_default="t") |
835
|
|
|
x = Column((Numeric), server_default="0.") |
836
|
|
|
r = Column((Numeric), server_default="0.") |
837
|
|
|
g = Column((Numeric), server_default="0.") |
838
|
|
|
b = Column((Numeric), server_default="0.") |
839
|
|
|
s_nom = Column(Float(53), server_default="0.") |
840
|
|
|
s_nom_extendable = Column((Boolean), server_default="False") |
841
|
|
|
s_nom_min = Column(Float(53), server_default="0.") |
842
|
|
|
s_nom_max = Column(Float(53), server_default="inf") |
843
|
|
|
s_max_pu = Column(Float(53), server_default="1.") |
844
|
|
|
tap_ratio = Column(Float(53), server_default="1.") |
845
|
|
|
tap_side = Column((BigInteger), server_default="0") |
846
|
|
|
tap_position = Column((BigInteger), server_default="0") |
847
|
|
|
phase_shift = Column(Float(53), server_default="0.") |
848
|
|
|
build_year = Column(BigInteger, server_default="0") |
849
|
|
|
lifetime = Column(Float(53), server_default="inf") |
850
|
|
|
v_ang_min = Column(Float(53), server_default="-inf") |
851
|
|
|
v_ang_max = Column(Float(53), server_default="inf") |
852
|
|
|
capital_cost = Column(Float(53), server_default="0.") |
853
|
|
|
num_parallel = Column(Float(53), server_default="1.") |
854
|
|
|
geom = Column(Geometry("MULTILINESTRING", 4326)) |
855
|
|
|
topo = Column(Geometry("LINESTRING", 4326)) |
856
|
|
|
|
857
|
|
|
|
858
|
|
View Code Duplication |
class EgonPfHvTransformerTimeseries(Base): |
|
|
|
|
859
|
|
|
source_list = [ |
860
|
|
|
sources()["egon-data"], |
861
|
|
|
] |
862
|
|
|
|
863
|
|
|
contributor_list = contributors(["cb"]) |
864
|
|
|
contributor_list[0]["comment"] = "Added meta data" |
865
|
|
|
|
866
|
|
|
__tablename__ = "egon_etrago_transformer_timeseries" |
867
|
|
|
__table_args__ = { |
868
|
|
|
"schema": "grid", |
869
|
|
|
"comment": get_meta( |
870
|
|
|
"grid", |
871
|
|
|
"Transformer", |
872
|
|
|
source_list=source_list, |
873
|
|
|
contributor_list=contributor_list, |
874
|
|
|
timeseries=True, |
875
|
|
|
), |
876
|
|
|
} |
877
|
|
|
|
878
|
|
|
scn_name = Column(String, primary_key=True, nullable=False) |
879
|
|
|
trafo_id = Column(BigInteger, primary_key=True, nullable=False) |
880
|
|
|
temp_id = Column(Integer, primary_key=True, nullable=False) |
881
|
|
|
s_max_pu = Column(ARRAY(Float(precision=53))) |
882
|
|
|
|
883
|
|
|
|
884
|
|
|
class EgonPfHvBusmap(Base): |
885
|
|
|
__tablename__ = "egon_etrago_hv_busmap" |
886
|
|
|
__table_args__ = {"schema": "grid"} |
887
|
|
|
|
888
|
|
|
scn_name = Column(Text, primary_key=True, nullable=False) |
889
|
|
|
bus0 = Column(Text, primary_key=True, nullable=False) |
890
|
|
|
bus1 = Column(Text, primary_key=True, nullable=False) |
891
|
|
|
path_length = Column(Numeric) |
892
|
|
|
version = Column(Text, primary_key=True, nullable=False) |
893
|
|
|
|
894
|
|
|
|
895
|
|
|
def create_tables(): |
896
|
|
|
"""Create tables for eTraGo input data. |
897
|
|
|
Returns |
898
|
|
|
------- |
899
|
|
|
None. |
900
|
|
|
""" |
901
|
|
|
db.execute_sql("CREATE SCHEMA IF NOT EXISTS grid;") |
902
|
|
|
engine = db.engine() |
903
|
|
|
|
904
|
|
|
##################### drop tables with old names ######################### |
905
|
|
|
db.execute_sql( |
906
|
|
|
""" |
907
|
|
|
DROP TABLE IF EXISTS grid.egon_pf_hv_bus;""" |
908
|
|
|
) |
909
|
|
|
db.execute_sql( |
910
|
|
|
""" |
911
|
|
|
DROP TABLE IF EXISTS grid.egon_pf_hv_bus_timeseries;""" |
912
|
|
|
) |
913
|
|
|
db.execute_sql( |
914
|
|
|
""" |
915
|
|
|
DROP TABLE IF EXISTS grid.egon_pf_hv_carrier;""" |
916
|
|
|
) |
917
|
|
|
db.execute_sql( |
918
|
|
|
""" |
919
|
|
|
DROP TABLE IF EXISTS grid.egon_pf_hv_generator;""" |
920
|
|
|
) |
921
|
|
|
db.execute_sql( |
922
|
|
|
""" |
923
|
|
|
DROP TABLE IF EXISTS grid.egon_pf_hv_generator_timeseries;""" |
924
|
|
|
) |
925
|
|
|
db.execute_sql( |
926
|
|
|
""" |
927
|
|
|
DROP TABLE IF EXISTS grid.egon_pf_hv_line;""" |
928
|
|
|
) |
929
|
|
|
db.execute_sql( |
930
|
|
|
""" |
931
|
|
|
DROP TABLE IF EXISTS grid.egon_pf_hv_line_timeseries;""" |
932
|
|
|
) |
933
|
|
|
db.execute_sql( |
934
|
|
|
""" |
935
|
|
|
DROP TABLE IF EXISTS grid.egon_pf_hv_link;""" |
936
|
|
|
) |
937
|
|
|
db.execute_sql( |
938
|
|
|
""" |
939
|
|
|
DROP TABLE IF EXISTS grid.egon_pf_hv_link_timeseries;""" |
940
|
|
|
) |
941
|
|
|
db.execute_sql( |
942
|
|
|
""" |
943
|
|
|
DROP TABLE IF EXISTS grid.egon_pf_hv_load;""" |
944
|
|
|
) |
945
|
|
|
db.execute_sql( |
946
|
|
|
""" |
947
|
|
|
DROP TABLE IF EXISTS grid.egon_pf_hv_load_timeseries;""" |
948
|
|
|
) |
949
|
|
|
db.execute_sql( |
950
|
|
|
""" |
951
|
|
|
DROP TABLE IF EXISTS grid.egon_pf_hv_storage;""" |
952
|
|
|
) |
953
|
|
|
db.execute_sql( |
954
|
|
|
""" |
955
|
|
|
DROP TABLE IF EXISTS grid.egon_pf_hv_storage_timeseries;""" |
956
|
|
|
) |
957
|
|
|
db.execute_sql( |
958
|
|
|
""" |
959
|
|
|
DROP TABLE IF EXISTS grid.egon_pf_hv_store;""" |
960
|
|
|
) |
961
|
|
|
db.execute_sql( |
962
|
|
|
""" |
963
|
|
|
DROP TABLE IF EXISTS grid.egon_pf_hv_store_timeseries;""" |
964
|
|
|
) |
965
|
|
|
db.execute_sql( |
966
|
|
|
""" |
967
|
|
|
DROP TABLE IF EXISTS grid.egon_pf_hv_temp_resolution;""" |
968
|
|
|
) |
969
|
|
|
db.execute_sql( |
970
|
|
|
""" |
971
|
|
|
DROP TABLE IF EXISTS grid.egon_pf_hv_transformer;""" |
972
|
|
|
) |
973
|
|
|
db.execute_sql( |
974
|
|
|
""" |
975
|
|
|
DROP TABLE IF EXISTS grid.egon_pf_hv_transformer_timeseries;""" |
976
|
|
|
) |
977
|
|
|
########################################################################## |
978
|
|
|
|
979
|
|
|
# Drop existing tables |
980
|
|
|
EgonPfHvBus.__table__.drop(bind=engine, checkfirst=True) |
981
|
|
|
EgonPfHvBusTimeseries.__table__.drop(bind=engine, checkfirst=True) |
982
|
|
|
EgonPfHvGenerator.__table__.drop(bind=engine, checkfirst=True) |
983
|
|
|
EgonPfHvGeneratorTimeseries.__table__.drop(bind=engine, checkfirst=True) |
984
|
|
|
EgonPfHvLine.__table__.drop(bind=engine, checkfirst=True) |
985
|
|
|
EgonPfHvLineTimeseries.__table__.drop(bind=engine, checkfirst=True) |
986
|
|
|
EgonPfHvLink.__table__.drop(bind=engine, checkfirst=True) |
987
|
|
|
EgonPfHvLinkTimeseries.__table__.drop(bind=engine, checkfirst=True) |
988
|
|
|
EgonPfHvLoad.__table__.drop(bind=engine, checkfirst=True) |
989
|
|
|
EgonPfHvLoadTimeseries.__table__.drop(bind=engine, checkfirst=True) |
990
|
|
|
EgonPfHvCarrier.__table__.drop(bind=engine, checkfirst=True) |
991
|
|
|
EgonPfHvStorage.__table__.drop(bind=engine, checkfirst=True) |
992
|
|
|
EgonPfHvStorageTimeseries.__table__.drop(bind=engine, checkfirst=True) |
993
|
|
|
EgonPfHvStore.__table__.drop(bind=engine, checkfirst=True) |
994
|
|
|
EgonPfHvStoreTimeseries.__table__.drop(bind=engine, checkfirst=True) |
995
|
|
|
EgonPfHvTempResolution.__table__.drop(bind=engine, checkfirst=True) |
996
|
|
|
EgonPfHvTransformer.__table__.drop(bind=engine, checkfirst=True) |
997
|
|
|
EgonPfHvTransformerTimeseries.__table__.drop(bind=engine, checkfirst=True) |
998
|
|
|
EgonPfHvBusmap.__table__.drop(bind=engine, checkfirst=True) |
999
|
|
|
# Create new tables |
1000
|
|
|
EgonPfHvBus.__table__.create(bind=engine, checkfirst=True) |
1001
|
|
|
EgonPfHvBusTimeseries.__table__.create(bind=engine, checkfirst=True) |
1002
|
|
|
EgonPfHvGenerator.__table__.create(bind=engine, checkfirst=True) |
1003
|
|
|
EgonPfHvGeneratorTimeseries.__table__.create(bind=engine, checkfirst=True) |
1004
|
|
|
EgonPfHvLine.__table__.create(bind=engine, checkfirst=True) |
1005
|
|
|
EgonPfHvLineTimeseries.__table__.create(bind=engine, checkfirst=True) |
1006
|
|
|
EgonPfHvLink.__table__.create(bind=engine, checkfirst=True) |
1007
|
|
|
EgonPfHvLinkTimeseries.__table__.create(bind=engine, checkfirst=True) |
1008
|
|
|
EgonPfHvLoad.__table__.create(bind=engine, checkfirst=True) |
1009
|
|
|
EgonPfHvLoadTimeseries.__table__.create(bind=engine, checkfirst=True) |
1010
|
|
|
EgonPfHvCarrier.__table__.create(bind=engine, checkfirst=True) |
1011
|
|
|
EgonPfHvStorage.__table__.create(bind=engine, checkfirst=True) |
1012
|
|
|
EgonPfHvStorageTimeseries.__table__.create(bind=engine, checkfirst=True) |
1013
|
|
|
EgonPfHvStore.__table__.create(bind=engine, checkfirst=True) |
1014
|
|
|
EgonPfHvStoreTimeseries.__table__.create(bind=engine, checkfirst=True) |
1015
|
|
|
EgonPfHvTempResolution.__table__.create(bind=engine, checkfirst=True) |
1016
|
|
|
EgonPfHvTransformer.__table__.create(bind=engine, checkfirst=True) |
1017
|
|
|
EgonPfHvTransformerTimeseries.__table__.create( |
1018
|
|
|
bind=engine, checkfirst=True |
1019
|
|
|
) |
1020
|
|
|
EgonPfHvBusmap.__table__.create(bind=engine, checkfirst=True) |
1021
|
|
|
|
1022
|
|
|
|
1023
|
|
|
def temp_resolution(): |
1024
|
|
|
"""Insert temporal resolution for etrago |
1025
|
|
|
|
1026
|
|
|
Returns |
1027
|
|
|
------- |
1028
|
|
|
None. |
1029
|
|
|
|
1030
|
|
|
""" |
1031
|
|
|
|
1032
|
|
|
db.execute_sql( |
1033
|
|
|
""" |
1034
|
|
|
INSERT INTO grid.egon_etrago_temp_resolution |
1035
|
|
|
(temp_id, timesteps, resolution, start_time) |
1036
|
|
|
SELECT 1, 8760, 'h', TIMESTAMP '2011-01-01 00:00:00'; |
1037
|
|
|
""" |
1038
|
|
|
) |
1039
|
|
|
|
1040
|
|
|
|
1041
|
|
|
def insert_carriers(): |
1042
|
|
|
"""Insert list of carriers into eTraGo table |
1043
|
|
|
|
1044
|
|
|
Returns |
1045
|
|
|
------- |
1046
|
|
|
None. |
1047
|
|
|
|
1048
|
|
|
""" |
1049
|
|
|
# Delete existing entries |
1050
|
|
|
db.execute_sql( |
1051
|
|
|
""" |
1052
|
|
|
DELETE FROM grid.egon_etrago_carrier |
1053
|
|
|
""" |
1054
|
|
|
) |
1055
|
|
|
|
1056
|
|
|
# List carrier names from all components |
1057
|
|
|
df = pd.DataFrame( |
1058
|
|
|
data={ |
1059
|
|
|
"name": [ |
1060
|
|
|
"biogas", |
1061
|
|
|
"biogas_feedin", |
1062
|
|
|
"biogas_to_gas", |
1063
|
|
|
"biomass", |
1064
|
|
|
"pv", |
1065
|
|
|
"wind_offshore", |
1066
|
|
|
"wind_onshore", |
1067
|
|
|
"central_heat_pump", |
1068
|
|
|
"central_resistive_heater", |
1069
|
|
|
"CH4", |
1070
|
|
|
"CH4_for_industry", |
1071
|
|
|
"CH4_system_boundary", |
1072
|
|
|
"CH4_to_H2", |
1073
|
|
|
"dsm", |
1074
|
|
|
"H2", |
1075
|
|
|
"H2_feedin", |
1076
|
|
|
"H2_for_industry", |
1077
|
|
|
"H2_grid", |
1078
|
|
|
"H2_gridextension", |
1079
|
|
|
"H2_hgv_load", |
1080
|
|
|
"H2_overground", |
1081
|
|
|
"H2_retrofit", |
1082
|
|
|
"H2_saltcavern", |
1083
|
|
|
"H2_system_boundary", |
1084
|
|
|
"H2_to_CH4", |
1085
|
|
|
"H2_to_power", |
1086
|
|
|
"H2_underground", |
1087
|
|
|
"rural_heat_pump", |
1088
|
|
|
"industrial_biomass_CHP", |
1089
|
|
|
"industrial_gas_CHP", |
1090
|
|
|
"central_biomass_CHP_heat", |
1091
|
|
|
"central_biomass_CHP", |
1092
|
|
|
"central_gas_CHP", |
1093
|
|
|
"central_gas_CHP_heat", |
1094
|
|
|
"power_to_H2", |
1095
|
|
|
"rural_gas_boiler", |
1096
|
|
|
"central_gas_boiler", |
1097
|
|
|
"solar_thermal_collector", |
1098
|
|
|
"geo_thermal", |
1099
|
|
|
"AC", |
1100
|
|
|
"central_heat", |
1101
|
|
|
"rural_heat", |
1102
|
|
|
"natural_gas_feedin", |
1103
|
|
|
"pumped_hydro", |
1104
|
|
|
"battery", |
1105
|
|
|
"OCGT", |
1106
|
|
|
] |
1107
|
|
|
} |
1108
|
|
|
) |
1109
|
|
|
|
1110
|
|
|
# Insert data into database |
1111
|
|
|
df.to_sql( |
1112
|
|
|
"egon_etrago_carrier", |
1113
|
|
|
schema="grid", |
1114
|
|
|
con=db.engine(), |
1115
|
|
|
if_exists="append", |
1116
|
|
|
index=False, |
1117
|
|
|
) |
1118
|
|
|
|
1119
|
|
|
|
1120
|
|
|
def check_carriers(): |
1121
|
|
|
"""Check if any eTraGo table has carriers not included in the carrier table. |
1122
|
|
|
|
1123
|
|
|
Raises |
1124
|
|
|
------ |
1125
|
|
|
ValueError if carriers that are not defined in the carriers table are |
1126
|
|
|
used in any eTraGo table. |
1127
|
|
|
""" |
1128
|
|
|
carriers = db.select_dataframe( |
1129
|
|
|
f""" |
1130
|
|
|
SELECT name FROM grid.egon_etrago_carrier |
1131
|
|
|
""" |
1132
|
|
|
) |
1133
|
|
|
unknown_carriers = {} |
1134
|
|
|
tables = ["bus", "store", "storage", "link", "line", "generator", "load"] |
1135
|
|
|
|
1136
|
|
|
for table in tables: |
1137
|
|
|
# Delete existing entries |
1138
|
|
|
data = db.select_dataframe( |
1139
|
|
|
f""" |
1140
|
|
|
SELECT carrier FROM grid.egon_etrago_{table} |
1141
|
|
|
""" |
1142
|
|
|
) |
1143
|
|
|
unknown_carriers[table] = data[~data["carrier"].isin(carriers)][ |
1144
|
|
|
"carrier" |
1145
|
|
|
].unique() |
1146
|
|
|
|
1147
|
|
|
if len(unknown_carriers) > 0: |
1148
|
|
|
msg = ( |
1149
|
|
|
"The eTraGo tables contain carriers, that are not included in the " |
1150
|
|
|
"carrier table:\n" |
1151
|
|
|
) |
1152
|
|
|
for table, carriers in unknown_carriers.items(): |
1153
|
|
|
carriers = [str(c) for c in carriers] |
1154
|
|
|
if len(carriers) > 0: |
1155
|
|
|
msg += table + ": '" + "', '".join(carriers) + "'\n" |
1156
|
|
|
|
1157
|
|
|
raise ValueError(msg) |
1158
|
|
|
|
1159
|
|
|
|
1160
|
|
|
def link_geom_from_buses(df, scn_name): |
1161
|
|
|
"""Add LineString geometry accoring to geometry of buses to links |
1162
|
|
|
|
1163
|
|
|
Parameters |
1164
|
|
|
---------- |
1165
|
|
|
df : pandas.DataFrame |
1166
|
|
|
List of eTraGo links with bus0 and bus1 but without topology |
1167
|
|
|
scn_name : str |
1168
|
|
|
Scenario name |
1169
|
|
|
|
1170
|
|
|
Returns |
1171
|
|
|
------- |
1172
|
|
|
gdf : geopandas.GeoDataFrame |
1173
|
|
|
List of eTraGo links with bus0 and bus1 but with topology |
1174
|
|
|
|
1175
|
|
|
""" |
1176
|
|
|
|
1177
|
|
|
geom_buses = db.select_geodataframe( |
1178
|
|
|
f""" |
1179
|
|
|
SELECT bus_id, geom |
1180
|
|
|
FROM grid.egon_etrago_bus |
1181
|
|
|
WHERE scn_name = '{scn_name}' |
1182
|
|
|
""", |
1183
|
|
|
index_col="bus_id", |
1184
|
|
|
epsg=4326, |
1185
|
|
|
) |
1186
|
|
|
|
1187
|
|
|
# Create geometry columns for bus0 and bus1 |
1188
|
|
|
df["geom_0"] = geom_buses.geom[df.bus0.values].values |
1189
|
|
|
df["geom_1"] = geom_buses.geom[df.bus1.values].values |
1190
|
|
|
|
1191
|
|
|
geometry = df.apply( |
1192
|
|
|
lambda x: LineString([x["geom_0"], x["geom_1"]]), axis=1 |
1193
|
|
|
) |
1194
|
|
|
df = df.drop(["geom_0", "geom_1"], axis=1) |
1195
|
|
|
|
1196
|
|
|
gdf = gpd.GeoDataFrame(df, geometry=geometry, crs=4326).rename_geometry( |
1197
|
|
|
"topo" |
1198
|
|
|
) |
1199
|
|
|
|
1200
|
|
|
return gdf |
1201
|
|
|
|