From 326aeb682b06c4f2704a86d7aeb2a9206da988e7 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 9 Oct 2023 14:28:06 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- config/config.ua.yaml | 3 +-- rules/build_electricity.smk | 6 ++--- scripts/base_network.py | 23 +++++++++++-------- .../determine_availability_matrix_MD_UA.py | 20 ++++++++++++---- 4 files changed, 31 insertions(+), 21 deletions(-) diff --git a/config/config.ua.yaml b/config/config.ua.yaml index c3029bf8..dcb1d86e 100644 --- a/config/config.ua.yaml +++ b/config/config.ua.yaml @@ -13,7 +13,7 @@ scenario: - 2050 countries: - - UA +- UA enable: retrieve: true @@ -21,4 +21,3 @@ enable: retrieve_sector_databundle: false retrieve_cost_data: true retrieve_cutout: false - diff --git a/rules/build_electricity.smk b/rules/build_electricity.smk index 3eb9ee12..be7425aa 100644 --- a/rules/build_electricity.smk +++ b/rules/build_electricity.smk @@ -210,10 +210,8 @@ rule determine_availability_matrix_MD_UA: input: copernicus=RESOURCES + "Copernicus_LC100_global_v3.0.1_2019-nrt_Discrete-Classification-map_EPSG-4326.tif", - wdpa=RESOURCES - + f"WDPA_{bYYYY}.gpkg", - wdpa_marine=RESOURCES - + f"WDPA_WDOECM_{bYYYY}_marine.gpkg", + wdpa=RESOURCES + f"WDPA_{bYYYY}.gpkg", + wdpa_marine=RESOURCES + f"WDPA_WDOECM_{bYYYY}_marine.gpkg", gebco=lambda w: ( "data/bundle/GEBCO_2014_2D.nc" if "max_depth" in config["renewable"][w.technology].keys() diff --git a/scripts/base_network.py b/scripts/base_network.py index bec90239..1929c59a 100644 --- a/scripts/base_network.py +++ b/scripts/base_network.py @@ -368,16 +368,19 @@ def _apply_parameter_corrections(n, parameter_corrections): def _reconnect_crimea(lines): logger.info("Reconnecting Crimea to the Ukrainian grid.") - lines_to_crimea = pd.DataFrame({ - "bus0": ["3065", "3181", "3181"], - "bus1": ["3057", "3055", "3057"], - "v_nom": [300, 300, 300], - "num_parallel": [1, 1, 1], - "length": [140, 120, 140], - "carrier": ["AC", "AC", "AC"], - "underground": [False, False, False], - "under_construction": [False, False, False], - }, index=["Melitopol", "Liubymivka left", "Luibymivka right"]) + lines_to_crimea = pd.DataFrame( + { + "bus0": ["3065", "3181", "3181"], + "bus1": ["3057", "3055", "3057"], + "v_nom": [300, 300, 300], + "num_parallel": [1, 1, 1], + "length": [140, 120, 140], + "carrier": ["AC", "AC", "AC"], + "underground": [False, False, False], + "under_construction": [False, False, False], + }, + index=["Melitopol", "Liubymivka left", "Luibymivka right"], + ) return pd.concat([lines, lines_to_crimea]) diff --git a/scripts/determine_availability_matrix_MD_UA.py b/scripts/determine_availability_matrix_MD_UA.py index 2fea2294..8d10f45d 100644 --- a/scripts/determine_availability_matrix_MD_UA.py +++ b/scripts/determine_availability_matrix_MD_UA.py @@ -18,11 +18,15 @@ from rasterio.plot import show logger = logging.getLogger(__name__) + def get_wdpa_layer_name(wdpa_fn, layer_substring): - """Get layername from file "wdpa_fn" whose name contains "layer_substring".""" + """ + Get layername from file "wdpa_fn" whose name contains "layer_substring". + """ l = fiona.listlayers(wdpa_fn) return [_ for _ in l if layer_substring in _][0] + if __name__ == "__main__": if "snakemake" not in globals(): from _helpers import mock_snakemake @@ -32,7 +36,7 @@ if __name__ == "__main__": ) configure_logging(snakemake) - nprocesses = None # snakemake.config["atlite"].get("nprocesses") + nprocesses = None # snakemake.config["atlite"].get("nprocesses") noprogress = not snakemake.config["atlite"].get("show_progress", True) config = snakemake.config["renewable"][snakemake.wildcards.technology] @@ -74,7 +78,11 @@ if __name__ == "__main__": ) if config["natura"]: - wdpa_fn = snakemake.input.wdpa_marine if "offwind" in snakemake.wildcards.technology else snakemake.input.wdpa + wdpa_fn = ( + snakemake.input.wdpa_marine + if "offwind" in snakemake.wildcards.technology + else snakemake.input.wdpa + ) layer = get_wdpa_layer_name(wdpa_fn, "polygons") wdpa = gpd.read_file( wdpa_fn, @@ -92,7 +100,9 @@ if __name__ == "__main__": ).to_crs(3035) wdpa_pts = wdpa_pts[wdpa_pts["REP_AREA"] > 1] wdpa_pts["buffer_radius"] = np.sqrt(wdpa_pts["REP_AREA"] / np.pi) * 1000 - wdpa_pts = wdpa_pts.set_geometry(wdpa_pts["geometry"].buffer(wdpa_pts["buffer_radius"])) + wdpa_pts = wdpa_pts.set_geometry( + wdpa_pts["geometry"].buffer(wdpa_pts["buffer_radius"]) + ) if not wdpa_pts.empty: excluder.add_geometry(wdpa_pts.geometry) @@ -135,7 +145,7 @@ if __name__ == "__main__": fig, ax = plt.subplots(figsize=(4, 8)) gpd.GeoSeries(regions_geometry.unary_union).plot(ax=ax, color="none") show(band, transform=transform, cmap="Greens", ax=ax) - plt.axis('off') + plt.axis("off") plt.savefig(snakemake.output.availability_map, bbox_inches="tight", dpi=500) # Limit results only to buses for UA and MD