Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes/#344 set osmosis temp dir #345

Merged
merged 8 commits into from
Jul 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Authors
=======

* Guido Pleßmann, Ilka Cußman, Stephan Günther - https://github.com/openego/eGon-data
* Guido Pleßmann, Ilka Cußman, Stephan Günther, Jonathan Amme - https://github.com/openego/eGon-data
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -192,3 +192,5 @@ Bug fixes
`#258 <https://github.com/openego/eGon-data/issues/258>`_
* Fix conflicting docker containers by setting a project name
`#289 <https://github.com/openego/eGon-data/issues/289>`_
* Set current working directory as java's temp dir when executing osmosis
`#344 <https://github.com/openego/eGon-data/issues/344>`_
11 changes: 9 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,12 @@ packages are required too. Right now these are:
* To download ERA5 weather data you need to register at the CDS
registration page and install the CDS API key as described
`here <https://cds.climate.copernicus.eu/api-how-to>`_
You also have to agree on the `terms of use
You also have to agree on the `terms of use
<https://cds.climate.copernicus.eu/cdsapp/#!/terms/licence-to-use-copernicus-products>`_

* Make sure you have enough free disk space (~350 GB) in your working
directory.

Installation
============

Expand Down Expand Up @@ -188,6 +191,10 @@ solution.
can't be run on laptop. Use the :ref:`test mode <Test mode>` for
experimenting.

.. warning::

A complete run of the workflow needs loads of free disk space (~350 GB) to
store (temporary) files.

Test mode
---------
Expand All @@ -206,4 +213,4 @@ Data is reduced during execution of the workflow to represent only this area.
Further Reading
===============

You can find more in depth documentation at https://eGon-data.readthedocs.io.
You can find more in-depth documentation at https://eGon-data.readthedocs.io.
22 changes: 13 additions & 9 deletions src/egon/data/processing/osmtgmod/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import datetime
import logging
import codecs
from pathlib import Path
import egon.data.config
from egon.data.config import settings
import egon.data.subprocess as subproc
Expand All @@ -25,8 +26,7 @@ def run_osmtgmod():
target_path = osm_config["target"]["path_testmode"]

filtered_osm_pbf_path_to_file = os.path.join(
egon.data.__path__[0] + "/datasets" + "/osm/"
+ target_path
egon.data.__path__[0], "datasets", "osm", target_path
)
docker_db_config = db.credentials()

Expand All @@ -53,7 +53,7 @@ def import_osm_data():
)

else:
subproc.run(
subproc.run(
[
"git",
"clone",
Expand All @@ -74,8 +74,7 @@ def import_osm_data():
target_path = osm_config["target"]["path_testmode"]

filtered_osm_pbf_path_to_file = os.path.join(
egon.data.__path__[0] + "/datasets" + "/osm/"
+ target_path
egon.data.__path__[0], "datasets", "osm", target_path
)

docker_db_config=db.credentials()
Expand Down Expand Up @@ -141,13 +140,19 @@ def import_osm_data():
{config['osm_data']['osmosis_path_to_binary']}"""
)

# create directory to store osmosis' temp files
osmosis_temp_dir = Path('.') / "osmosis_temp/"
if not os.path.exists(osmosis_temp_dir):
os.mkdir(osmosis_temp_dir)

subproc.run(
"%s --read-pbf %s --write-pgsql \
"JAVACMD_OPTIONS='%s' %s --read-pbf %s --write-pgsql \
database=%s host=%s user=%s password=%s"
% (
f"-Djava.io.tmpdir={osmosis_temp_dir}",
os.path.join(egon.data.__path__[0],
"processing/osmtgmod/osmTGmod/",
config["osm_data"]["osmosis_path_to_binary"]),
"processing/osmtgmod/osmTGmod/",
config["osm_data"]["osmosis_path_to_binary"]),
filtered_osm_pbf_path_to_file,
config_database,
config["postgres_server"]["host"]
Expand All @@ -160,7 +165,6 @@ def import_osm_data():
)
logging.info("Importing OSM-Data...")


# After updating OSM-Data, power_tables (for editing)
# have to be updated as well
logging.info("Creating power-tables...")
Expand Down