merging script in retrieve_gas_input_location with build_gas_input_location
This commit is contained in:
parent
da6469b80c
commit
3dede28aae
@ -114,12 +114,6 @@ if config["sector"]["gas_network"] or config["sector"]["H2_retrofit"]:
|
|||||||
"IGGIELGN_PipeSegments.geojson",
|
"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:
|
rule build_gas_network:
|
||||||
input:
|
input:
|
||||||
gas_network="data/gas_network/scigrid-gas/data/IGGIELGN_PipeSegments.geojson"
|
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:
|
rule build_gas_input_locations:
|
||||||
input:
|
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",
|
entry="data/gas_network/scigrid-gas/data/IGGIELGN_BorderPoints.geojson",
|
||||||
production="data/gas_network/scigrid-gas/data/IGGIELGN_Productions.geojson",
|
production="data/gas_network/scigrid-gas/data/IGGIELGN_Productions.geojson",
|
||||||
regions_onshore=pypsaeur("resources/regions_onshore_elec_s{simpl}_{clusters}.geojson"),
|
regions_onshore=pypsaeur("resources/regions_onshore_elec_s{simpl}_{clusters}.geojson"),
|
||||||
|
@ -18,12 +18,27 @@ def read_scigrid_gas(fn):
|
|||||||
df.drop(["param", "uncertainty", "method"], axis=1, inplace=True)
|
df.drop(["param", "uncertainty", "method"], axis=1, inplace=True)
|
||||||
return df
|
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 terminals
|
||||||
lng = gpd.read_file(lng_fn)
|
lng = retrieve_gem_lng_data(lng_url)
|
||||||
|
|
||||||
lng.CapacityInMtpa = lng.CapacityInMtpa.astype(float)
|
lng.CapacityInMtpa = lng.CapacityInMtpa.astype(float)
|
||||||
|
|
||||||
# Entry points from outside the model scope
|
# Entry points from outside the model scope
|
||||||
|
@ -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])
|
|
Loading…
Reference in New Issue
Block a user