make_summary: Update summary creation for new line volume/cost constraints

Fixes #4.
This commit is contained in:
Jonas Hoersch 2019-02-10 16:08:39 +01:00
parent 448e8c238e
commit 15e986a0ec
2 changed files with 19 additions and 5 deletions

View File

@ -268,11 +268,18 @@ rule plot_network:
def input_make_summary(w):
# It's mildly hacky to include the separate costs input as first entry
if w.ll.endswith("all"):
ll = config["scenario"]["ll"]
if len(w.ll) == 4:
ll = [l for l in ll if l[0] == w.ll[0]]
else:
ll = w.ll
return ([COSTS] +
expand("results/networks/{network}_s{simpl}_{clusters}_l{ll}_{opts}.nc",
network=w.network,
ll=ll,
**{k: config["scenario"][k] if getattr(w, k) == "all" else getattr(w, k)
for k in ["simpl", "clusters", "l", "opts"]}))
for k in ["simpl", "clusters", "opts"]}))
rule make_summary:
input: input_make_summary

View File

@ -353,7 +353,7 @@ outputs = ["costs",
def make_summaries(networks_dict, country='all'):
columns = pd.MultiIndex.from_tuples(networks_dict.keys(),names=["simpl","clusters","lv","opts"])
columns = pd.MultiIndex.from_tuples(networks_dict.keys(),names=["simpl","clusters","ll","opts"])
dfs = {}
@ -401,15 +401,22 @@ if __name__ == "__main__":
w = getattr(snakemake.wildcards, key)
return snakemake.config["scenario"][key] if w == "all" else [w]
networks_dict = {(simpl,clusters,lv,opts) : ('results/networks/{network}_s{simpl}_{clusters}_lv{lv}_{opts}.nc'
if snakemake.wildcards.ll.endswith("all"):
ll = snakemake.config["scenario"]["ll"]
if len(snakemake.wildcards.ll) == 4:
ll = [l for l in ll if l[0] == snakemake.wildcards.ll[0]]
else:
ll = [snakemake.wildcards.ll]
networks_dict = {(simpl,clusters,l,opts) : ('results/networks/{network}_s{simpl}_{clusters}_l{ll}_{opts}.nc'
.format(network=snakemake.wildcards.network,
simpl=simpl,
clusters=clusters,
opts=opts,
lv=lv))
ll=l))
for simpl in expand_from_wildcard("simpl")
for clusters in expand_from_wildcard("clusters")
for lv in expand_from_wildcard("lv")
for l in ll
for opts in expand_from_wildcard("opts")}
print(networks_dict)