Skip to content

Commit

Permalink
update rules to work with new workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
p-glaum committed Nov 12, 2024
1 parent 20fec8d commit b04c474
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 90 deletions.
96 changes: 52 additions & 44 deletions rules/collect.smk
Original file line number Diff line number Diff line change
Expand Up @@ -87,51 +87,59 @@ rule validate_elec_networks:

rule plot_statistics:
input:
[
expand(
lambda w: expand(
(
RESULTS
+ "statistics/figures/comparison/country_{country}/.statistics_{carrier}_plots",
country=config_provider("plotting", "statistics")(run).get(
"countries", "all"
),
carrier=config_provider("plotting", "statistics")(run).get(
"carriers", "all"
),
run=config["run"]["name"],
+ "statistics/csv/base_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}/country_{country}/.statistics_{carrier}_csv"
),
expand(
RESULTS
+ "statistics/figures/single/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}/country_{country}/.statistics_{carrier}_plots",
**config["scenario"],
country=config_provider("plotting", "statistics")(run).get(
"countries", "all"
),
carrier=config_provider("plotting", "statistics")(run).get(
"carriers", "all"
),
run=config["run"]["name"],
**config["scenario"],
run=config["run"]["name"],
country=config_provider("plotting", "statistics")(w).get(
"countries", "all"
),
(
expand(
"results/statistics/"
+ config_provider("plotting", "statistics")(run).get(
"comparison_folder", "''"
)
+ "/"
+ "figures/country_{country}/.statistics_{carrier}_plots",
**config["scenario"],
country=config_provider("plotting", "statistics")(run).get(
"countries", "all"
),
carrier=config_provider("plotting", "statistics")(run).get(
"carriers", "all"
),
run=config["run"]["name"],
)
if config_provider("plotting", "statistics")(run).get(
"comparison_folder", ""
)
!= ""
else []
carrier=config_provider("plotting", "statistics")(w).get(
"carriers", "all"
),
allow_missing=True,
),
expand(
RESULTS
+ "statistics/figures/single/base_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}/country_{country}/.statistics_{carrier}_plots",
**config["scenario"],
country=config_provider("plotting", "statistics")(run).get(
"countries", "all"
),
carrier=config_provider("plotting", "statistics")(run).get(
"carriers", "all"
),
],
run=config["run"]["name"],
),
expand(
RESULTS
+ "statistics/figures/comparison/country_{country}/.statistics_{carrier}_plots",
country=config_provider("plotting", "statistics")(run).get(
"countries", "all"
),
carrier=config_provider("plotting", "statistics")(run).get(
"carriers", "all"
),
run=config["run"]["name"],
),
expand(
"results/statistics/"
+ config_provider("plotting", "statistics")(run).get(
"comparison_folder", "''"
)
+ "/"
+ "figures/country_{country}/.statistics_{carrier}_plots",
country=config_provider("plotting", "statistics")(run).get(
"countries", "all"
),
carrier=config_provider("plotting", "statistics")(run).get(
"carriers", "all"
),
run=config["run"]["name"],
)
if config_provider("plotting", "statistics")(run).get("comparison_folder", "")
!= ""
else [],
78 changes: 32 additions & 46 deletions rules/postprocess.smk
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,25 @@ STATISTICS_BARPLOTS = [
"market_value",
]


rule plot_base_statistics:
params:
plotting=config_provider("plotting"),
barplots=STATISTICS_BARPLOTS,
input:
network=RESULTS + "networks/base_s_{clusters}_elec_l{ll}_{opts}.nc",
output:
**{
f"{plot}_bar": RESULTS
+ f"figures/statistics_{plot}_bar_base_s_{{clusters}}_elec_l{{ll}}_{{opts}}.pdf"
for plot in STATISTICS_BARPLOTS
},
barplots_touch=RESULTS
+ "figures/.statistics_plots_base_s_{clusters}_elec_l{ll}_{opts}",
script:
"../scripts/plot_statistics.py"


STATISTICS = {
"capacity_factor": ("-", "p.u."),
"installed_capacity": (1e3, "GW"),
Expand All @@ -277,11 +296,11 @@ rule write_statistics:
statistics=STATISTICS,
input:
network=RESULTS
+ "postnetworks/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.nc",
+ "postnetworks/base_s_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.nc",
output:
**{
f"{metric}": RESULTS
+ "statistics/csv/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}/country_{country}/{carrier}_"
+ "statistics/csv/base_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}/country_{country}/{carrier}_"
+ f"{metric}.csv"
for carrier in config_provider("plotting", "statistics")(run).get(
"carriers", "all"
Expand All @@ -291,10 +310,10 @@ rule write_statistics:
)
},
csv_touch=RESULTS
+ "statistics/csv/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}/country_{country}/.statistics_{carrier}_csv",
+ "statistics/csv/base_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}/country_{country}/.statistics_{carrier}_csv",
log:
RESULTS
+ "logs/write_statistics/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}_country-{country}_carrier-{carrier}.log",
+ "logs/write_statistics/base_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}_country-{country}_carrier-{carrier}.log",
script:
"../scripts/write_statistics.py"

Expand All @@ -306,7 +325,7 @@ rule plot_statistics_single:
input:
**{
f"{metric}": RESULTS
+ "statistics/csv/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}/country_{country}/{carrier}_"
+ "statistics/csv/base_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}/country_{country}/{carrier}_"
+ f"{metric}.csv"
for carrier in config_provider("plotting", "statistics")(run).get(
"carriers", "all"
Expand All @@ -318,7 +337,7 @@ rule plot_statistics_single:
output:
**{
f"{metric}": RESULTS
+ "statistics/figures/single/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}/country_{country}/{carrier}_"
+ "statistics/figures/single/base_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}/country_{country}/{carrier}_"
+ f"{metric}.pdf"
for carrier in config_provider("plotting", "statistics")(run).get(
"carriers", "all"
Expand All @@ -328,10 +347,10 @@ rule plot_statistics_single:
)
},
barplots_touch=RESULTS
+ "statistics/figures/single/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}/country_{country}/.statistics_{carrier}_plots",
+ "statistics/figures/single/base_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}/country_{country}/.statistics_{carrier}_plots",
log:
RESULTS
+ "logs/plot_statistics_single/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}_country-{country}_carrier-{carrier}.log",
+ "logs/plot_statistics_single/base_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}_country-{country}_carrier-{carrier}.log",
script:
"../scripts/plot_statistics_single.py"

Expand All @@ -343,7 +362,7 @@ rule plot_statistics_comparison:
input:
expand(
RESULTS
+ "statistics/csv/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}/country_{country}/{carrier}_{metric}.csv",
+ "statistics/csv/base_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}/country_{country}/{carrier}_{metric}.csv",
**config["scenario"],
metric=config_provider("plotting", "statistics")(run).get(
"metrics", STATISTICS
Expand Down Expand Up @@ -387,7 +406,7 @@ rule plot_statistics_scenario_comparison:
input:
expand(
RESULTS
+ "statistics/csv/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}/country_{country}/{carrier}_{metric}.csv",
+ "statistics/csv/base_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}/country_{country}/{carrier}_{metric}.csv",
**config["scenario"],
metric=config_provider("plotting", "statistics")(run).get(
"metrics", STATISTICS
Expand All @@ -397,12 +416,7 @@ rule plot_statistics_scenario_comparison:
),
output:
**{
f"{metric}": "results/statistics/"
+ config_provider("plotting", "statistics")(run).get(
"comparison_folder", ""
)
+ "/"
+ "figures/country_{country}/{carrier}_"
f"{metric}": "results/statistics/{comparison_folder}/figures/country_{country}/{carrier}_"
+ f"{metric}.pdf"
for carrier in config_provider("plotting", "statistics")(run).get(
"carriers", "all"
Expand All @@ -411,36 +425,8 @@ rule plot_statistics_scenario_comparison:
"metrics", STATISTICS
)
},
barplots_touch="results/statistics/"
+ config_provider("plotting", "statistics")(run).get(
"comparison_folder", "results/scenario_comparison"
)
+ "/"
+ "figures/country_{country}/.statistics_{carrier}_plots",
barplots_touch="results/statistics/{comparison_folder}/figures/country_{country}/.statistics_{carrier}_plots",
log:
"results/statistics/"
+ config_provider("plotting", "statistics")(run).get(
"comparison_folder", "scenario_comparison"
)
+ "/"
+ "logs/plot_statistics_scenario_comparison/country-{country}_carrier-{carrier}.log",
"results/logs/{comparison_folder}/plot_statistics_scenario_comparison/country-{country}_carrier-{carrier}.log",
script:
"../scripts/plot_statistics_comparison.py"


rule plot_base_statistics:
params:
plotting=config_provider("plotting"),
barplots=STATISTICS_BARPLOTS,
input:
network=RESULTS + "networks/base_s_{clusters}_elec_l{ll}_{opts}.nc",
output:
**{
f"{plot}_bar": RESULTS
+ f"figures/statistics_{plot}_bar_base_s_{{clusters}}_elec_l{{ll}}_{{opts}}.pdf"
for plot in STATISTICS_BARPLOTS
},
barplots_touch=RESULTS
+ "figures/.statistics_plots_base_s_{clusters}_elec_l{ll}_{opts}",
script:
"../scripts/plot_statistics.py"

0 comments on commit b04c474

Please sign in to comment.