2023-03-06 08:27:45 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2024-02-19 15:21:48 +00:00
|
|
|
# SPDX-FileCopyrightText: : 2023-2024 The PyPSA-Eur Authors
|
2023-03-06 17:49:23 +00:00
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: MIT
|
2023-03-09 11:45:43 +00:00
|
|
|
"""
|
|
|
|
Build regionalised geological sequestration potential for carbon dioxide using
|
2023-03-10 15:56:32 +00:00
|
|
|
data from `CO2Stop <https://setis.ec.europa.eu/european-co2-storage-
|
|
|
|
database_en>`_.
|
2023-03-09 11:45:43 +00:00
|
|
|
"""
|
|
|
|
|
2023-01-24 17:44:39 +00:00
|
|
|
import geopandas as gpd
|
|
|
|
import pandas as pd
|
2024-02-12 10:53:20 +00:00
|
|
|
from _helpers import set_scenario_config
|
|
|
|
|
2023-01-24 17:44:39 +00:00
|
|
|
|
|
|
|
def area(gdf):
|
|
|
|
"""
|
|
|
|
Returns area of GeoDataFrame geometries in square kilometers.
|
|
|
|
"""
|
|
|
|
return gdf.to_crs(epsg=3035).area.div(1e6)
|
|
|
|
|
|
|
|
|
|
|
|
def allocate_sequestration_potential(
|
|
|
|
gdf, regions, attr="conservative estimate Mt", threshold=3
|
|
|
|
):
|
2024-04-10 15:13:58 +00:00
|
|
|
if isinstance(attr, str):
|
|
|
|
attr = [attr]
|
2024-04-10 10:06:53 +00:00
|
|
|
gdf = gdf.loc[gdf[attr].sum(axis=1) > threshold, attr + ["geometry"]]
|
2023-01-24 17:44:39 +00:00
|
|
|
gdf["area_sqkm"] = area(gdf)
|
|
|
|
overlay = gpd.overlay(regions, gdf, keep_geom_type=True)
|
|
|
|
overlay["share"] = area(overlay) / overlay["area_sqkm"]
|
|
|
|
adjust_cols = overlay.columns.difference({"name", "area_sqkm", "geometry", "share"})
|
|
|
|
overlay[adjust_cols] = overlay[adjust_cols].multiply(overlay["share"], axis=0)
|
2024-04-10 10:06:53 +00:00
|
|
|
return overlay.dissolve("name", aggfunc="sum")[attr].sum(axis=1)
|
2023-01-24 17:44:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
if "snakemake" not in globals():
|
2023-03-06 18:09:45 +00:00
|
|
|
from _helpers import mock_snakemake
|
2023-03-06 08:27:45 +00:00
|
|
|
|
2024-09-13 13:37:01 +00:00
|
|
|
snakemake = mock_snakemake("build_sequestration_potentials", clusters="128")
|
2023-01-24 17:44:39 +00:00
|
|
|
|
2024-02-12 10:53:20 +00:00
|
|
|
set_scenario_config(snakemake)
|
|
|
|
|
2023-06-15 17:12:30 +00:00
|
|
|
cf = snakemake.params.sequestration_potential
|
2023-01-24 17:44:39 +00:00
|
|
|
|
2024-03-20 14:40:07 +00:00
|
|
|
gdf = gpd.read_file(snakemake.input.sequestration_potential)
|
2023-01-24 17:44:39 +00:00
|
|
|
|
|
|
|
regions = gpd.read_file(snakemake.input.regions_offshore)
|
2023-02-16 16:21:58 +00:00
|
|
|
if cf["include_onshore"]:
|
2023-01-24 17:44:39 +00:00
|
|
|
onregions = gpd.read_file(snakemake.input.regions_onshore)
|
|
|
|
regions = pd.concat([regions, onregions]).dissolve(by="name").reset_index()
|
|
|
|
|
2023-02-16 16:21:58 +00:00
|
|
|
s = allocate_sequestration_potential(
|
|
|
|
gdf, regions, attr=cf["attribute"], threshold=cf["min_size"]
|
|
|
|
)
|
2023-01-24 17:44:39 +00:00
|
|
|
|
2023-02-16 16:21:58 +00:00
|
|
|
s = s.where(s > cf["min_size"]).dropna()
|
2023-01-24 17:44:39 +00:00
|
|
|
|
|
|
|
s.to_csv(snakemake.output.sequestration_potential)
|