scenario-management: fix set_scenario_config function; apply config_provider to some direct inputs
This commit is contained in:
parent
9d4ce430cc
commit
91eff472a7
@ -214,19 +214,19 @@ rule build_renewable_profiles:
|
|||||||
corine=ancient("data/bundle/corine/g250_clc06_V18_5.tif"),
|
corine=ancient("data/bundle/corine/g250_clc06_V18_5.tif"),
|
||||||
natura=lambda w: (
|
natura=lambda w: (
|
||||||
RESOURCES + "natura.tiff"
|
RESOURCES + "natura.tiff"
|
||||||
if config["renewable"][w.technology]["natura"]
|
if config_provider("renewable", w.technology, "natura")(w)
|
||||||
else []
|
else []
|
||||||
),
|
),
|
||||||
gebco=ancient(
|
gebco=ancient(
|
||||||
lambda w: (
|
lambda w: (
|
||||||
"data/bundle/GEBCO_2014_2D.nc"
|
"data/bundle/GEBCO_2014_2D.nc"
|
||||||
if config["renewable"][w.technology].get("max_depth")
|
if config_provider("renewable", w.technology)(w).get("max_depth")
|
||||||
else []
|
else []
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
ship_density=lambda w: (
|
ship_density=lambda w: (
|
||||||
RESOURCES + "shipdensity_raster.tif"
|
RESOURCES + "shipdensity_raster.tif"
|
||||||
if "ship_threshold" in config["renewable"][w.technology].keys()
|
if "ship_threshold" in config_provider("renewable", w.technology)(w).keys()
|
||||||
else []
|
else []
|
||||||
),
|
),
|
||||||
country_shapes=RESOURCES + "country_shapes.geojson",
|
country_shapes=RESOURCES + "country_shapes.geojson",
|
||||||
@ -238,7 +238,7 @@ rule build_renewable_profiles:
|
|||||||
),
|
),
|
||||||
cutout=lambda w: "cutouts/"
|
cutout=lambda w: "cutouts/"
|
||||||
+ CDIR
|
+ CDIR
|
||||||
+ config["renewable"][w.technology]["cutout"]
|
+ config_provider("renewable", w.technology, "cutout")(w)
|
||||||
+ ".nc",
|
+ ".nc",
|
||||||
output:
|
output:
|
||||||
profile=RESOURCES + "profile_{technology}.nc",
|
profile=RESOURCES + "profile_{technology}.nc",
|
||||||
|
@ -31,10 +31,12 @@ def mute_print():
|
|||||||
|
|
||||||
|
|
||||||
def set_scenario_config(snakemake):
|
def set_scenario_config(snakemake):
|
||||||
if "scenario_config" in snakemake.input:
|
if snakemake.config["run"]["scenarios"]:
|
||||||
with open(snakemake.input.scenario_config, "r") as f:
|
script_dir = Path(__file__).parent.resolve()
|
||||||
|
root_dir = script_dir.parent
|
||||||
|
with open(root_dir / snakemake.config["scenariofile"], "r") as f:
|
||||||
scenario_config = yaml.safe_load(f)
|
scenario_config = yaml.safe_load(f)
|
||||||
update_config(snakemake.config, scenario_config)
|
update_config(snakemake.config, scenario_config[snakemake.wildcards.run])
|
||||||
|
|
||||||
|
|
||||||
def configure_logging(snakemake, skip_handlers=False):
|
def configure_logging(snakemake, skip_handlers=False):
|
||||||
|
@ -743,7 +743,7 @@ if __name__ == "__main__":
|
|||||||
if "snakemake" not in globals():
|
if "snakemake" not in globals():
|
||||||
from _helpers import mock_snakemake
|
from _helpers import mock_snakemake
|
||||||
|
|
||||||
snakemake = mock_snakemake("base_network")
|
snakemake = mock_snakemake("base_network", run="network2019")
|
||||||
configure_logging(snakemake)
|
configure_logging(snakemake)
|
||||||
set_scenario_config(snakemake)
|
set_scenario_config(snakemake)
|
||||||
|
|
||||||
|
@ -68,8 +68,6 @@ def load_timeseries(fn, years, countries):
|
|||||||
load : pd.DataFrame
|
load : pd.DataFrame
|
||||||
Load time-series with UTC timestamps x ISO-2 countries
|
Load time-series with UTC timestamps x ISO-2 countries
|
||||||
"""
|
"""
|
||||||
logger.info(f"Retrieving load data from '{fn}'.")
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
pd.read_csv(fn, index_col=0, parse_dates=[0])
|
pd.read_csv(fn, index_col=0, parse_dates=[0])
|
||||||
.tz_localize(None)
|
.tz_localize(None)
|
||||||
@ -182,20 +180,26 @@ def manual_adjustment(load, fn_load):
|
|||||||
Manual adjusted and interpolated load time-series with UTC
|
Manual adjusted and interpolated load time-series with UTC
|
||||||
timestamps x ISO-2 countries
|
timestamps x ISO-2 countries
|
||||||
"""
|
"""
|
||||||
if "MK" in load:
|
|
||||||
if "AL" not in load or load.AL.isnull().values.all():
|
if "AL" not in load and "AL" in countries:
|
||||||
load["AL"] = load["MK"] * (4.1 / 7.4)
|
if "ME" in load:
|
||||||
if "RS" in load:
|
|
||||||
if "KV" not in load or load.KV.isnull().values.all():
|
|
||||||
load["KV"] = load["RS"] * (4.8 / 27.0)
|
|
||||||
if "ME" in load:
|
|
||||||
if "AL" not in load and "AL" in countries:
|
|
||||||
load["AL"] = load.ME * (5.7 / 2.9)
|
load["AL"] = load.ME * (5.7 / 2.9)
|
||||||
if "MK" not in load and "MK" in countries:
|
elif "MK" in load:
|
||||||
load["MK"] = load.ME * (6.7 / 2.9)
|
load["AL"] = load["MK"] * (4.1 / 7.4)
|
||||||
if "BA" not in load and "BA" in countries:
|
|
||||||
|
if "MK" in countries:
|
||||||
|
if "MK" not in load or load.MK.isnull().sum() > len(load) / 2:
|
||||||
|
if "ME" in load:
|
||||||
|
load["MK"] = load.ME * (6.7 / 2.9)
|
||||||
|
|
||||||
|
if "BA" not in load and "BA" in countries:
|
||||||
|
if "ME" in load:
|
||||||
load["BA"] = load.HR * (11.0 / 16.2)
|
load["BA"] = load.HR * (11.0 / 16.2)
|
||||||
|
|
||||||
|
if "KV" not in load or load.KV.isnull().values.all():
|
||||||
|
if "RS" in load:
|
||||||
|
load["KV"] = load["RS"] * (4.8 / 27.0)
|
||||||
|
|
||||||
copy_timeslice(load, "GR", "2015-08-11 21:00", "2015-08-15 20:00", Delta(weeks=1))
|
copy_timeslice(load, "GR", "2015-08-11 21:00", "2015-08-15 20:00", Delta(weeks=1))
|
||||||
copy_timeslice(load, "AT", "2018-12-31 22:00", "2019-01-01 22:00", Delta(days=2))
|
copy_timeslice(load, "AT", "2018-12-31 22:00", "2019-01-01 22:00", Delta(days=2))
|
||||||
copy_timeslice(load, "CH", "2010-01-19 07:00", "2010-01-19 22:00", Delta(days=1))
|
copy_timeslice(load, "CH", "2010-01-19 07:00", "2010-01-19 22:00", Delta(days=1))
|
||||||
@ -250,7 +254,7 @@ if __name__ == "__main__":
|
|||||||
if "snakemake" not in globals():
|
if "snakemake" not in globals():
|
||||||
from _helpers import mock_snakemake
|
from _helpers import mock_snakemake
|
||||||
|
|
||||||
snakemake = mock_snakemake("build_electricity_demand")
|
snakemake = mock_snakemake("build_electricity_demand", run="network2019")
|
||||||
|
|
||||||
configure_logging(snakemake)
|
configure_logging(snakemake)
|
||||||
set_scenario_config(snakemake)
|
set_scenario_config(snakemake)
|
||||||
|
@ -200,7 +200,9 @@ if __name__ == "__main__":
|
|||||||
if "snakemake" not in globals():
|
if "snakemake" not in globals():
|
||||||
from _helpers import mock_snakemake
|
from _helpers import mock_snakemake
|
||||||
|
|
||||||
snakemake = mock_snakemake("build_renewable_profiles", technology="solar")
|
snakemake = mock_snakemake(
|
||||||
|
"build_renewable_profiles", technology="solar", run="network2019"
|
||||||
|
)
|
||||||
configure_logging(snakemake)
|
configure_logging(snakemake)
|
||||||
set_scenario_config(snakemake)
|
set_scenario_config(snakemake)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user