From cab85cbb617c4267adc7626168bc65e7a99f1065 Mon Sep 17 00:00:00 2001 From: Fabian Neumann Date: Mon, 26 Aug 2024 15:04:15 +0200 Subject: [PATCH] update GEM Europe gas tracker to May 2024 version (#1235) --- doc/release_notes.rst | 3 +++ rules/build_sector.smk | 5 +---- rules/retrieve.smk | 17 +++++++++++++++++ scripts/build_gas_input_locations.py | 23 +++++++++++++++-------- 4 files changed, 36 insertions(+), 12 deletions(-) diff --git a/doc/release_notes.rst b/doc/release_notes.rst index 4df38b01..c9359f71 100644 --- a/doc/release_notes.rst +++ b/doc/release_notes.rst @@ -9,6 +9,9 @@ Release Notes Upcoming Release ================ + +* Update GEM Europe Gas Tracker to May 2024 version. + * Add investment period dependent CO2 sequestration potentials * Add option to produce hydrogen from solid biomass (flag ``solid biomass to hydrogen``), combined with carbon capture diff --git a/rules/build_sector.smk b/rules/build_sector.smk index 598df96e..c1e4d573 100644 --- a/rules/build_sector.smk +++ b/rules/build_sector.smk @@ -93,10 +93,7 @@ rule build_gas_network: rule build_gas_input_locations: input: - gem=storage( - "https://globalenergymonitor.org/wp-content/uploads/2023/07/Europe-Gas-Tracker-2023-03-v3.xlsx", - keep_local=True, - ), + gem="data/gem/Europe-Gas-Tracker-2024-05.xlsx", 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"), diff --git a/rules/retrieve.smk b/rules/retrieve.smk index c30696cc..df1f7379 100644 --- a/rules/retrieve.smk +++ b/rules/retrieve.smk @@ -280,6 +280,23 @@ if config["enable"]["retrieve"]: os.remove(params["zip"]) +if config["enable"]["retrieve"]: + + rule retrieve_gem_europe_gas_tracker: + output: + "data/gem/Europe-Gas-Tracker-2024-05.xlsx", + run: + import requests + + response = requests.get( + "https://globalenergymonitor.org/wp-content/uploads/2024/05/Europe-Gas-Tracker-2024-05.xlsx", + headers={"User-Agent": "Mozilla/5.0"}, + ) + with open(output[0], "wb") as f: + f.write(response.content) + + + if config["enable"]["retrieve"]: # Some logic to find the correct file URL # Sometimes files are released delayed or ahead of schedule, check which file is currently available diff --git a/scripts/build_gas_input_locations.py b/scripts/build_gas_input_locations.py index ca43db3c..0cd11475 100644 --- a/scripts/build_gas_input_locations.py +++ b/scripts/build_gas_input_locations.py @@ -36,15 +36,20 @@ def build_gem_lng_data(fn): "Gran Canaria LNG Terminal", ] + status_list = ["Operating", "Construction"] # noqa: F841 + df = df.query( - "Status != 'Cancelled' \ + "Status in @status_list \ + & FacilityType == 'Import' \ & Country != @remove_country \ & TerminalName != @remove_terminal \ - & CapacityInMtpa != '--'" + & CapacityInMtpa != '--' \ + & CapacityInMtpa != 0" ) geometry = gpd.points_from_xy(df["Longitude"], df["Latitude"]) - return gpd.GeoDataFrame(df, geometry=geometry, crs="EPSG:4326") + gdf = gpd.GeoDataFrame(df, geometry=geometry, crs="EPSG:4326") + return gdf def build_gem_prod_data(fn): @@ -54,8 +59,10 @@ def build_gem_prod_data(fn): remove_country = ["Cyprus", "Türkiye"] # noqa: F841 remove_fuel_type = ["oil"] # noqa: F841 + status_list = ["operating", "in development"] # noqa: F841 + df = df.query( - "Status != 'shut in' \ + "Status in @status_list \ & 'Fuel type' != 'oil' \ & Country != @remove_country \ & ~Latitude.isna() \ @@ -64,7 +71,7 @@ def build_gem_prod_data(fn): p = pd.read_excel(fn, sheet_name="Gas extraction - production") p = p.set_index("GEM Unit ID") - p = p[p["Fuel description"] == "gas"] + p = p[p["Fuel description"].str.contains("gas")] capacities = pd.DataFrame(index=df.index) for key in ["production", "production design capacity", "reserves"]: @@ -85,7 +92,8 @@ def build_gem_prod_data(fn): ) geometry = gpd.points_from_xy(df["Longitude"], df["Latitude"]) - return gpd.GeoDataFrame(df, geometry=geometry, crs="EPSG:4326") + gdf = gpd.GeoDataFrame(df, geometry=geometry, crs="EPSG:4326") + return gdf def build_gas_input_locations(gem_fn, entry_fn, sto_fn, countries): @@ -134,8 +142,7 @@ if __name__ == "__main__": snakemake = mock_snakemake( "build_gas_input_locations", simpl="", - clusters="5", - configfiles="config/test/config.overnight.yaml", + clusters="128", ) configure_logging(snakemake)