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,76 +67,60 @@ rule build_simplified_population_layouts:
"../scripts/build_clustered_population_layouts.py"
if config["sector"]["gas_network"] or config["sector"]["H2_retrofit"]:
rule build_gas_network:
input:
gas_network="data/gas_network/scigrid-gas/data/IGGIELGN_PipeSegments.geojson",
output:
cleaned_gas_network=RESOURCES + "gas_network.csv",
resources:
mem_mb=4000,
log:
LOGS + "build_gas_network.log",
conda:
"../envs/environment.yaml"
script:
"../scripts/build_gas_network.py"
rule build_gas_input_locations:
input:
gem=HTTP.remote(
"https://globalenergymonitor.org/wp-content/uploads/2023/07/Europe-Gas-Tracker-2023-03-v3.xlsx",
keep_local=True,
),
entry="data/gas_network/scigrid-gas/data/IGGIELGN_BorderPoints.geojson",
storage="data/gas_network/scigrid-gas/data/IGGIELGN_Storages.geojson",
regions_onshore=RESOURCES
+ "regions_onshore_elec_s{simpl}_{clusters}.geojson",
regions_offshore=RESOURCES
+ "regions_offshore_elec_s{simpl}_{clusters}.geojson",
output:
gas_input_nodes=RESOURCES
+ "gas_input_locations_s{simpl}_{clusters}.geojson",
gas_input_nodes_simplified=RESOURCES
+ "gas_input_locations_s{simpl}_{clusters}_simplified.csv",
resources:
mem_mb=2000,
log:
LOGS + "build_gas_input_locations_s{simpl}_{clusters}.log",
conda:
"../envs/environment.yaml"
script:
"../scripts/build_gas_input_locations.py"
rule cluster_gas_network:
input:
cleaned_gas_network=RESOURCES + "gas_network.csv",
regions_onshore=RESOURCES
+ "regions_onshore_elec_s{simpl}_{clusters}.geojson",
regions_offshore=RESOURCES
+ "regions_offshore_elec_s{simpl}_{clusters}.geojson",
output:
clustered_gas_network=RESOURCES + "gas_network_elec_s{simpl}_{clusters}.csv",
resources:
mem_mb=4000,
log:
LOGS + "cluster_gas_network_s{simpl}_{clusters}.log",
conda:
"../envs/environment.yaml"
script:
"../scripts/cluster_gas_network.py"
gas_infrastructure = {
**rules.cluster_gas_network.output,
**rules.build_gas_input_locations.output,
}
rule build_gas_network:
input:
gas_network="data/gas_network/scigrid-gas/data/IGGIELGN_PipeSegments.geojson",
output:
cleaned_gas_network=RESOURCES + "gas_network.csv",
resources:
mem_mb=4000,
log:
LOGS + "build_gas_network.log",
conda:
"../envs/environment.yaml"
script:
"../scripts/build_gas_network.py"
if not (config["sector"]["gas_network"] or config["sector"]["H2_retrofit"]):
# this is effecively an `else` statement which is however not liked by snakefmt
rule build_gas_input_locations:
input:
gem=HTTP.remote(
"https://globalenergymonitor.org/wp-content/uploads/2023/07/Europe-Gas-Tracker-2023-03-v3.xlsx",
keep_local=True,
),
entry="data/gas_network/scigrid-gas/data/IGGIELGN_BorderPoints.geojson",
storage="data/gas_network/scigrid-gas/data/IGGIELGN_Storages.geojson",
regions_onshore=RESOURCES + "regions_onshore_elec_s{simpl}_{clusters}.geojson",
regions_offshore=RESOURCES + "regions_offshore_elec_s{simpl}_{clusters}.geojson",
output:
gas_input_nodes=RESOURCES + "gas_input_locations_s{simpl}_{clusters}.geojson",
gas_input_nodes_simplified=RESOURCES
+ "gas_input_locations_s{simpl}_{clusters}_simplified.csv",
resources:
mem_mb=2000,
log:
LOGS + "build_gas_input_locations_s{simpl}_{clusters}.log",
conda:
"../envs/environment.yaml"
script:
"../scripts/build_gas_input_locations.py"
gas_infrastructure = {}
rule cluster_gas_network:
input:
cleaned_gas_network=RESOURCES + "gas_network.csv",
regions_onshore=RESOURCES + "regions_onshore_elec_s{simpl}_{clusters}.geojson",
regions_offshore=RESOURCES + "regions_offshore_elec_s{simpl}_{clusters}.geojson",
output:
clustered_gas_network=RESOURCES + "gas_network_elec_s{simpl}_{clusters}.csv",
resources:
mem_mb=4000,
log:
LOGS + "cluster_gas_network_s{simpl}_{clusters}.log",
conda:
"../envs/environment.yaml"
script:
"../scripts/cluster_gas_network.py"
rule build_heat_demands:
@ -722,7 +706,8 @@ rule prepare_sector_network:
input:
**build_retro_cost_output,
**build_biomass_transport_costs_output,
**gas_infrastructure,
**rules.cluster_gas_network.output,
**rules.build_gas_input_locations.output,
**build_sequestration_potentials_output,
network=RESOURCES + "networks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}.nc",
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"
if config["enable"]["retrieve"] and (
config["sector"]["gas_network"] or config["sector"]["H2_retrofit"]
):
if config["enable"]["retrieve"]:
datafiles = [
"IGGIELGN_LNGs.geojson",
"IGGIELGN_BorderPoints.geojson",