2023-08-06 07:01:56 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2024-02-19 15:21:48 +00:00
|
|
|
# SPDX-FileCopyrightText: : 2023-2024 The PyPSA-Eur Authors
|
2023-08-06 07:01:56 +00:00
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
"""
|
|
|
|
Retrieve monthly fuel prices from Destatis.
|
|
|
|
"""
|
|
|
|
|
|
|
|
import logging
|
|
|
|
from pathlib import Path
|
|
|
|
|
2023-08-15 13:02:41 +00:00
|
|
|
from _helpers import configure_logging, progress_retrieve, set_scenario_config
|
2023-08-06 07:01:56 +00:00
|
|
|
|
2024-01-19 11:16:07 +00:00
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
2023-08-06 07:01:56 +00:00
|
|
|
if __name__ == "__main__":
|
|
|
|
if "snakemake" not in globals():
|
|
|
|
from _helpers import mock_snakemake
|
|
|
|
|
|
|
|
snakemake = mock_snakemake("retrieve_monthly_fuel_prices")
|
|
|
|
rootpath = ".."
|
|
|
|
else:
|
|
|
|
rootpath = "."
|
|
|
|
configure_logging(snakemake)
|
2023-08-15 13:02:41 +00:00
|
|
|
set_scenario_config(snakemake)
|
2023-08-06 07:01:56 +00:00
|
|
|
|
|
|
|
url = "https://www.destatis.de/EN/Themes/Economy/Prices/Publications/Downloads-Energy-Price-Trends/energy-price-trends-xlsx-5619002.xlsx?__blob=publicationFile"
|
|
|
|
|
|
|
|
to_fn = Path(rootpath) / Path(snakemake.output[0])
|
|
|
|
|
|
|
|
logger.info(f"Downloading monthly fuel prices from '{url}'.")
|
|
|
|
disable_progress = snakemake.config["run"].get("disable_progressbar", False)
|
|
|
|
progress_retrieve(url, to_fn, disable=disable_progress)
|
|
|
|
|
|
|
|
logger.info(f"Monthly fuel prices available at {to_fn}")
|