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