Merge branch 'energy_totals' of https://github.com/PyPSA/pypsa-eur into energy_totals
This commit is contained in:
commit
ae187b8ba3
@ -160,14 +160,17 @@ if config["enable"]["retrieve"] and config["enable"].get(
|
|||||||
rule retrieve_eurostat_data:
|
rule retrieve_eurostat_data:
|
||||||
output:
|
output:
|
||||||
protected(
|
protected(
|
||||||
directory("data/bundle-sector/eurostat-energy_balances-april_2023_edition")
|
directory(
|
||||||
),
|
"data/bundle-sector/eurostat-energy_balances-april_2023_edition"
|
||||||
|
)
|
||||||
|
),
|
||||||
log:
|
log:
|
||||||
"logs/retrieve_eurostat_data.log",
|
"logs/retrieve_eurostat_data.log",
|
||||||
retries: 2
|
retries: 2
|
||||||
script:
|
script:
|
||||||
"../scripts/retrieve_eurostat_data.py"
|
"../scripts/retrieve_eurostat_data.py"
|
||||||
|
|
||||||
|
|
||||||
if config["enable"]["retrieve"]:
|
if config["enable"]["retrieve"]:
|
||||||
datafiles = [
|
datafiles = [
|
||||||
"IGGIELGN_LNGs.geojson",
|
"IGGIELGN_LNGs.geojson",
|
||||||
|
@ -11,11 +11,7 @@ import logging
|
|||||||
import zipfile
|
import zipfile
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from _helpers import (
|
from _helpers import configure_logging, progress_retrieve, set_scenario_config
|
||||||
configure_logging,
|
|
||||||
progress_retrieve,
|
|
||||||
set_scenario_config,
|
|
||||||
)
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -33,13 +29,15 @@ if __name__ == "__main__":
|
|||||||
disable_progress = snakemake.config["run"].get("disable_progressbar", False)
|
disable_progress = snakemake.config["run"].get("disable_progressbar", False)
|
||||||
url_eurostat = "https://ec.europa.eu/eurostat/documents/38154/4956218/Balances-December2022.zip/f7cf0d19-5c0f-60ad-4e48-098a5ddd6e48?t=1671184070589"
|
url_eurostat = "https://ec.europa.eu/eurostat/documents/38154/4956218/Balances-December2022.zip/f7cf0d19-5c0f-60ad-4e48-098a5ddd6e48?t=1671184070589"
|
||||||
tarball_fn = Path(f"{rootpath}/data/bundle-sector/eurostat_2023.zip")
|
tarball_fn = Path(f"{rootpath}/data/bundle-sector/eurostat_2023.zip")
|
||||||
to_fn = Path(f"{rootpath}/data/bundle-sector/eurostat-energy_balances-april_2023_edition/")
|
to_fn = Path(
|
||||||
|
f"{rootpath}/data/bundle-sector/eurostat-energy_balances-april_2023_edition/"
|
||||||
|
)
|
||||||
|
|
||||||
logger.info(f"Downloading Eurostat data from '{url_eurostat}'.")
|
logger.info(f"Downloading Eurostat data from '{url_eurostat}'.")
|
||||||
progress_retrieve(url_eurostat, tarball_fn, disable=disable_progress)
|
progress_retrieve(url_eurostat, tarball_fn, disable=disable_progress)
|
||||||
|
|
||||||
logger.info("Extracting Eurostat data.")
|
logger.info("Extracting Eurostat data.")
|
||||||
with zipfile.ZipFile(tarball_fn, 'r') as zip_ref:
|
with zipfile.ZipFile(tarball_fn, "r") as zip_ref:
|
||||||
zip_ref.extractall(to_fn)
|
zip_ref.extractall(to_fn)
|
||||||
|
|
||||||
logger.info(f"Eurostat data available in '{to_fn}'.")
|
logger.info(f"Eurostat data available in '{to_fn}'.")
|
Loading…
Reference in New Issue
Block a user