Skip to content

Commit

Permalink
Merge pull request #328 from openego/features/#323-egon-data-link
Browse files Browse the repository at this point in the history
Features/#323 egon data link
  • Loading branch information
birgits authored Mar 31, 2023
2 parents 0db2091 + b2547c8 commit c043a79
Show file tree
Hide file tree
Showing 50 changed files with 16,227 additions and 12,508 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 22.8.0
rev: 22.10.0
hooks:
- id: black
- repo: https://github.com/pycqa/flake8
Expand All @@ -19,14 +19,14 @@ repos:
- id: isort
name: isort (python)
- repo: https://github.com/asottile/pyupgrade
rev: v2.38.0
rev: v3.2.0
hooks:
- id: pyupgrade
#- repo: https://github.com/pycqa/pylint
# rev: pylint-2.6.0
# hooks:
# - id: pylint
- repo: https://github.com/kynan/nbstripout
rev: 0.6.0
rev: 0.6.1
hooks:
- id: nbstripout
6 changes: 6 additions & 0 deletions doc/dev_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,9 @@ To manually check if external links in the documentation work, you can run the f
sphinx-build ./doc/ -b linkcheck -d _build/doctrees _build/html
Internal links can be checked adding -n option when building the documentation. This will
also raise warnings for type hinting, so it is a bit confusing, but can still be helpful.

.. code-block:: bash
sphinx-build -n -E -a -b html ./doc/ <outputdir>
2 changes: 1 addition & 1 deletion doc/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ time series:
# load time series (scaled by annual demand)
timeseries_load = pd.DataFrame(
{"residential": [0.0001] * len(timeindex),
"retail": [0.0002] * len(timeindex),
"cts": [0.0002] * len(timeindex),
"industrial": [0.00015] * len(timeindex),
"agricultural": [0.00005] * len(timeindex)
},
Expand Down
1 change: 1 addition & 0 deletions doc/whatsnew/v0-3-0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Release date: <month> <day>, <year>
Changes
-------

* Added functionalities to obtain electromobility, DSM, storage and electricity timeseries data from oedb `#328 <https://github.com/openego/eDisGo/pull/328>`_
* Added functionalities to obtain heat pump data from oedb `#324 <https://github.com/openego/eDisGo/pull/324>`_
* Added functionality to resample and check integrity of flexibility bands `#341 <https://github.com/openego/eDisGo/pull/341>`_
* Added function to sort buses in lines dataframe such that bus0 is always the upstream bus `#335 <https://github.com/openego/eDisGo/pull/335>`_
Expand Down
751 changes: 531 additions & 220 deletions edisgo/edisgo.py

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions edisgo/flex_opt/costs.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def grid_expansion_costs(edisgo_obj, without_generator_import=False):
Attributes
----------
edisgo_obj : :class:`~.self.edisgo.EDisGo`
edisgo_obj : :class:`~.EDisGo`
without_generator_import : bool
If True excludes lines that were added in the generator import to
connect new generators to the topology from calculation of topology expansion
Expand Down Expand Up @@ -213,7 +213,7 @@ def line_expansion_costs(edisgo_obj, lines_names=None):
Parameters
-----------
edisgo_obj : :class:`~.edisgo.EDisGo`
edisgo_obj : :class:`~.EDisGo`
eDisGo object
lines_names: None or list(str)
List of names of lines to return cost information for. If None, it is returned
Expand Down
6 changes: 3 additions & 3 deletions edisgo/flex_opt/reinforce_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ def reinforce_grid(
conducted and therefore which time steps to consider when checking
for over-loading and over-voltage issues.
It defaults to None in which case all timesteps in
timeseries.timeindex (see :class:`~.network.network.TimeSeries`) are
timeseries.timeindex (see :class:`~.network.timeseries.TimeSeries`) are
used.
Possible options are:
* None
Time steps in timeseries.timeindex (see
:class:`~.network.network.TimeSeries`) are used.
:class:`~.network.timeseries.TimeSeries`) are used.
* 'snapshot_analysis'
Reinforcement is conducted for two worst-case snapshots. See
:meth:`edisgo.tools.tools.select_worstcase_snapshots()` for further
Expand Down Expand Up @@ -96,7 +96,7 @@ def reinforce_grid(
Returns
-------
:class:`~.network.network.Results`
:class:`~.network.results.Results`
Returns the Results object holding network expansion costs, equipment
changes, etc.
Expand Down
22 changes: 18 additions & 4 deletions edisgo/io/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def session_scope_egon_data(engine: Engine):

def sql_grid_geom(edisgo_obj: EDisGo) -> Geometry:
return func.ST_GeomFromText(
str(edisgo_obj.topology.grid_district["geom"]),
edisgo_obj.topology.grid_district["geom"].wkt,
edisgo_obj.topology.grid_district["srid"],
)

Expand All @@ -215,14 +215,28 @@ def get_srid_of_db_table(session: Session, geom_col: InstrumentedAttribute) -> i
return pd.read_sql(sql=query.statement, con=query.session.bind).iat[0, 0]


def sql_within(geom_col: InstrumentedAttribute, geom_shape: Geometry, srid: int):
def sql_within(geom_a: Geometry, geom_b: Geometry, srid: int):
"""
Checks if geometry a is completely within geometry b.
Parameters
----------
geom_a : Geometry
Geometry within `geom_b`.
geom_b : Geometry
Geometry containing `geom_a`.
srid : int
SRID geometries are transformed to in order to use the same SRID for both
geometries.
"""
return func.ST_Within(
func.ST_Transform(
geom_col,
geom_a,
srid,
),
func.ST_Transform(
geom_shape,
geom_b,
srid,
),
)
Expand Down
2 changes: 2 additions & 0 deletions edisgo/io/ding0_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,10 @@ def sort_hvmv_transformer_buses(transformers_df):
# set up columns that are added in new ding0 version
grid.loads["building_id"] = None
grid.loads["number_households"] = None
grid.generators["source_id"] = None
else:
edisgo_obj.topology.buses_df["in_building"] = False
grid.generators = grid.generators.rename(columns={"gens_id": "source_id"})
edisgo_obj.topology.loads_df = grid.loads[edisgo_obj.topology.loads_df.columns]
# drop slack generator from generators
slack = grid.generators.loc[grid.generators.control == "Slack"].index
Expand Down
Loading

0 comments on commit c043a79

Please sign in to comment.