diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 28d0278a..2fb51c54 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -51,7 +51,7 @@ repos: # Formatting with "black" coding style - repo: https://github.com/psf/black-pre-commit-mirror - rev: 24.2.0 + rev: 24.3.0 hooks: # Format Python files - id: black diff --git a/doc/configtables/costs.csv b/doc/configtables/costs.csv index b69c0bf9..03933c18 100644 --- a/doc/configtables/costs.csv +++ b/doc/configtables/costs.csv @@ -1,6 +1,6 @@ ,Unit,Values,Description year,--,YYYY; e.g. '2030',Year for which to retrieve cost assumptions of ``resources/costs.csv``. -version,--,vX.X.X; e.g. 'v0.5.0',Version of ``technology-data`` repository to use. +version,--,vX.X.X or //vX.X.X; e.g. 'v0.5.0',Version of ``technology-data`` repository to use. If this string is of the form // then costs are instead retrieved from ``github.com//`` at the tag. rooftop_share,--,float,Share of rooftop PV when calculating capital cost of solar (joint rooftop and utility-scale PV). social_discountrate,p.u.,float,Social discount rate to compare costs in different investment periods. 0.02 corresponds to a social discount rate of 2%. fill_values,--,float,Default values if not specified for a technology in ``resources/costs.csv``. diff --git a/doc/release_notes.rst b/doc/release_notes.rst index 11fd3df7..21094250 100644 --- a/doc/release_notes.rst +++ b/doc/release_notes.rst @@ -82,6 +82,8 @@ Upcoming Release * Upgrade default techno-economic assumptions to ``technology-data`` v0.8.1. +* Add possibility to download cost data from custom fork of ``technology-data``. + * Linearly interpolate missing investment periods in year-dependent configuration options. diff --git a/rules/retrieve.smk b/rules/retrieve.smk index b2c1e8d6..ac296f79 100644 --- a/rules/retrieve.smk +++ b/rules/retrieve.smk @@ -50,7 +50,7 @@ if config["enable"].get("retrieve_irena"): onwind="data/existing_infrastructure/onwind_capacity_IRENA.csv", solar="data/existing_infrastructure/solar_capacity_IRENA.csv", log: - logs("retrieve_irena.log"), + "logs/retrieve_irena.log", resources: mem_mb=1000, retries: 2 diff --git a/scripts/add_electricity.py b/scripts/add_electricity.py index ac73cb1f..7e60203f 100755 --- a/scripts/add_electricity.py +++ b/scripts/add_electricity.py @@ -184,12 +184,13 @@ def sanitize_carriers(n, config): def sanitize_locations(n): - n.buses["x"] = n.buses.x.where(n.buses.x != 0, n.buses.location.map(n.buses.x)) - n.buses["y"] = n.buses.y.where(n.buses.y != 0, n.buses.location.map(n.buses.y)) - n.buses["country"] = n.buses.country.where( - n.buses.country.ne("") & n.buses.country.notnull(), - n.buses.location.map(n.buses.country), - ) + if "location" in n.buses.columns: + n.buses["x"] = n.buses.x.where(n.buses.x != 0, n.buses.location.map(n.buses.x)) + n.buses["y"] = n.buses.y.where(n.buses.y != 0, n.buses.location.map(n.buses.y)) + n.buses["country"] = n.buses.country.where( + n.buses.country.ne("") & n.buses.country.notnull(), + n.buses.location.map(n.buses.country), + ) def add_co2_emissions(n, costs, carriers): diff --git a/scripts/prepare_perfect_foresight.py b/scripts/prepare_perfect_foresight.py index f7e8495e..fea0cef4 100644 --- a/scripts/prepare_perfect_foresight.py +++ b/scripts/prepare_perfect_foresight.py @@ -537,5 +537,8 @@ if __name__ == "__main__": # set carbon constraints n = set_carbon_constraints(n) + # update meta + n.meta = dict(snakemake.config, **dict(wildcards=dict(snakemake.wildcards))) + # export network n.export_to_netcdf(snakemake.output[0]) diff --git a/scripts/retrieve_cost_data.py b/scripts/retrieve_cost_data.py index eb1ef041..39fcab7c 100644 --- a/scripts/retrieve_cost_data.py +++ b/scripts/retrieve_cost_data.py @@ -25,9 +25,10 @@ if __name__ == "__main__": set_scenario_config(snakemake) version = snakemake.params.version - baseurl = ( - f"https://raw.githubusercontent.com/PyPSA/technology-data/{version}/outputs/" - ) + if "/" in version: + baseurl = f"https://raw.githubusercontent.com/{version}/outputs" + else: + baseurl = f"https://raw.githubusercontent.com/PyPSA/technology-data/{version}/outputs/" filepath = Path(snakemake.output[0]) url = baseurl + filepath.name diff --git a/test.sh b/test.sh index d6007750..a3dfb65f 100755 --- a/test.sh +++ b/test.sh @@ -2,8 +2,12 @@ # # SPDX-License-Identifier: CC0-1.0 +set -x && \ + snakemake -call solve_elec_networks --configfile config/test/config.electricity.yaml --rerun-triggers=mtime && \ snakemake -call all --configfile config/test/config.overnight.yaml --rerun-triggers=mtime && \ snakemake -call all --configfile config/test/config.myopic.yaml --rerun-triggers=mtime && \ snakemake -call all --configfile config/test/config.perfect.yaml --rerun-triggers=mtime && \ -snakemake -call all --configfile config/test/config.scenarios.yaml --rerun-triggers=mtime -n +snakemake -call all --configfile config/test/config.scenarios.yaml --rerun-triggers=mtime -n && \ + +set +x