Skip to content

Commit

Permalink
Merge pull request #841 from openego/features/#803_pes_buses
Browse files Browse the repository at this point in the history
Add coordinates to non AC buses abroad in eGon100RE
  • Loading branch information
AmeliaNadal committed Jul 27, 2022
2 parents 8c1355b + 69c3a0f commit c8c2db7
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,8 @@ Changed
`#787 <https://github.com/openego/eGon-data/issues/787>`_
* Update pypsa-eur-sec fork and store national demand time series
`#402 <https://github.com/openego/eGon-data/issues/402>`_
* Add coordinates to non AC buses abroad in eGon100RE
`#803 <https://github.com/openego/eGon-data/issues/803>`_

Bug Fixes
---------
Expand Down
31 changes: 26 additions & 5 deletions src/egon/data/datasets/pypsaeursec/__init__.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

from egon.data import __path__, db
from egon.data.datasets import Dataset
from egon.data.datasets.scenario_parameters import get_sector_parameters
import egon.data.config
import egon.data.subprocess as subproc
from egon.data.datasets.scenario_parameters import get_sector_parameters


def run_pypsa_eur_sec():
Expand Down Expand Up @@ -481,13 +481,34 @@ def neighbor_reduction():
# Connect to local database
engine = db.engine()

# db.execute_sql("DELETE FROM grid.egon_etrago_bus "
# "WHERE scn_name = 'eGon100RE' "
# "AND country <> 'DE'")
db.execute_sql(
"DELETE FROM grid.egon_etrago_bus "
"WHERE scn_name = 'eGon100RE' "
"AND country <> 'DE'"
)

neighbors["scn_name"] = "eGon100RE"
neighbors.index = neighbors["new_index"]

# Correct geometry for non AC buses
carriers = set(neighbors.carrier.to_list())
carriers.remove("AC")
non_AC_neighbors = pd.DataFrame()
for c in carriers:
c_neighbors = neighbors[neighbors.carrier == c].set_index(
"location", drop=False
)
for i in ["x", "y"]:
c_neighbors = c_neighbors.drop(i, axis=1)
coordinates = neighbors[neighbors.carrier == "AC"][
["location", "x", "y"]
].set_index("location")
c_neighbors = pd.concat([coordinates, c_neighbors], axis=1).set_index(
"new_index", drop=False
)
non_AC_neighbors = non_AC_neighbors.append(c_neighbors)
neighbors = neighbors[neighbors.carrier == "AC"].append(non_AC_neighbors)

for i in ["new_index", "control", "generator", "location", "sub_network"]:
neighbors = neighbors.drop(i, axis=1)

Expand Down Expand Up @@ -837,7 +858,7 @@ class PypsaEurSec(Dataset):
def __init__(self, dependencies):
super().__init__(
name="PypsaEurSec",
version="0.0.5",
version="0.0.6",
dependencies=dependencies,
tasks=tasks,
)
Empty file modified src/egon/data/datasets/storages/__init__.py
100644 → 100755
Empty file.

0 comments on commit c8c2db7

Please sign in to comment.