Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix adding H2 export ports for land-locked countries #1229

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions scripts/add_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ def select_ports(n):
# ports.loc[:, "fraction"] = ports.fraction.round(1)

ports = ports[ports.country.isin(countries)]
if len(ports) < 1:
logger.error(
if ports.empty:
logger.warning(
"No export ports chosen, please add ports to the file data/export_ports.csv"
)
return ports
gadm_level = snakemake.params.gadm_level

ports["gadm_{}".format(gadm_level)] = ports[["x", "y", "country"]].apply(
Expand All @@ -70,6 +71,9 @@ def select_ports(n):


def add_export(n, hydrogen_buses_ports, export_profile):
"""
Adds H2 exports for ports
"""
country_shape = gpd.read_file(snakemake.input["shapes_path"])
# Find most northwestern point in country shape and get x and y coordinates
country_shape = country_shape.to_crs(
Expand Down Expand Up @@ -238,8 +242,10 @@ def create_export_profile():
# get hydrogen export buses/ports
hydrogen_buses_ports = select_ports(n)

# add export value and components to network
add_export(n, hydrogen_buses_ports, export_profile)
# depending on the region, there may be hydrogen ports available (or not)
if not hydrogen_buses_ports.empty:
# add export value and components to network
add_export(n, hydrogen_buses_ports, export_profile)

n.export_to_netcdf(snakemake.output[0])

Expand Down
3 changes: 3 additions & 0 deletions scripts/prepare_sector_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -1287,6 +1287,9 @@ def add_shipping(n, costs):
).squeeze()
ports = ports[ports.country.isin(countries)]

if ports.empty:
return

gadm_level = options["gadm_level"]

all_navigation = ["total international navigation", "total domestic navigation"]
Expand Down
Loading