|
@@ 374-431 (lines=58) @@
|
| 371 |
|
return load_ts_df, curves_individual |
| 372 |
|
|
| 373 |
|
|
| 374 |
|
def insert_sites_ind_load(): |
| 375 |
|
"""Inserts electrical industry loads assigned to osm landuse areas to the database |
| 376 |
|
|
| 377 |
|
Returns |
| 378 |
|
------- |
| 379 |
|
None. |
| 380 |
|
|
| 381 |
|
""" |
| 382 |
|
|
| 383 |
|
targets = egon.data.config.datasets()["electrical_load_curves_industry"][ |
| 384 |
|
"targets" |
| 385 |
|
] |
| 386 |
|
|
| 387 |
|
for scenario in ["eGon2035", "eGon100RE"]: |
| 388 |
|
|
| 389 |
|
# Delete existing data from database |
| 390 |
|
db.execute_sql( |
| 391 |
|
f""" |
| 392 |
|
DELETE FROM |
| 393 |
|
{targets['sites_load']['schema']}.{targets['sites_load']['table']} |
| 394 |
|
WHERE scn_name = '{scenario}' |
| 395 |
|
""" |
| 396 |
|
) |
| 397 |
|
|
| 398 |
|
# Delete existing data from database |
| 399 |
|
db.execute_sql( |
| 400 |
|
f""" |
| 401 |
|
DELETE FROM |
| 402 |
|
{targets['sites_load_individual']['schema']}. |
| 403 |
|
{targets['sites_load_individual']['table']} |
| 404 |
|
WHERE scn_name = '{scenario}' |
| 405 |
|
""" |
| 406 |
|
) |
| 407 |
|
|
| 408 |
|
# Calculate industrial load curves per bus |
| 409 |
|
data, curves_individual = calc_load_curves_ind_sites(scenario) |
| 410 |
|
data.index = data.index.rename(["bus", "wz"]) |
| 411 |
|
data["scn_name"] = scenario |
| 412 |
|
|
| 413 |
|
data.set_index(["scn_name"], inplace=True, append=True) |
| 414 |
|
|
| 415 |
|
# Insert into database |
| 416 |
|
data.to_sql( |
| 417 |
|
targets["sites_load"]["table"], |
| 418 |
|
schema=targets["sites_load"]["schema"], |
| 419 |
|
con=db.engine(), |
| 420 |
|
if_exists="append", |
| 421 |
|
) |
| 422 |
|
|
| 423 |
|
curves_individual['peak_load'] = np.array(curves_individual['p_set'].values.tolist()).max(axis=1) |
| 424 |
|
curves_individual['demand'] = np.array(curves_individual['p_set'].values.tolist()).sum(axis=1) |
| 425 |
|
curves_individual = identify_voltage_level(curves_individual) |
| 426 |
|
|
| 427 |
|
curves_individual.to_sql( |
| 428 |
|
targets["sites_load_individual"]["table"], |
| 429 |
|
schema=targets["sites_load_individual"]["schema"], |
| 430 |
|
con=db.engine(), |
| 431 |
|
if_exists="append", |
| 432 |
|
) |
| 433 |
|
|
|
@@ 216-271 (lines=56) @@
|
| 213 |
|
return load_ts_df, curves_individual |
| 214 |
|
|
| 215 |
|
|
| 216 |
|
def insert_osm_ind_load(): |
| 217 |
|
"""Inserts electrical industry loads assigned to osm landuse areas to the database |
| 218 |
|
|
| 219 |
|
Returns |
| 220 |
|
------- |
| 221 |
|
None. |
| 222 |
|
|
| 223 |
|
""" |
| 224 |
|
|
| 225 |
|
targets = egon.data.config.datasets()["electrical_load_curves_industry"][ |
| 226 |
|
"targets" |
| 227 |
|
] |
| 228 |
|
|
| 229 |
|
for scenario in ["eGon2035", "eGon100RE"]: |
| 230 |
|
|
| 231 |
|
# Delete existing data from database |
| 232 |
|
db.execute_sql( |
| 233 |
|
f""" |
| 234 |
|
DELETE FROM |
| 235 |
|
{targets['osm_load']['schema']}.{targets['osm_load']['table']} |
| 236 |
|
WHERE scn_name = '{scenario}' |
| 237 |
|
""" |
| 238 |
|
) |
| 239 |
|
|
| 240 |
|
db.execute_sql( |
| 241 |
|
f""" |
| 242 |
|
DELETE FROM |
| 243 |
|
{targets['osm_load_individual']['schema']}.{targets['osm_load_individual']['table']} |
| 244 |
|
WHERE scn_name = '{scenario}' |
| 245 |
|
""" |
| 246 |
|
) |
| 247 |
|
|
| 248 |
|
# Calculate cts load curves per mv substation (hvmv bus) |
| 249 |
|
data, curves_individual = calc_load_curves_ind_osm(scenario) |
| 250 |
|
data.index = data.index.rename("bus") |
| 251 |
|
data["scn_name"] = scenario |
| 252 |
|
|
| 253 |
|
data.set_index(["scn_name"], inplace=True, append=True) |
| 254 |
|
|
| 255 |
|
# Insert into database |
| 256 |
|
data.to_sql( |
| 257 |
|
targets["osm_load"]["table"], |
| 258 |
|
schema=targets["osm_load"]["schema"], |
| 259 |
|
con=db.engine(), |
| 260 |
|
if_exists="append", |
| 261 |
|
) |
| 262 |
|
|
| 263 |
|
curves_individual['peak_load'] = np.array(curves_individual['p_set'].values.tolist()).max(axis=1) |
| 264 |
|
curves_individual['demand'] = np.array(curves_individual['p_set'].values.tolist()).sum(axis=1) |
| 265 |
|
curves_individual = identify_voltage_level(curves_individual) |
| 266 |
|
|
| 267 |
|
curves_individual.to_sql( |
| 268 |
|
targets["osm_load_individual"]["table"], |
| 269 |
|
schema=targets["osm_load_individual"]["schema"], |
| 270 |
|
con=db.engine(), |
| 271 |
|
if_exists="append", |
| 272 |
|
) |
| 273 |
|
|
| 274 |
|
|