disentangle gas input nodes by lng, prod, entry with mmc/d#

This commit is contained in:
Fabian Neumann 2021-11-09 14:52:08 +01:00
parent 9e4e97690f
commit 57c0dd29d1
3 changed files with 24 additions and 9 deletions

View File

@ -106,7 +106,8 @@ if config["sector"]["gas_network"]:
production="data/gas_network/scigrid-gas/data/IGGIELGN_Productions.geojson",
regions_onshore=pypsaeur("resources/regions_onshore_elec_s{simpl}_{clusters}.geojson"),
output:
gas_input_nodes="resources/gas_input_locations_s{simpl}_{clusters}.csv"
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,
script: "scripts/build_gas_input_locations.py"

View File

@ -29,7 +29,7 @@ def build_gas_input_locations(lng_fn, entry_fn, prod_fn, countries):
~entry.name.str.contains("Tegelen") | # malformed datapoint
(entry.from_country == "NO") # entries from NO to GB
]
# production sites inside the model scope
prod = read_scigrid_gas(prod_fn)
prod = prod.loc[
@ -38,10 +38,17 @@ def build_gas_input_locations(lng_fn, entry_fn, prod_fn, countries):
(prod.country_code != "DE")
]
return gpd.GeoDataFrame(
geometry=pd.concat([prod.geometry, entry.geometry, lng.geometry]).reset_index(drop=True),
crs=4326
)
lng["mcm_per_day"] = lng["max_cap_store2pipe_M_m3_per_d"]
entry["mcm_per_day"] = entry["max_cap_from_to_M_m3_per_d"]
prod["mcm_per_day"] = prod["max_supply_M_m3_per_d"]
lng["type"] = "lng"
entry["type"] = "entry"
prod["type"] = "production"
sel = ["geometry", "mcm_per_day", "type"]
return pd.concat([prod[sel], entry[sel], lng[sel]], ignore_index=True)
if __name__ == "__main__":
@ -72,6 +79,13 @@ if __name__ == "__main__":
gas_input_locations.to_crs(3035),
onshore_regions.to_crs(3035),
how='left'
).index_right.unique()
)
pd.Series(gas_input_nodes, name='gas_input_nodes').to_csv(snakemake.output.gas_input_nodes)
gas_input_nodes.rename(columns={"index_right": "bus"}, inplace=True)
gas_input_nodes.to_file(snakemake.output.gas_input_nodes, driver='GeoJSON')
gas_input_nodes_s = gas_input_nodes.groupby(["bus", "type"])["mcm_per_day"].sum().unstack()
gas_input_nodes_s.columns.name = "mcm_per_day"
gas_input_nodes_s.to_csv(snakemake.output.gas_input_nodes_simplified)

View File

@ -1124,7 +1124,7 @@ def add_storage_and_grids(n, costs):
# production, LNG terminal, nor entry-point beyond system scope
fn = snakemake.input.gas_input_nodes
gas_input_nodes = pd.read_csv(fn, index_col=0, squeeze=True).values
gas_input_nodes = pd.read_csv(fn, index_col=0).index.unique()
remove_i = n.generators[
(n.generators.carrier=="gas") &
~n.generators.bus.map(n.buses.location).isin(gas_input_nodes)