retrieve ammonia demand data
This commit is contained in:
parent
fb2ab4c50b
commit
314f6c6f0f
@ -65,6 +65,15 @@ if config["enable"]["retrieve"] and config["enable"].get("retrieve_databundle",
|
|||||||
script:
|
script:
|
||||||
"../scripts/retrieve_jrc_idees.py"
|
"../scripts/retrieve_jrc_idees.py"
|
||||||
|
|
||||||
|
rule retrieve_ammonia_demand:
|
||||||
|
output:
|
||||||
|
"data/bundle/myb1-2021-nitro-ert.xlsx",
|
||||||
|
log:
|
||||||
|
"logs/retrieve_ammonia_demand.log",
|
||||||
|
retries: 2
|
||||||
|
script:
|
||||||
|
"../scripts/retrieve_ammonia_demand.py"
|
||||||
|
|
||||||
rule retrieve_eurostat_household_data:
|
rule retrieve_eurostat_household_data:
|
||||||
output:
|
output:
|
||||||
"data/eurostat/eurostat-household_energy_balances-february_2024.csv",
|
"data/eurostat/eurostat-household_energy_balances-february_2024.csv",
|
||||||
|
42
scripts/retrieve_ammonia_demand.py
Normal file
42
scripts/retrieve_ammonia_demand.py
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# SPDX-FileCopyrightText: : 2024- The PyPSA-Eur Authors
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
"""
|
||||||
|
Retrieve ammonia demand from https://www.usgs.gov/centers/national-minerals-information-center/nitrogen-statistics-and-information.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import logging
|
||||||
|
import os
|
||||||
|
import zipfile
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
from _helpers import configure_logging, progress_retrieve, set_scenario_config
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
# Define the base URL
|
||||||
|
url = "https://d9-wret.s3.us-west-2.amazonaws.com/assets/palladium/production/s3fs-public/media/files/myb1-2022-nitro-ert.xlsx"
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
if "snakemake" not in globals():
|
||||||
|
from _helpers import mock_snakemake
|
||||||
|
|
||||||
|
snakemake = mock_snakemake("retrieve_ammonia_demand")
|
||||||
|
rootpath = ".."
|
||||||
|
else:
|
||||||
|
rootpath = "."
|
||||||
|
|
||||||
|
configure_logging(snakemake)
|
||||||
|
set_scenario_config(snakemake)
|
||||||
|
disable_progress = snakemake.config["run"].get("disable_progressbar", False)
|
||||||
|
|
||||||
|
to_fn = snakemake.output[0]
|
||||||
|
|
||||||
|
|
||||||
|
# download .zip file
|
||||||
|
logger.info(f"Downloading Ammonia demand from {url}.")
|
||||||
|
progress_retrieve(url, to_fn, disable=disable_progress)
|
||||||
|
|
||||||
|
|
||||||
|
logger.info(f"Ammonia demand data available in '{to_fn}'.")
|
Loading…
Reference in New Issue
Block a user