merging script in retrieve_gas_input_location with build_gas_input_location

This commit is contained in:
virio-andreyana 2023-02-16 11:57:33 +01:00
parent da6469b80c
commit 3dede28aae
3 changed files with 19 additions and 49 deletions

View File

@ -114,12 +114,6 @@ if config["sector"]["gas_network"] or config["sector"]["H2_retrofit"]:
"IGGIELGN_PipeSegments.geojson",
]
rule retrieve_gas_infrastructure_data:
output: expand("data/gas_network/scigrid-gas/data/{files}", files=datafiles)
script: 'scripts/retrieve_gas_infrastructure_data.py'
rule build_gas_network:
input:
gas_network="data/gas_network/scigrid-gas/data/IGGIELGN_PipeSegments.geojson"
@ -134,7 +128,7 @@ if config["sector"]["gas_network"] or config["sector"]["H2_retrofit"]:
rule build_gas_input_locations:
input:
lng="data/gas_network/Europe-Gas-Tracker-August-2022.geojson",
lng="https://globalenergymonitor.org/wp-content/uploads/2022/09/Europe-Gas-Tracker-August-2022.xlsx",
entry="data/gas_network/scigrid-gas/data/IGGIELGN_BorderPoints.geojson",
production="data/gas_network/scigrid-gas/data/IGGIELGN_Productions.geojson",
regions_onshore=pypsaeur("resources/regions_onshore_elec_s{simpl}_{clusters}.geojson"),

View File

@ -18,12 +18,27 @@ def read_scigrid_gas(fn):
df.drop(["param", "uncertainty", "method"], axis=1, inplace=True)
return df
def retrieve_gem_lng_data(lng_url):
df = pd.read_excel(lng_url,storage_options={'User-Agent': 'Mozilla/5.0'}, sheet_name = 'LNG terminals - data')
df = df.set_index("ComboID")
def build_gas_input_locations(lng_fn, entry_fn, prod_fn, countries):
remove_status = ['Cancelled']
remove_country = ['Cyprus','Turkey']
remove_terminal = ['Puerto de la Luz LNG Terminal','Gran Canaria LNG Terminal']
df = df.query("Status != 'Cancelled' \
& Country != @remove_country \
& TerminalName != @remove_terminal \
& CapacityInMtpa != '--'")
geometry = gpd.points_from_xy(df['Longitude'], df['Latitude'])
return gpd.GeoDataFrame(df, geometry=geometry, crs="EPSG:4326")
def build_gas_input_locations(lng_url, entry_fn, prod_fn, countries):
# LNG terminals
lng = gpd.read_file(lng_fn)
lng = retrieve_gem_lng_data(lng_url)
lng.CapacityInMtpa = lng.CapacityInMtpa.astype(float)
# Entry points from outside the model scope

View File

@ -1,39 +0,0 @@
"""
Retrieve LNG gas infrastructure data from "https://globalenergymonitor.org/wp-content/uploads/2022/09/Europe-Gas-Tracker-August-2022.xlsx"
Note: This is the script that removes non EU grid countries and terminals that are not closely connected to the europe network
"""
import logging
import pandas as pd
import geopandas as gpd
logger = logging.getLogger(__name__)
if __name__ == "__main__":
if 'snakemake' not in globals():
from helper import mock_snakemake
snakemake = mock_snakemake('retrieve_gas_input_locations')
rootpath = '..'
else:
rootpath = '.'
# LNG terminals
lng_url="https://globalenergymonitor.org/wp-content/uploads/2022/09/Europe-Gas-Tracker-August-2022.xlsx"
df = pd.read_excel(lng_url,storage_options={'User-Agent': 'Mozilla/5.0'}, sheet_name = 'LNG terminals - data')
df = df.set_index("ComboID")
remove_status = ['Cancelled']
remove_country = ['Cyprus','Turkey']
remove_terminal = ['Puerto de la Luz LNG Terminal','Gran Canaria LNG Terminal']
df = df.query("Status != 'Cancelled' \
& Country != @remove_country \
& TerminalName != @remove_terminal \
& CapacityInMtpa != '--'")
geometry = gpd.points_from_xy(df['Longitude'], df['Latitude'])
lng = gpd.GeoDataFrame(df, geometry=geometry, crs="EPSG:4326")
lng.to_file(snakemake.output[0])