Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed May 31, 2024
1 parent 749f5f7 commit 81ea082
Show file tree
Hide file tree
Showing 19 changed files with 409 additions and 223 deletions.
3 changes: 3 additions & 0 deletions Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ copy_default_files(workflow)
configfile: "config/config.default.yaml"
configfile: "config/config.yaml"


# temporary for mock_snakemake
# import yaml
# from snakemake.utils import update_config
Expand Down Expand Up @@ -59,6 +60,8 @@ include: "rules/build_sector.smk"
include: "rules/solve_electricity.smk"
include: "rules/postprocess.smk"
include: "rules/validate.smk"


# include: "rules/plot.smk"


Expand Down
12 changes: 5 additions & 7 deletions rules/build_sector.smk
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,7 @@ rule prepare_sector_network:
hourly_heat_demand_total=resources(
"hourly_heat_demand_total_elec_s{simpl}_{clusters}.nc"
),
industrial_demand_today = resources(
industrial_demand_today=resources(
"industrial_energy_demand_today_elec_s{simpl}_{clusters}.csv"
),
district_heat_share=resources(
Expand Down Expand Up @@ -1035,12 +1035,10 @@ rule prepare_sector_network:
import_costs="data/imports/results-230505.csv",
import_p_max_pu="data/imports/combined_weighted_generator_timeseries.nc",
regions_onshore=resources("regions_onshore_elec_s{simpl}_{clusters}.geojson"),
country_centroids=
storage(
"https://raw.githubusercontent.com/gavinr/world-countries-centroids/v1.0.0/dist/countries.csv",
keep_local=True,
)
,
country_centroids=storage(
"https://raw.githubusercontent.com/gavinr/world-countries-centroids/v1.0.0/dist/countries.csv",
keep_local=True,
),
output:
RESULTS
+ "prenetworks/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.nc",
Expand Down
188 changes: 144 additions & 44 deletions rules/plot.smk
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,19 @@ rule plot_salt_caverns_clustered:
rc="matplotlibrc",
output:
onshore=multiext(
RESOURCES + "graphics/salt-caverns-s{simpl}-{clusters}-onshore", ".png", ".pdf"
RESOURCES + "graphics/salt-caverns-s{simpl}-{clusters}-onshore",
".png",
".pdf",
),
nearshore=multiext(
RESOURCES + "graphics/salt-caverns-s{simpl}-{clusters}-nearshore", ".png", ".pdf"
RESOURCES + "graphics/salt-caverns-s{simpl}-{clusters}-nearshore",
".png",
".pdf",
),
offshore=multiext(
RESOURCES + "graphics/salt-caverns-s{simpl}-{clusters}-offshore", ".png", ".pdf"
RESOURCES + "graphics/salt-caverns-s{simpl}-{clusters}-offshore",
".png",
".pdf",
),
script:
"../scripts/plot_salt_caverns_clustered.py"
Expand All @@ -133,7 +139,8 @@ rule plot_biomass_potentials:
rc="matplotlibrc",
output:
solid_biomass=multiext(
RESOURCES + "graphics/biomass-potentials-s{simpl}-{clusters}-solid_biomass",
RESOURCES
+ "graphics/biomass-potentials-s{simpl}-{clusters}-solid_biomass",
".png",
".pdf",
),
Expand All @@ -143,7 +150,9 @@ rule plot_biomass_potentials:
".pdf",
),
biogas=multiext(
RESOURCES + "graphics/biomass-potentials-s{simpl}-{clusters}-biogas", ".png", ".pdf"
RESOURCES + "graphics/biomass-potentials-s{simpl}-{clusters}-biogas",
".png",
".pdf",
),
script:
"../scripts/plot_biomass_potentials.py"
Expand Down Expand Up @@ -181,7 +190,10 @@ rule plot_choropleth_capacities:
regions_offshore=RESOURCES + "regions_offshore_elec_s{simpl}_{clusters}.geojson",
rc="matplotlibrc",
output:
directory(RESULTS + "graphics/p_nom_opt/s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}"),
directory(
RESULTS
+ "graphics/p_nom_opt/s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}"
),
script:
"../scripts/plot_choropleth_capacities.py"

Expand All @@ -194,7 +206,10 @@ rule plot_choropleth_prices:
regions_offshore=RESOURCES + "regions_offshore_elec_s{simpl}_{clusters}.geojson",
rc="matplotlibrc",
output:
directory(RESULTS + "graphics/prices/s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}"),
directory(
RESULTS
+ "graphics/prices/s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}"
),
script:
"../scripts/plot_choropleth_prices.py"

Expand All @@ -207,7 +222,10 @@ rule plot_choropleth_potential_used:
regions_offshore=RESOURCES + "regions_offshore_elec_s{simpl}_{clusters}.geojson",
rc="matplotlibrc",
output:
directory(RESULTS + "graphics/potential_used/s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}"),
directory(
RESULTS
+ "graphics/potential_used/s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}"
),
script:
"../scripts/plot_choropleth_potential_used.py"

Expand All @@ -219,11 +237,15 @@ rule plot_choropleth_demand:
industrial_demand=RESOURCES
+ "industrial_energy_demand_elec_s{simpl}_{clusters}_{planning_horizons}.csv",
shipping_demand=RESOURCES + "shipping_demand_s{simpl}_{clusters}.csv",
nodal_energy_totals=RESOURCES + "pop_weighted_energy_totals_s{simpl}_{clusters}.csv",
nodal_energy_totals=RESOURCES
+ "pop_weighted_energy_totals_s{simpl}_{clusters}.csv",
regions_onshore=RESOURCES + "regions_onshore_elec_s{simpl}_{clusters}.geojson",
rc="matplotlibrc",
output:
directory(RESULTS + "graphics/regional_demand/s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}"),
directory(
RESULTS
+ "graphics/regional_demand/s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}"
),
script:
"../scripts/plot_choropleth_demand.py"

Expand All @@ -235,7 +257,10 @@ rule plot_balance_timeseries:
rc="matplotlibrc",
threads: 12
output:
directory(RESULTS + "graphics/balance_timeseries/s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}")
directory(
RESULTS
+ "graphics/balance_timeseries/s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}"
),
script:
"../scripts/plot_balance_timeseries.py"

Expand All @@ -247,18 +272,25 @@ rule plot_heatmap_timeseries:
rc="matplotlibrc",
threads: 12
output:
directory(RESULTS + "graphics/heatmap_timeseries/s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}")
directory(
RESULTS
+ "graphics/heatmap_timeseries/s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}"
),
script:
"../scripts/plot_heatmap_timeseries.py"


rule plot_heatmap_timeseries_resources:
input:
network=RESULTS
+ "prenetworks/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.nc",
rc="matplotlibrc",
threads: 12
output:
directory(RESULTS + "graphics/heatmap_timeseries_resources/s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}")
directory(
RESULTS
+ "graphics/heatmap_timeseries_resources/s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}"
),
script:
"../scripts/plot_heatmap_timeseries_resources.py"

Expand All @@ -272,8 +304,12 @@ rule plot_power_network:
regions=RESOURCES + "regions_onshore_elec_s{simpl}_{clusters}.geojson",
rc="matplotlibrc",
output:
multiext(RESULTS
+ "maps/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}-costs-all_{planning_horizons}", ".png", ".pdf")
multiext(
RESULTS
+ "maps/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}-costs-all_{planning_horizons}",
".png",
".pdf",
),
threads: 2
resources:
mem_mb=10000,
Expand All @@ -287,6 +323,7 @@ rule plot_power_network:
script:
"../scripts/plot_power_network.py"


rule plot_hydrogen_network:
params:
foresight=config["foresight"],
Expand All @@ -297,8 +334,12 @@ rule plot_hydrogen_network:
regions=RESOURCES + "regions_onshore_elec_s{simpl}_{clusters}.geojson",
rc="matplotlibrc",
output:
multiext(RESULTS
+ "maps/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}-h2_network_{planning_horizons}", ".png", ".pdf")
multiext(
RESULTS
+ "maps/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}-h2_network_{planning_horizons}",
".png",
".pdf",
),
threads: 2
resources:
mem_mb=10000,
Expand All @@ -312,6 +353,7 @@ rule plot_hydrogen_network:
script:
"../scripts/plot_hydrogen_network.py"


rule plot_gas_network:
params:
plotting=config["plotting"],
Expand All @@ -321,8 +363,12 @@ rule plot_gas_network:
regions=RESOURCES + "regions_onshore_elec_s{simpl}_{clusters}.geojson",
rc="matplotlibrc",
output:
multiext(RESULTS
+ "maps/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}-ch4_network_{planning_horizons}", ".png", ".pdf")
multiext(
RESULTS
+ "maps/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}-ch4_network_{planning_horizons}",
".png",
".pdf",
),
threads: 2
resources:
mem_mb=10000,
Expand All @@ -336,6 +382,7 @@ rule plot_gas_network:
script:
"../scripts/plot_gas_network.py"


rule plot_import_options:
input:
network=RESULTS
Expand All @@ -345,11 +392,22 @@ rule plot_import_options:
imports="data/imports/results-230505.csv",
rc="matplotlibrc",
output:
map=multiext(RESULTS + "graphics/import_options_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}", ".png", ".pdf"),
distribution=multiext(RESULTS + "graphics/import_options_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}-distribution", ".png", ".pdf"),
map=multiext(
RESULTS
+ "graphics/import_options_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}",
".png",
".pdf",
),
distribution=multiext(
RESULTS
+ "graphics/import_options_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}-distribution",
".png",
".pdf",
),
script:
"../scripts/plot_import_options.py"


rule plot_import_world_map:
input:
imports="data/imports/results-230505.csv",
Expand All @@ -367,7 +425,7 @@ rule plot_import_world_map:
wdpa="data/WDPA.gpkg",
rc="matplotlibrc",
output:
multiext(RESOURCES + "graphics/import_world_map", ".png", ".pdf")
multiext(RESOURCES + "graphics/import_world_map", ".png", ".pdf"),
script:
"../scripts/plot_import_world_map.py"

Expand All @@ -379,7 +437,12 @@ rule plot_import_networks:
regions=RESOURCES + "regions_onshore_elec_s{simpl}_{clusters}.geojson",
rc="matplotlibrc",
output:
multiext(RESULTS + "graphics/import_networks/s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}", ".png", ".pdf")
multiext(
RESULTS
+ "graphics/import_networks/s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}",
".png",
".pdf",
),
script:
"../scripts/plot_import_network.py"

Expand All @@ -390,7 +453,12 @@ rule plot_import_shares:
+ "postnetworks/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.nc",
rc="matplotlibrc",
output:
multiext(RESULTS + "graphics/import_shares/s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}", ".png", ".pdf")
multiext(
RESULTS
+ "graphics/import_shares/s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}",
".png",
".pdf",
),
script:
"../scripts/plot_import_shares.py"

Expand All @@ -405,34 +473,66 @@ rule plot_all_resources:
rules.plot_powerplants.output,
rules.plot_salt_caverns_unclustered.output,
rules.plot_import_world_map.output,
expand(RESOURCES + "graphics/salt-caverns-s{simpl}-{clusters}-onshore.pdf", **config["scenario"]),
expand(RESOURCES + "graphics/power-network-{clusters}.pdf", **config["scenario"]),
expand(RESOURCES + "graphics/biomass-potentials-s{simpl}-{clusters}-biogas.pdf", **config["scenario"]),
expand(RESOURCES + "graphics/capacity-factor/s{simpl}-{clusters}", **config["scenario"]),
expand(RESOURCES + "graphics/capacity-factor-sector/s{simpl}-{clusters}", **config["scenario"]),
expand(
RESOURCES + "graphics/salt-caverns-s{simpl}-{clusters}-onshore.pdf",
**config["scenario"],
),
expand(
RESOURCES + "graphics/power-network-{clusters}.pdf", **config["scenario"]
),
expand(
RESOURCES + "graphics/biomass-potentials-s{simpl}-{clusters}-biogas.pdf",
**config["scenario"],
),
expand(
RESOURCES + "graphics/capacity-factor/s{simpl}-{clusters}",
**config["scenario"],
),
expand(
RESOURCES + "graphics/capacity-factor-sector/s{simpl}-{clusters}",
**config["scenario"],
),


rule plot_all_results_single:
input:
RESULTS + "graphics/p_nom_opt/s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}",
RESULTS + "graphics/prices/s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}",
RESULTS + "graphics/potential_used/s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}",
RESULTS + "graphics/balance_timeseries/s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}",
RESULTS + "graphics/heatmap_timeseries/s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}",
RESULTS + "graphics/heatmap_timeseries_resources/s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}",
RESULTS + "graphics/regional_demand/s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}",
RESULTS + "maps/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}-costs-all_{planning_horizons}.pdf",
RESULTS + "maps/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}-h2_network_{planning_horizons}.pdf",
RESULTS + "maps/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}-ch4_network_{planning_horizons}.pdf",
RESULTS + "graphics/import_options_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.pdf",
RESULTS + "graphics/import_networks/s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.pdf",
RESULTS + "graphics/import_shares/s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.pdf",
RESULTS
+ "graphics/p_nom_opt/s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}",
RESULTS
+ "graphics/prices/s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}",
RESULTS
+ "graphics/potential_used/s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}",
RESULTS
+ "graphics/balance_timeseries/s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}",
RESULTS
+ "graphics/heatmap_timeseries/s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}",
RESULTS
+ "graphics/heatmap_timeseries_resources/s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}",
RESULTS
+ "graphics/regional_demand/s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}",
RESULTS
+ "maps/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}-costs-all_{planning_horizons}.pdf",
RESULTS
+ "maps/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}-h2_network_{planning_horizons}.pdf",
RESULTS
+ "maps/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}-ch4_network_{planning_horizons}.pdf",
RESULTS
+ "graphics/import_options_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.pdf",
RESULTS
+ "graphics/import_networks/s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.pdf",
RESULTS
+ "graphics/import_shares/s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.pdf",
output:
RESULTS + "graphics/s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.touch"
RESULTS
+ "graphics/s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.touch",
shell:
"touch {output}"


rule plot_all_results:
input:
expand(RESULTS + "graphics/s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.touch", **config["scenario"]),
expand(
RESULTS
+ "graphics/s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.touch",
**config["scenario"],
),
Loading

0 comments on commit 81ea082

Please sign in to comment.