use wildcard input functions where applicable

This commit is contained in:
Fabian Neumann 2024-02-17 18:35:26 +01:00
parent 95853bb59d
commit e898781fda
3 changed files with 11 additions and 11 deletions

View File

@ -276,7 +276,7 @@ rule build_renewable_profiles:
), ),
luisa=lambda w: ( luisa=lambda w: (
"data/LUISA_basemap_020321_50m.tif" "data/LUISA_basemap_020321_50m.tif"
if config_provider("renewable", w.technology, "luisa")(w) if config_provider("renewable", w.technology, "luisa")
else [] else []
), ),
gebco=ancient( gebco=ancient(
@ -365,9 +365,9 @@ rule build_line_rating:
snapshots=config_provider("snapshots"), snapshots=config_provider("snapshots"),
input: input:
base_network=resources("networks/base.nc"), base_network=resources("networks/base.nc"),
cutout="cutouts/" cutout=lambda w: "cutouts/"
+ CDIR + CDIR
+ config_provider("lines", "dynamic_line_rating", "cutout") + config_provider("lines", "dynamic_line_rating", "cutout")(w)
+ ".nc", + ".nc",
output: output:
output=resources("networks/line_rating.nc"), output=resources("networks/line_rating.nc"),
@ -419,7 +419,7 @@ rule add_electricity:
if config_provider("lines", "dynamic_line_rating", "activate")(w) if config_provider("lines", "dynamic_line_rating", "activate")(w)
else resources("networks/base.nc") else resources("networks/base.nc")
), ),
tech_costs=resources(f"costs_{config_provider('costs', 'year')(w)}.csv"), tech_costs=lambda w: resources(f"costs_{config_provider('costs', 'year')(w)}.csv"),
regions=resources("regions_onshore.geojson"), regions=resources("regions_onshore.geojson"),
powerplants=resources("powerplants.csv"), powerplants=resources("powerplants.csv"),
hydro_capacities=ancient("data/bundle/hydro_capacities.csv"), hydro_capacities=ancient("data/bundle/hydro_capacities.csv"),
@ -462,7 +462,7 @@ rule simplify_network:
costs=config_provider("costs"), costs=config_provider("costs"),
input: input:
network=resources("networks/elec.nc"), network=resources("networks/elec.nc"),
tech_costs=resources(f"costs_{config_provider('costs', 'year')(w)}.csv"), tech_costs=lambda w: resources(f"costs_{config_provider('costs', 'year')(w)}.csv"),
regions_onshore=resources("regions_onshore.geojson"), regions_onshore=resources("regions_onshore.geojson"),
regions_offshore=resources("regions_offshore.geojson"), regions_offshore=resources("regions_offshore.geojson"),
output: output:
@ -509,7 +509,7 @@ rule cluster_network:
if config_provider("enable", "custom_busmap", default=False)(w) if config_provider("enable", "custom_busmap", default=False)(w)
else [] else []
), ),
tech_costs=resources(f"costs_{config_provider('costs', 'year')(w)}.csv"), tech_costs=lambda w: resources(f"costs_{config_provider('costs', 'year')(w)}.csv"),
output: output:
network=resources("networks/elec_s{simpl}_{clusters}.nc"), network=resources("networks/elec_s{simpl}_{clusters}.nc"),
regions_onshore=resources("regions_onshore_elec_s{simpl}_{clusters}.geojson"), regions_onshore=resources("regions_onshore_elec_s{simpl}_{clusters}.geojson"),
@ -536,7 +536,7 @@ rule add_extra_components:
costs=config_provider("costs"), costs=config_provider("costs"),
input: input:
network=resources("networks/elec_s{simpl}_{clusters}.nc"), network=resources("networks/elec_s{simpl}_{clusters}.nc"),
tech_costs=resources(f"costs_{config_provider('costs', 'year')(w)}.csv"), tech_costs=lambda w: resources(f"costs_{config_provider('costs', 'year')(w)}.csv"),
output: output:
resources("networks/elec_s{simpl}_{clusters}_ec.nc"), resources("networks/elec_s{simpl}_{clusters}_ec.nc"),
log: log:
@ -564,11 +564,11 @@ rule prepare_network:
gaslimit=config_provider("electricity", "gaslimit"), gaslimit=config_provider("electricity", "gaslimit"),
max_hours=config_provider("electricity", "max_hours"), max_hours=config_provider("electricity", "max_hours"),
costs=config_provider("costs"), costs=config_provider("costs"),
adjustments=config_provider("adjustments", "electricity", adjustments=config_provider("adjustments", "electricity"),
autarky=config_provider("electricity", "autarky", default={}), autarky=config_provider("electricity", "autarky", default={}),
input: input:
resources("networks/elec_s{simpl}_{clusters}_ec.nc"), resources("networks/elec_s{simpl}_{clusters}_ec.nc"),
tech_costs=resources(f"costs_{config_provider('costs', 'year')(w)}.csv"), tech_costs=lambda w: resources(f"costs_{config_provider('costs', 'year')(w)}.csv"),
co2_price=lambda w: resources("co2_price.csv") if "Ept" in w.opts else [], co2_price=lambda w: resources("co2_price.csv") if "Ept" in w.opts else [],
output: output:
resources("networks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}.nc"), resources("networks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}.nc"),

View File

@ -84,7 +84,7 @@ if config["enable"]["retrieve"] and config["enable"].get("retrieve_cost_data", T
rule retrieve_cost_data: rule retrieve_cost_data:
params: params:
version=lambda w: config_provider("costs", "version")(w), version=config_provider("costs", "version"),
output: output:
resources("costs_{year}.csv"), resources("costs_{year}.csv"),
log: log:

View File

@ -72,7 +72,7 @@ def get_run_path(fn, dir, rdir, shared_resources):
is_shared = shared_resources is_shared = shared_resources
else: else:
raise ValueError( raise ValueError(
"shared_resources must be a boolean or 'base' for special handling." "shared_resources must be a boolean, str, or 'base' for special handling."
) )
if is_shared: if is_shared: