Merge pull request #846 from PyPSA/smpl-build-sector-smk

`build_sector.smk`: simplify gas infrastructure rules
This commit is contained in:
Fabian Neumann 2024-01-04 20:47:05 +01:00 committed by GitHub
commit e7e82209f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 54 additions and 71 deletions

View File

@ -67,8 +67,6 @@ rule build_simplified_population_layouts:
"../scripts/build_clustered_population_layouts.py" "../scripts/build_clustered_population_layouts.py"
if config["sector"]["gas_network"] or config["sector"]["H2_retrofit"]:
rule build_gas_network: rule build_gas_network:
input: input:
gas_network="data/gas_network/scigrid-gas/data/IGGIELGN_PipeSegments.geojson", gas_network="data/gas_network/scigrid-gas/data/IGGIELGN_PipeSegments.geojson",
@ -83,6 +81,7 @@ if config["sector"]["gas_network"] or config["sector"]["H2_retrofit"]:
script: script:
"../scripts/build_gas_network.py" "../scripts/build_gas_network.py"
rule build_gas_input_locations: rule build_gas_input_locations:
input: input:
gem=HTTP.remote( gem=HTTP.remote(
@ -91,13 +90,10 @@ if config["sector"]["gas_network"] or config["sector"]["H2_retrofit"]:
), ),
entry="data/gas_network/scigrid-gas/data/IGGIELGN_BorderPoints.geojson", entry="data/gas_network/scigrid-gas/data/IGGIELGN_BorderPoints.geojson",
storage="data/gas_network/scigrid-gas/data/IGGIELGN_Storages.geojson", storage="data/gas_network/scigrid-gas/data/IGGIELGN_Storages.geojson",
regions_onshore=RESOURCES regions_onshore=RESOURCES + "regions_onshore_elec_s{simpl}_{clusters}.geojson",
+ "regions_onshore_elec_s{simpl}_{clusters}.geojson", regions_offshore=RESOURCES + "regions_offshore_elec_s{simpl}_{clusters}.geojson",
regions_offshore=RESOURCES
+ "regions_offshore_elec_s{simpl}_{clusters}.geojson",
output: output:
gas_input_nodes=RESOURCES gas_input_nodes=RESOURCES + "gas_input_locations_s{simpl}_{clusters}.geojson",
+ "gas_input_locations_s{simpl}_{clusters}.geojson",
gas_input_nodes_simplified=RESOURCES gas_input_nodes_simplified=RESOURCES
+ "gas_input_locations_s{simpl}_{clusters}_simplified.csv", + "gas_input_locations_s{simpl}_{clusters}_simplified.csv",
resources: resources:
@ -109,13 +105,12 @@ if config["sector"]["gas_network"] or config["sector"]["H2_retrofit"]:
script: script:
"../scripts/build_gas_input_locations.py" "../scripts/build_gas_input_locations.py"
rule cluster_gas_network: rule cluster_gas_network:
input: input:
cleaned_gas_network=RESOURCES + "gas_network.csv", cleaned_gas_network=RESOURCES + "gas_network.csv",
regions_onshore=RESOURCES regions_onshore=RESOURCES + "regions_onshore_elec_s{simpl}_{clusters}.geojson",
+ "regions_onshore_elec_s{simpl}_{clusters}.geojson", regions_offshore=RESOURCES + "regions_offshore_elec_s{simpl}_{clusters}.geojson",
regions_offshore=RESOURCES
+ "regions_offshore_elec_s{simpl}_{clusters}.geojson",
output: output:
clustered_gas_network=RESOURCES + "gas_network_elec_s{simpl}_{clusters}.csv", clustered_gas_network=RESOURCES + "gas_network_elec_s{simpl}_{clusters}.csv",
resources: resources:
@ -127,17 +122,6 @@ if config["sector"]["gas_network"] or config["sector"]["H2_retrofit"]:
script: script:
"../scripts/cluster_gas_network.py" "../scripts/cluster_gas_network.py"
gas_infrastructure = {
**rules.cluster_gas_network.output,
**rules.build_gas_input_locations.output,
}
if not (config["sector"]["gas_network"] or config["sector"]["H2_retrofit"]):
# this is effecively an `else` statement which is however not liked by snakefmt
gas_infrastructure = {}
rule build_heat_demands: rule build_heat_demands:
params: params:
@ -722,7 +706,8 @@ rule prepare_sector_network:
input: input:
**build_retro_cost_output, **build_retro_cost_output,
**build_biomass_transport_costs_output, **build_biomass_transport_costs_output,
**gas_infrastructure, **rules.cluster_gas_network.output,
**rules.build_gas_input_locations.output,
**build_sequestration_potentials_output, **build_sequestration_potentials_output,
network=RESOURCES + "networks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}.nc", network=RESOURCES + "networks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}.nc",
energy_totals_name=RESOURCES + "energy_totals.csv", energy_totals_name=RESOURCES + "energy_totals.csv",

View File

@ -162,9 +162,7 @@ if config["enable"]["retrieve"] and config["enable"].get(
"../scripts/retrieve_sector_databundle.py" "../scripts/retrieve_sector_databundle.py"
if config["enable"]["retrieve"] and ( if config["enable"]["retrieve"]:
config["sector"]["gas_network"] or config["sector"]["H2_retrofit"]
):
datafiles = [ datafiles = [
"IGGIELGN_LNGs.geojson", "IGGIELGN_LNGs.geojson",
"IGGIELGN_BorderPoints.geojson", "IGGIELGN_BorderPoints.geojson",