diff --git a/Snakefile b/Snakefile index 4011dee0..a76d42de 100644 --- a/Snakefile +++ b/Snakefile @@ -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"), diff --git a/scripts/build_gas_input_locations.py b/scripts/build_gas_input_locations.py index d01f518d..e820a46d 100644 --- a/scripts/build_gas_input_locations.py +++ b/scripts/build_gas_input_locations.py @@ -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 diff --git a/scripts/retrieve_gas_input_locations.py b/scripts/retrieve_gas_input_locations.py deleted file mode 100644 index cea8d8b5..00000000 --- a/scripts/retrieve_gas_input_locations.py +++ /dev/null @@ -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]) \ No newline at end of file