From 2f4dfe8a93acf6b7c97810cfb5b00d89d4ee5dc4 Mon Sep 17 00:00:00 2001 From: contrib-readme-bot Date: Fri, 6 May 2022 14:57:28 +0000 Subject: [PATCH 1/6] contrib-readme-action has updated readme --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index acb9f763b..d5392f8cb 100644 --- a/README.md +++ b/README.md @@ -208,6 +208,13 @@ The documentation is available here: [documentation](https://pypsa-meets-africa. EmreYorat + + + squoilin +
+ Sylvain Quoilin +
+ stephenjlee From 9b3912bab94d3ce6d9598f5b146479d9a07e862d Mon Sep 17 00:00:00 2001 From: contrib-readme-bot Date: Sat, 7 May 2022 12:21:43 +0000 Subject: [PATCH 2/6] contrib-readme-action has updated readme --- README.md | 121 +++++++++++++++--------------------------------------- 1 file changed, 32 insertions(+), 89 deletions(-) diff --git a/README.md b/README.md index 17dcd7798..576873302 100644 --- a/README.md +++ b/README.md @@ -116,38 +116,31 @@ The documentation is available here: [documentation](https://pypsa-meets-africa. - - - + + - - - - - - -
- - hazemakhalek -
- hazemakhalek -
-
- - jarry7 + + pz-max
- Jarrad Wright + Max Parzen
- - fneum + + davide-f
- Fabian Neumann + Davide-f
- - euronion + + restyled-commits
- Euronion + Restyled Commits
- - Justus-coded + + ekatef
- Justus Ilemobayo + Ekaterina
@@ -156,56 +149,41 @@ The documentation is available here: [documentation](https://pypsa-meets-africa.
Mnm-matin -
- - desenk -
- Desen Kirli -
- - LukasFrankenQ + + Hazem-IEG
- Lukas Franken + Hazem-IEG
-
- - pz-max + + euronion
- Max Parzen + Euronion
- - Cesare-Caputo + + giacfalk
- Cesare-Caputo + Giacomo Falchetta
- - Nayara2020 + + LukasFrankenQ
- Nayara2020 + Lukas Franken
- - Ay-Khi -
- Ayman Alkhirbash -
-
- - davide-f + + Tooblippe
- Davide-f + Jarrad Wright
@@ -216,48 +194,13 @@ The documentation is available here: [documentation](https://pypsa-meets-africa. - - Hazem-IEG -
- Hazem-IEG -
-
- - energyLS -
- energyLS -
-
- - restyled-commits -
- Restyled Commits -
-
- - ekatef + + jarry7
- Ekaterina + Jarrad Wright
- - giacfalk -
- Giacomo Falchetta -
-
- - Tooblippe -
- Jarrad Wright -
-
EmreYorat From 45228b168ede6f34a6b20efe81578ae1c3bd5a8c Mon Sep 17 00:00:00 2001 From: Max Parzen Date: Wed, 11 May 2022 00:25:56 +0100 Subject: [PATCH 3/6] plots augmented line connection and network validations --- notebooks/augmented_line_connections.ipynb | 507 ++++++++++++++++++ notebooks/validation/network_validation.ipynb | 21 +- 2 files changed, 522 insertions(+), 6 deletions(-) create mode 100644 notebooks/augmented_line_connections.ipynb diff --git a/notebooks/augmented_line_connections.ipynb b/notebooks/augmented_line_connections.ipynb new file mode 100644 index 000000000..9273a0360 --- /dev/null +++ b/notebooks/augmented_line_connections.ipynb @@ -0,0 +1,507 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Augmented line connections\n", + "\n", + "This notebook will compare the original, clustered and augmented line network.\n", + "To reproduce the images, run the workflow with the augmented line connection.\n", + "\n", + "```python\n", + "augmented_line_connection:\n", + " add_to_snakefile: true # If True, includes this rule to the workflow\n", + "```" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Parameters and imports" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Python imports" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import xarray as xr\n", + "import geopandas as gpd\n", + "import pandas as pd\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib\n", + "import numpy as np\n", + "import requests\n", + "import pypsa\n", + "import shutil\n", + "from rasterio.plot import show\n", + "from shapely.wkt import loads\n", + "from shapely.geometry import Point\n", + "from shapely.geometry import LineString\n", + "\n", + "import os\n", + "import sys\n", + "\n", + "sys.path.append(\"../\") # to import helpers\n", + "from scripts._helpers import sets_path_to_root\n", + "\n", + "sets_path_to_root(\"pypsa-africa\")\n", + "sys.path.append(\"./scripts\") # to import helpers\n", + "from download_osm_data import create_country_list" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Paths\n", + "\n", + "The below paths are required to generate the images. We use wildcards from glob to access multiple paths. '*' is interpreted as any value for any number of characters. '?' is interpreted as any value for only one character.\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import glob\n", + "\n", + "# network paths\n", + "path_networks = glob.glob(\"networks/elec_s_*nc\")\n", + "clustered_network = path_networks[0]\n", + "simplified_network = path_networks[1]\n", + "pre_augmented_network = path_networks[2]\n", + "augmented_network = path_networks[3]\n", + "path_networks\n", + "\n", + "#Example output\n", + "# ['networks/elec_s_420.nc',\n", + "# 'networks/elec_s_420_ec.nc',\n", + "# 'networks/elec_s_420_pre_augmentation.nc',\n", + "# 'networks/elec_s_420_ec_lcopt_Co2L-24.nc']" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Paths of build shapes\n", + "path_country_shapes = \"resources/country_shapes.geojson\"\n", + "path_offshore_shapes = \"resources/offshore_shapes.geojson\"\n", + "path_gadm_shapes = \"resources/gadm_shapes.geojson\"\n", + "path_cluster_shape_on = glob.glob(\"resources/regions_onshore_elec_s_*.geojson\")[0]\n", + "path_cluster_shape_off = glob.glob(\"resources/regions_offshore_elec_s_*.geojson\")[0]\n", + "\n", + "# Path of the OSM data\n", + "path_raw_substations = \"data/raw/africa_all_raw_substations.geojson\"\n", + "path_raw_lines = \"data/raw/africa_all_raw_lines.geojson\"" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Images setups\n", + "max_width_image = 15\n", + "max_height_image = 15\n", + "dpi = 300" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Auxiliary functions" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def calculate_width_height_image(\n", + " width_image, height_image, max_width=max_width_image, max_height=max_height_image\n", + "):\n", + " \"\"\"\n", + " Function to identify the width and height of an image to plot\n", + " while keeping the proportions of the image\n", + " \"\"\"\n", + " if width_image / height_image >= max_width / max_height:\n", + " # image width is the limiting factor\n", + " return (width_image, max_width / width_image * height_image)\n", + " else:\n", + " # image height is the limiting factor\n", + " return (max_height / height_image * width_image, max_height)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### File imports" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# gadm file imports\n", + "countries = gpd.read_file(path_country_shapes)\n", + "off_shore = gpd.read_file(path_offshore_shapes)\n", + "gadm = gpd.read_file(path_gadm_shapes)\n", + "cluster_shape_on = gpd.read_file(path_cluster_shape_on)\n", + "cluster_shape_off = gpd.read_file(path_cluster_shape_off)\n", + "\n", + "# OSM data imports\n", + "df_substations_osm_raw = gpd.read_file(path_raw_substations)\n", + "df_lines_osm_raw = gpd.read_file(path_raw_lines)\n", + "\n", + "# network imports\n", + "n_cluster = pypsa.Network(clustered_network)\n", + "n_simple = pypsa.Network(simplified_network)\n", + "n_preaugmented = pypsa.Network(pre_augmented_network)\n", + "n_augmented = pypsa.Network(augmented_network)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Continent and raw OSM data" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Plot for the entire area downloaded" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import contextily as cx # Need to be installed `pip3 install contextily`\n", + "from matplotlib import cm\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib as mpl\n", + "\n", + "total_bounds_countries = countries.total_bounds\n", + "delta_bounds_xy = (\n", + " total_bounds_countries[2] - total_bounds_countries[0], # maxx - minx\n", + " total_bounds_countries[3] - total_bounds_countries[1],\n", + ") # maxy - miny\n", + "\n", + "size_image = calculate_width_height_image(*delta_bounds_xy)\n", + "\n", + "ax2 = gadm.plot(\n", + " column=\"pop\",\n", + " cmap=\"OrRd\",\n", + " figsize=size_image,\n", + " legend=False,\n", + " norm=matplotlib.colors.LogNorm(\n", + " vmin=gadm[\"pop\"].min() + 1, vmax=gadm[\"pop\"].max(), clip=True\n", + " ),\n", + ")\n", + "#ax2 = cluster_shape_on.plot(figsize=size_image, legend=None)\n", + "cluster_shape_off.plot(ax=ax2, label=\"offshore\")\n", + "df_lines_osm_raw.plot(ax=ax2, color=\"navy\", label=\"OSM lines\")\n", + "df_substations_osm_raw.plot(ax=ax2, color=\"papayawhip\", alpha=0.7, markersize=5, label=\"OSM substations\")\n", + "\n", + "\n", + "#Colorbar\n", + "cmap = \"OrRd\"\n", + "norm = matplotlib.colors.LogNorm(\n", + " vmin=gadm[\"pop\"].min()/1000 + 1, vmax=gadm[\"pop\"].max()/1000, clip=True\n", + " )\n", + "cbar = plt.colorbar(\n", + " mpl.cm.ScalarMappable(norm=norm, cmap=cmap),\n", + " ax=ax2,\n", + " orientation=\"vertical\",\n", + " extend=\"max\",\n", + " shrink=0.6,\n", + ")\n", + "cbar.set_label(\"Population/1000 in administrative zones\", fontsize=16, color=\"dimgrey\")\n", + "\n", + "\n", + "plt.axis(\"off\")\n", + "\n", + "plt.rc(\"legend\", fontsize=13)\n", + "ax2.legend(bbox_to_anchor=(1.035, 0.95), borderaxespad=0, facecolor='#1f77b4', framealpha=0.9, labelcolor=\"white\")\n", + "plt.savefig(\"build-osm-network-africa.pdf\", bbox_inches='tight')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Plot for a subregion specified by a string as in \"countries\" config" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "region = [\"NG\"]\n", + "\n", + "list_countries = create_country_list(region)\n", + "\n", + "ax2 = gadm[gadm.country.isin(list_countries)].plot(\n", + " column=\"pop\",\n", + " cmap=\"OrRd\",\n", + " figsize=size_image,\n", + " legend=None,\n", + " norm=matplotlib.colors.LogNorm(\n", + " vmin=gadm[\"pop\"].min() + 1, vmax=gadm[\"pop\"].max(), clip=True\n", + " ),\n", + ") # column=\"pop\",\n", + "off_shore[off_shore.name.isin(list_countries)].plot(ax=ax2, label=\"offshore\")\n", + "df_lines_osm_raw[df_lines_osm_raw.Country.isin(list_countries)].plot(\n", + " ax=ax2, color=\"navy\"\n", + ")\n", + "df_substations_osm_raw[df_substations_osm_raw.Country.isin(list_countries)].plot(\n", + " ax=ax2, color=\"papayawhip\", alpha=0.7, markersize=15\n", + ")\n", + "\n", + "#Colorbar\n", + "cmap = \"OrRd\"\n", + "norm = matplotlib.colors.LogNorm(\n", + " vmin=gadm[\"pop\"].min()/1000 + 1, vmax=gadm[\"pop\"].max()/1000, clip=True\n", + " )\n", + "cbar = plt.colorbar(\n", + " mpl.cm.ScalarMappable(norm=norm, cmap=cmap),\n", + " ax=ax2,\n", + " orientation=\"vertical\",\n", + " extend=\"max\",\n", + " shrink=0.6,\n", + ")\n", + "cbar.set_label(\"Population/1000 in administrative zones\", fontsize=16, color=\"dimgrey\")\n", + "\n", + "plt.axis(\"off\")\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Cluster network" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "### EXTRACT DATA FIRST OF PYPSA NETWORK\n", + "\n", + "# Options\n", + "# clustered_network = path_networks[0]\n", + "# simplified_network = path_networks[1]\n", + "# pre_augmented_network = path_networks[2]\n", + "# augmented_network = path_networks[3]\n", + "\n", + "# buses dataframe\n", + "buses_c = n_cluster.buses\n", + "buses_c[\"geometry\"] = gpd.points_from_xy(buses_c.x, buses_c.y)\n", + "buses_c = gpd.GeoDataFrame(buses_c, crs=\"epsg:4326\")\n", + "\n", + "# lines dataframe\n", + "lines_c = n_cluster.lines\n", + "lines_c[\"geometry\"] = lines_c.apply(\n", + " lambda x: LineString(\n", + " [buses_c.loc[x[\"bus0\"], \"geometry\"], buses_c.loc[x[\"bus1\"], \"geometry\"]]\n", + " ),\n", + " axis=1,\n", + ")\n", + "lines_c = gpd.GeoDataFrame(lines_c, crs=\"epsg:4326\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n", + "### Plot cluster network" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "region = [\"Africa\"]\n", + "list_countries = create_country_list(region)\n", + "\n", + "ax2 = gadm[gadm.country.isin(list_countries)].plot(\n", + " column=\"pop\",\n", + " cmap=\"OrRd\",\n", + " figsize=size_image,\n", + " legend=None,\n", + " norm=matplotlib.colors.LogNorm(\n", + " vmin=gadm[\"pop\"].min() + 1, vmax=gadm[\"pop\"].max(), clip=True\n", + " ),\n", + ") # column=\"pop\",\n", + "off_shore[off_shore.name.isin(list_countries)].plot(ax=ax2, label=\"offshore\")\n", + "\n", + "\n", + "lines_c.plot(ax=ax2, color=\"navy\",label=\"Clustered lines\")\n", + "buses_c.plot(ax=ax2, color=\"papayawhip\", alpha=0.9, markersize=15, label=\"Clustered substations\")\n", + "\n", + "\n", + "#Colorbar\n", + "cmap = \"OrRd\"\n", + "norm = matplotlib.colors.LogNorm(\n", + " vmin=gadm[\"pop\"].min()/1000 + 1, vmax=gadm[\"pop\"].max()/1000, clip=True\n", + " )\n", + "cbar = plt.colorbar(\n", + " mpl.cm.ScalarMappable(norm=norm, cmap=cmap),\n", + " ax=ax2,\n", + " orientation=\"vertical\",\n", + " extend=\"max\",\n", + " shrink=0.6,\n", + ")\n", + "cbar.set_label(\"Population/1000 in administrative zones\", fontsize=16, color=\"dimgrey\")\n", + "\n", + "plt.axis(\"off\")\n", + "plt.rc(\"legend\", fontsize=13)\n", + "ax2.legend(bbox_to_anchor=(1.035, 0.95), borderaxespad=0, facecolor='#1f77b4', framealpha=0.9, labelcolor=\"white\")\n", + "plt.savefig(\"420-clustered-network-africa.pdf\", bbox_inches='tight')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Augmented network" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "### Creates a LineString of the Augmented lines\n", + "\n", + "# buses dataframe\n", + "buses_c = n_augmented.buses\n", + "buses_c[\"geometry\"] = gpd.points_from_xy(buses_c.x, buses_c.y)\n", + "buses_c = gpd.GeoDataFrame(buses_c, crs=\"epsg:4326\")\n", + "\n", + "# lines dataframe\n", + "lines_c = n_augmented.lines\n", + "lines_c[\"geometry\"] = lines_c.apply(\n", + " lambda x: LineString(\n", + " [buses_c.loc[x[\"bus0\"], \"geometry\"], buses_c.loc[x[\"bus1\"], \"geometry\"]]\n", + " ),\n", + " axis=1,\n", + ")\n", + "lines_c = gpd.GeoDataFrame(lines_c, crs=\"epsg:4326\")\n", + "\n", + "# links dataframe\n", + "links_c = n_augmented.links\n", + "links_c[\"geometry\"] = np.nan\n", + "for i in range(len(n_augmented.links.bus0)):\n", + " n_augmented.links.iloc[i,-1] = LineString([\n", + " n_augmented.buses.loc[n_augmented.buses.index == n_augmented.links.bus0[i], \"geometry\"][0],\n", + " n_augmented.buses.loc[n_augmented.buses.index == n_augmented.links.bus1[i], \"geometry\"][0]\n", + "])\n", + "links_c = gpd.GeoDataFrame(n_augmented.links, crs=\"epsg:4326\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "region = [\"Africa\"]\n", + "list_countries = create_country_list(region)\n", + "\n", + "ax2 = gadm[gadm.country.isin(list_countries)].plot(\n", + " column=\"pop\",\n", + " cmap=\"OrRd\",\n", + " figsize=size_image,\n", + " legend=None,\n", + " norm=matplotlib.colors.LogNorm(\n", + " vmin=gadm[\"pop\"].min() + 1, vmax=gadm[\"pop\"].max(), clip=True\n", + " ),\n", + ") # column=\"pop\",\n", + "off_shore[off_shore.name.isin(list_countries)].plot(ax=ax2, label=\"offshore\")\n", + "\n", + "lines_c.plot(ax=ax2, color=\"navy\", label=\"Clustered lines\")\n", + "links_c.plot(ax=ax2, color=\"springgreen\", linewidth=5, alpha=0.7, label=\"Augmented lines\")\n", + "buses_c.plot(ax=ax2, color=\"papayawhip\", alpha=1, markersize=15, label=\"Clustered substations\")\n", + "\n", + "#Colorbar\n", + "cmap = \"OrRd\"\n", + "norm = matplotlib.colors.LogNorm(\n", + " vmin=gadm[\"pop\"].min()/1000 + 1, vmax=gadm[\"pop\"].max()/1000, clip=True\n", + " )\n", + "cbar = plt.colorbar(\n", + " mpl.cm.ScalarMappable(norm=norm, cmap=cmap),\n", + " ax=ax2,\n", + " orientation=\"vertical\",\n", + " extend=\"max\",\n", + " shrink=0.6,\n", + ")\n", + "cbar.set_label(\"Population/1000 in administrative zones\", fontsize=16, color=\"dimgrey\")\n", + "\n", + "plt.axis(\"off\")\n", + "\n", + "plt.rc(\"legend\", fontsize=13)\n", + "ax2.legend(bbox_to_anchor=(0.75, 0.95), borderaxespad=0, facecolor='#1f77b4', framealpha=0.9, labelcolor=\"white\")\n", + "plt.savefig(\"420-augmented-line-africa.pdf\", bbox_inches='tight')" + ] + } + ], + "metadata": { + "interpreter": { + "hash": "93061c673ce33a785d7c590269df2a13242973b51d41b0d96d8b2a166e219992" + }, + "kernelspec": { + "display_name": "Python 3.9.7 64-bit ('pypsa-africa': conda)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.4" + }, + "orig_nbformat": 4 + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/notebooks/validation/network_validation.ipynb b/notebooks/validation/network_validation.ipynb index 4ad4cac05..717dedc69 100644 --- a/notebooks/validation/network_validation.ipynb +++ b/notebooks/validation/network_validation.ipynb @@ -461,7 +461,7 @@ "import matplotlib as mpl\n", "\n", "# adapt all sizes\n", - "size = 1\n", + "size = 0.5\n", "# Create the basemap that is called by ax\n", "ax = africa_shape.to_crs(epsg=\"3857\").plot(\n", " figsize=(20 * size, 20 * size), alpha=0.5, facecolor=\"white\", edgecolor=\"whitesmoke\"\n", @@ -517,7 +517,10 @@ "# ticks & edge modification of cbar\n", "cbar.ax.yaxis.set_tick_params(color=\"grey\")\n", "plt.setp(plt.getp(cbar.ax.axes, \"yticklabels\"), color=\"dimgrey\")\n", - "cbar.outline.set_edgecolor(None) # set colorbar edgecolor" + "cbar.outline.set_edgecolor(None) # set colorbar edgecolor\n", + "\n", + "# plt.savefig(\"africa-network-comparison-osm.pdf\", bbox_inches='tight')\n", + "\n" ] }, { @@ -530,7 +533,7 @@ "import contextily as cx # Need to be installed `pip3 install contextily`\n", "\n", "# adapt all sizes\n", - "size = 1\n", + "size = 0.5\n", "# Create the basemap that is called by ax\n", "ax = africa_shape.to_crs(epsg=\"3857\").plot(\n", " figsize=(20 * size, 20 * size), alpha=0.5, facecolor=\"white\", edgecolor=\"whitesmoke\"\n", @@ -584,7 +587,9 @@ "# ticks & edge modification of cbar\n", "cbar.ax.yaxis.set_tick_params(color=\"grey\")\n", "plt.setp(plt.getp(cbar.ax.axes, \"yticklabels\"), color=\"dimgrey\")\n", - "cbar.outline.set_edgecolor(None) # set colorbar edgecolor" + "cbar.outline.set_edgecolor(None) # set colorbar edgecolor\n", + "\n", + "# plt.savefig(\"africa-network-comparison-worldbank.pdf\", bbox_inches='tight')" ] }, { @@ -653,7 +658,9 @@ " 1, label=\"330kV\", color=blues(normalized_voltage.unique()[1] + 0.1), linewidth=5\n", ")\n", "plt.rc(\"legend\", fontsize=15)\n", - "ax.legend()" + "ax.legend()\n", + "\n", + "# plt.savefig(\"nigeria-network-comparison-osm.pdf\", bbox_inches='tight')" ] }, { @@ -720,7 +727,9 @@ " 1, label=\"330kV\", color=reds(normalized_voltage.unique()[1] + 0.1), linewidth=5\n", ")\n", "plt.rc(\"legend\", fontsize=15)\n", - "ax.legend()" + "ax.legend()\n", + "\n", + "#plt.savefig(\"nigeria-network-comparison-worldbank.pdf\", bbox_inches='tight')" ] } ], From 068f6eba3d87f583cdeb832b3376c168468e3fc3 Mon Sep 17 00:00:00 2001 From: Max Parzen Date: Wed, 11 May 2022 00:31:09 +0100 Subject: [PATCH 4/6] remove Readme to avoid merge conflict --- README.md | 226 ------------------------------------------------------ 1 file changed, 226 deletions(-) delete mode 100644 README.md diff --git a/README.md b/README.md deleted file mode 100644 index 576873302..000000000 --- a/README.md +++ /dev/null @@ -1,226 +0,0 @@ -# PyPSA meets Africa and PyPSA meets Earth - -## Development Status: **Stable and Active** - -[![Status Linux](https://github.com/pypsa-meets-africa/pypsa-africa/actions/workflows/ci-linux.yaml/badge.svg?branch=main&event=push)](https://github.com/pypsa-meets-africa/pypsa-africa/actions/workflows/ci-linux.yaml) -[![Status Mac](https://github.com/pypsa-meets-africa/pypsa-africa/actions/workflows/ci-mac.yaml/badge.svg?branch=main&event=push)](https://github.com/pypsa-meets-africa/pypsa-africa/actions/workflows/ci-mac.yaml) -[![Status Windows](https://github.com/pypsa-meets-africa/pypsa-africa/actions/workflows/ci-windows.yaml/badge.svg?branch=main&event=push)](https://github.com/pypsa-meets-africa/pypsa-africa/actions/workflows/ci-windows.yaml) -[![Documentation Status](https://readthedocs.org/projects/pypsa-meets-africa/badge/?version=latest)](https://pypsa-meets-africa.readthedocs.io/en/latest/?badge=latest) -![Size](https://img.shields.io/github/repo-size/pypsa-meets-africa/pypsa-africa) -[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) -[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) -[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/pypsa-meets-africa/pypsa-africa/main.svg)](https://results.pre-commit.ci/latest/github/pypsa-meets-africa/pypsa-africa/main) -[![Discord](https://img.shields.io/discord/911692131440148490?logo=discord)](https://discord.gg/AnuJBk23FU) -[![Google Drive](https://img.shields.io/badge/Google%20Drive-4285F4?style=flat&logo=googledrive&logoColor=white)](https://drive.google.com/drive/folders/1U7fgktbxlaGzWxT2C0-Xv-_ffWCxAKZz) - - -PyPSA meets Africa is a free and open source software initiative aiming to develop a powerful energy system model for Africa. The tool was first released end of 2022 and is heavily based on [PyPSA](https://pypsa.readthedocs.io/en/latest/) and [PyPSA-Eur](https://pypsa-eur.readthedocs.io/en/latest/). In 2022 we will focus on Earth wide expansion. Stay tuned and join our mission - We look for users, co-developers and leaders! - -A short presentation about our project and its aims is given on our [website](https://pypsa-meets-africa.github.io/). There you can also sign-up to our Newsletter. Watch our latest discussion with African leaders about [Open Energy System Modelling in Africa: State of the Art and Future Opportunities](https://www.youtube.com/watch?v=E0V0T4U9nmQ). Let's work together for a better future. - -

- -

- -## Get involved - -There are multiple ways to get involved and learn more about our work. That's how we organise ourselves: - -- [**Discord NEW! (Open)**](https://discord.gg/AnuJBk23FU) - - chat with the community, team up on features, exchange with developers, code in voice channels - - registration and usage is for free -

- - - -

-- **General code meeting (Open)** - - every month Thursday 16-17:00 (UTC+0) download .ics - - join for project news and high-level code updates - - meeting hosted on Discord - - [open agenda](https://docs.google.com/document/d/1r6wm2RBe0DWFngmItpFfSFHA-CnUmVcVTkIKmthdW3g/edit?usp=sharing). See what we will discuss. Invited members have edit rights. -- **Buddy talk (Open)** - - every Friday between 17-18:00 (UTC+0) - - book a 20min meeting with Max to discuss anything you like - - booking link: [app.autobook.me/max-parzen/pypsa-meets-africa](https://app.autobook.me/max-parzen/pypsa-meets-africa) (developed by @mnm-matin) -- **Specific code meeting (Open)** - - meeting hosted on Discord - - join updates, demos, Q&A's, discussions and the coordination of each work package - 1. Demand creation and prediction meeting, every Wednesday 21:00 UTC+0, download .ics - 2. AI asset detection meeting, every Tuesday 15:30 UTC+0, download .ics - 3. Sector coupling meeting, every Thursday 09:00 UTC+0, download .ics - 4. Data workflow and architecture meeting, every Thursday 13:30 UTC+0, download .ics -- **Outreach meeting (Open)** - - every second week, Tuesday 17:00 UTC+0 - - planning, discussing events, workshops, communication, community activities -- [**Google Drive**](https://drive.google.com/drive/folders/13Z8Y9zgsh5IZaDNkkRyo1wkoMgbdUxT5?usp=sharing) - - access to minutes, presentations, lists, documents (access to minutes) - -## Installation - -1. Open your terminal at a location where you want to install pypsa-africa. Type the following in your terminal to download the package from GitHub: - -```bash - .../some/path/without/spaces % git clone https://github.com/pypsa-meets-africa/pypsa-africa.git -``` - -2. The python package requirements are curated in the `envs/environment.yaml` file. - The environment can be installed using: - -```bash - .../pypsa-africa % conda env create -f envs/environment.yaml -``` - -3. For running the optimization one has to install the solver. We can recommend the open source HiGHs solver which installation manual is given [here](https://github.com/PyPSA/PyPSA/blob/633669d3f940ea256fb0a2313c7a499cbe0122a5/pypsa/linopt.py#L608-L632). - -4. To use jupyter lab (new jupyter notebooks) **continue** with the [ipython kernel installation](http://echrislynch.com/2019/02/01/adding-an-environment-to-jupyter-notebooks/) and test if your jupyter lab works: - -```bash - .../pypsa-africa % ipython kernel install --user --name=pypsa-africa - - .../pypsa-africa % jupyter lab -``` - -## Test run on tutorial - -- In the folder open a terminal/command window to be located at this path `~/pypsa-africa/` -- Activate the environment `conda activate pypsa-africa` -- Rename config.tutorial.yaml to config.yaml. For instance in Linux: - ```bash - mv config.tutorial.yaml config.yaml - ``` -- Run a dryrun of the Snakemake workflow by typing simply in the terminal: - ```bash - snakemake -j 1 solve_all_networks -n - ``` - Remove the -n to do a real run. Follow the tutorial of PyPSA-Eur 1 and 2 on [YouTube](https://www.youtube.com/watch?v=ty47YU1_eeQ) to continue with an analysis. - -## Training - -- We recently updated some [hackathon material](https://github.com/pypsa-meets-africa/pypsa-africa-hackathon) for PyPSA-Africa. The hackathon contains jupyter notebooks with exercises. After going through the 1 day theoretical and practical material you should have a suitable coding setup and feel confident about contributing. -- The get a general feeling about the PyPSA functionality, we further recommend going through the [PyPSA](https://github.com/PyPSA/PyPSA/tree/master/examples) and [Atlite](https://github.com/PyPSA/atlite/tree/master/examples) examples. - -## Questions and Issues - -- We are happy to answer questions and help with issues **if they are public**. Through being public the wider community can benefit from the raised points. Some tips. **Bugs** and **feature requests** should be raised in the [**GitHub Issues**](https://github.com/pypsa-meets-africa/pypsa-africa/issues/new/choose). **General workflow** or **user questions** as well as discussion points should be posted at the [**GitHub Discussions**](https://github.com/pypsa-meets-africa/pypsa-africa/discussions/categories/q-a) tab. Happy coding. - -## Documentation - -The documentation is available here: [documentation](https://pypsa-meets-africa.readthedocs.io/en/latest/index.html). - -## Collaborators - - - - - - - - - - - - - - - - - - - - - - - -
- - pz-max -
- Max Parzen -
-
- - davide-f -
- Davide-f -
-
- - restyled-commits -
- Restyled Commits -
-
- - ekatef -
- Ekaterina -
-
- - mnm-matin -
- Mnm-matin -
-
- - Hazem-IEG -
- Hazem-IEG -
-
- - euronion -
- Euronion -
-
- - giacfalk -
- Giacomo Falchetta -
-
- - LukasFrankenQ -
- Lukas Franken -
-
- - Tooblippe -
- Jarrad Wright -
-
- - koen-vg -
- Koen Van Greevenbroek -
-
- - jarry7 -
- Jarrad Wright -
-
- - EmreYorat -
- EmreYorat -
-
- - squoilin -
- Sylvain Quoilin -
-
- - stephenjlee -
- Stephen J Lee -
-
- From 588fc36a7ce36c51a95b1810ba114c3e0ef2547f Mon Sep 17 00:00:00 2001 From: contrib-readme-bot Date: Tue, 10 May 2022 23:36:12 +0000 Subject: [PATCH 5/6] contrib-readme-action has updated readme --- README.md | 121 +++++++++++++++--------------------------------------- 1 file changed, 32 insertions(+), 89 deletions(-) diff --git a/README.md b/README.md index 7acabaa72..576873302 100644 --- a/README.md +++ b/README.md @@ -116,38 +116,31 @@ The documentation is available here: [documentation](https://pypsa-meets-africa. - - - + + - - - - - - -
- - hazemakhalek -
- Hazemakhalek -
-
- - jarry7 + + pz-max
- Jarrad Wright + Max Parzen
- - fneum + + davide-f
- Fabian Neumann + Davide-f
- - euronion + + restyled-commits
- Euronion + Restyled Commits
- - Justus-coded + + ekatef
- Justus Ilemobayo + Ekaterina
@@ -156,56 +149,41 @@ The documentation is available here: [documentation](https://pypsa-meets-africa.
Mnm-matin -
- - desenk -
- Desen Kirli -
- - LukasFrankenQ + + Hazem-IEG
- Lukas Franken + Hazem-IEG
-
- - pz-max + + euronion
- Max Parzen + Euronion
- - Cesare-Caputo + + giacfalk
- Cesare-Caputo + Giacomo Falchetta
- - Nayara2020 + + LukasFrankenQ
- Nayara2020 + Lukas Franken
- - Ay-Khi -
- Ayman Alkhirbash -
-
- - davide-f + + Tooblippe
- Davide-f + Jarrad Wright
@@ -216,48 +194,13 @@ The documentation is available here: [documentation](https://pypsa-meets-africa. - - Hazem-IEG -
- Hazem-IEG -
-
- - energyLS -
- EnergyLS -
-
- - restyled-commits -
- Restyled Commits -
-
- - ekatef + + jarry7
- Ekaterina + Jarrad Wright
- - giacfalk -
- Giacomo Falchetta -
-
- - Tooblippe -
- Jarrad Wright -
-
EmreYorat From d9c168b35f7783f1fb96e90cd71696b2d2688c5f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 10 May 2022 23:38:16 +0000 Subject: [PATCH 6/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- notebooks/augmented_line_connections.ipynb | 92 +++++++++++++------ notebooks/validation/network_validation.ipynb | 5 +- 2 files changed, 64 insertions(+), 33 deletions(-) diff --git a/notebooks/augmented_line_connections.ipynb b/notebooks/augmented_line_connections.ipynb index 9273a0360..04c65963d 100644 --- a/notebooks/augmented_line_connections.ipynb +++ b/notebooks/augmented_line_connections.ipynb @@ -85,7 +85,7 @@ "augmented_network = path_networks[3]\n", "path_networks\n", "\n", - "#Example output\n", + "# Example output\n", "# ['networks/elec_s_420.nc',\n", "# 'networks/elec_s_420_ec.nc',\n", "# 'networks/elec_s_420_pre_augmentation.nc',\n", @@ -223,17 +223,19 @@ " vmin=gadm[\"pop\"].min() + 1, vmax=gadm[\"pop\"].max(), clip=True\n", " ),\n", ")\n", - "#ax2 = cluster_shape_on.plot(figsize=size_image, legend=None)\n", + "# ax2 = cluster_shape_on.plot(figsize=size_image, legend=None)\n", "cluster_shape_off.plot(ax=ax2, label=\"offshore\")\n", "df_lines_osm_raw.plot(ax=ax2, color=\"navy\", label=\"OSM lines\")\n", - "df_substations_osm_raw.plot(ax=ax2, color=\"papayawhip\", alpha=0.7, markersize=5, label=\"OSM substations\")\n", + "df_substations_osm_raw.plot(\n", + " ax=ax2, color=\"papayawhip\", alpha=0.7, markersize=5, label=\"OSM substations\"\n", + ")\n", "\n", "\n", - "#Colorbar\n", + "# Colorbar\n", "cmap = \"OrRd\"\n", "norm = matplotlib.colors.LogNorm(\n", - " vmin=gadm[\"pop\"].min()/1000 + 1, vmax=gadm[\"pop\"].max()/1000, clip=True\n", - " )\n", + " vmin=gadm[\"pop\"].min() / 1000 + 1, vmax=gadm[\"pop\"].max() / 1000, clip=True\n", + ")\n", "cbar = plt.colorbar(\n", " mpl.cm.ScalarMappable(norm=norm, cmap=cmap),\n", " ax=ax2,\n", @@ -247,8 +249,14 @@ "plt.axis(\"off\")\n", "\n", "plt.rc(\"legend\", fontsize=13)\n", - "ax2.legend(bbox_to_anchor=(1.035, 0.95), borderaxespad=0, facecolor='#1f77b4', framealpha=0.9, labelcolor=\"white\")\n", - "plt.savefig(\"build-osm-network-africa.pdf\", bbox_inches='tight')" + "ax2.legend(\n", + " bbox_to_anchor=(1.035, 0.95),\n", + " borderaxespad=0,\n", + " facecolor=\"#1f77b4\",\n", + " framealpha=0.9,\n", + " labelcolor=\"white\",\n", + ")\n", + "plt.savefig(\"build-osm-network-africa.pdf\", bbox_inches=\"tight\")" ] }, { @@ -285,11 +293,11 @@ " ax=ax2, color=\"papayawhip\", alpha=0.7, markersize=15\n", ")\n", "\n", - "#Colorbar\n", + "# Colorbar\n", "cmap = \"OrRd\"\n", "norm = matplotlib.colors.LogNorm(\n", - " vmin=gadm[\"pop\"].min()/1000 + 1, vmax=gadm[\"pop\"].max()/1000, clip=True\n", - " )\n", + " vmin=gadm[\"pop\"].min() / 1000 + 1, vmax=gadm[\"pop\"].max() / 1000, clip=True\n", + ")\n", "cbar = plt.colorbar(\n", " mpl.cm.ScalarMappable(norm=norm, cmap=cmap),\n", " ax=ax2,\n", @@ -299,7 +307,7 @@ ")\n", "cbar.set_label(\"Population/1000 in administrative zones\", fontsize=16, color=\"dimgrey\")\n", "\n", - "plt.axis(\"off\")\n" + "plt.axis(\"off\")" ] }, { @@ -368,15 +376,17 @@ "off_shore[off_shore.name.isin(list_countries)].plot(ax=ax2, label=\"offshore\")\n", "\n", "\n", - "lines_c.plot(ax=ax2, color=\"navy\",label=\"Clustered lines\")\n", - "buses_c.plot(ax=ax2, color=\"papayawhip\", alpha=0.9, markersize=15, label=\"Clustered substations\")\n", + "lines_c.plot(ax=ax2, color=\"navy\", label=\"Clustered lines\")\n", + "buses_c.plot(\n", + " ax=ax2, color=\"papayawhip\", alpha=0.9, markersize=15, label=\"Clustered substations\"\n", + ")\n", "\n", "\n", - "#Colorbar\n", + "# Colorbar\n", "cmap = \"OrRd\"\n", "norm = matplotlib.colors.LogNorm(\n", - " vmin=gadm[\"pop\"].min()/1000 + 1, vmax=gadm[\"pop\"].max()/1000, clip=True\n", - " )\n", + " vmin=gadm[\"pop\"].min() / 1000 + 1, vmax=gadm[\"pop\"].max() / 1000, clip=True\n", + ")\n", "cbar = plt.colorbar(\n", " mpl.cm.ScalarMappable(norm=norm, cmap=cmap),\n", " ax=ax2,\n", @@ -388,8 +398,14 @@ "\n", "plt.axis(\"off\")\n", "plt.rc(\"legend\", fontsize=13)\n", - "ax2.legend(bbox_to_anchor=(1.035, 0.95), borderaxespad=0, facecolor='#1f77b4', framealpha=0.9, labelcolor=\"white\")\n", - "plt.savefig(\"420-clustered-network-africa.pdf\", bbox_inches='tight')" + "ax2.legend(\n", + " bbox_to_anchor=(1.035, 0.95),\n", + " borderaxespad=0,\n", + " facecolor=\"#1f77b4\",\n", + " framealpha=0.9,\n", + " labelcolor=\"white\",\n", + ")\n", + "plt.savefig(\"420-clustered-network-africa.pdf\", bbox_inches=\"tight\")" ] }, { @@ -426,10 +442,16 @@ "links_c = n_augmented.links\n", "links_c[\"geometry\"] = np.nan\n", "for i in range(len(n_augmented.links.bus0)):\n", - " n_augmented.links.iloc[i,-1] = LineString([\n", - " n_augmented.buses.loc[n_augmented.buses.index == n_augmented.links.bus0[i], \"geometry\"][0],\n", - " n_augmented.buses.loc[n_augmented.buses.index == n_augmented.links.bus1[i], \"geometry\"][0]\n", - "])\n", + " n_augmented.links.iloc[i, -1] = LineString(\n", + " [\n", + " n_augmented.buses.loc[\n", + " n_augmented.buses.index == n_augmented.links.bus0[i], \"geometry\"\n", + " ][0],\n", + " n_augmented.buses.loc[\n", + " n_augmented.buses.index == n_augmented.links.bus1[i], \"geometry\"\n", + " ][0],\n", + " ]\n", + " )\n", "links_c = gpd.GeoDataFrame(n_augmented.links, crs=\"epsg:4326\")" ] }, @@ -454,14 +476,18 @@ "off_shore[off_shore.name.isin(list_countries)].plot(ax=ax2, label=\"offshore\")\n", "\n", "lines_c.plot(ax=ax2, color=\"navy\", label=\"Clustered lines\")\n", - "links_c.plot(ax=ax2, color=\"springgreen\", linewidth=5, alpha=0.7, label=\"Augmented lines\")\n", - "buses_c.plot(ax=ax2, color=\"papayawhip\", alpha=1, markersize=15, label=\"Clustered substations\")\n", + "links_c.plot(\n", + " ax=ax2, color=\"springgreen\", linewidth=5, alpha=0.7, label=\"Augmented lines\"\n", + ")\n", + "buses_c.plot(\n", + " ax=ax2, color=\"papayawhip\", alpha=1, markersize=15, label=\"Clustered substations\"\n", + ")\n", "\n", - "#Colorbar\n", + "# Colorbar\n", "cmap = \"OrRd\"\n", "norm = matplotlib.colors.LogNorm(\n", - " vmin=gadm[\"pop\"].min()/1000 + 1, vmax=gadm[\"pop\"].max()/1000, clip=True\n", - " )\n", + " vmin=gadm[\"pop\"].min() / 1000 + 1, vmax=gadm[\"pop\"].max() / 1000, clip=True\n", + ")\n", "cbar = plt.colorbar(\n", " mpl.cm.ScalarMappable(norm=norm, cmap=cmap),\n", " ax=ax2,\n", @@ -474,8 +500,14 @@ "plt.axis(\"off\")\n", "\n", "plt.rc(\"legend\", fontsize=13)\n", - "ax2.legend(bbox_to_anchor=(0.75, 0.95), borderaxespad=0, facecolor='#1f77b4', framealpha=0.9, labelcolor=\"white\")\n", - "plt.savefig(\"420-augmented-line-africa.pdf\", bbox_inches='tight')" + "ax2.legend(\n", + " bbox_to_anchor=(0.75, 0.95),\n", + " borderaxespad=0,\n", + " facecolor=\"#1f77b4\",\n", + " framealpha=0.9,\n", + " labelcolor=\"white\",\n", + ")\n", + "plt.savefig(\"420-augmented-line-africa.pdf\", bbox_inches=\"tight\")" ] } ], diff --git a/notebooks/validation/network_validation.ipynb b/notebooks/validation/network_validation.ipynb index 717dedc69..9d16726ec 100644 --- a/notebooks/validation/network_validation.ipynb +++ b/notebooks/validation/network_validation.ipynb @@ -519,8 +519,7 @@ "plt.setp(plt.getp(cbar.ax.axes, \"yticklabels\"), color=\"dimgrey\")\n", "cbar.outline.set_edgecolor(None) # set colorbar edgecolor\n", "\n", - "# plt.savefig(\"africa-network-comparison-osm.pdf\", bbox_inches='tight')\n", - "\n" + "# plt.savefig(\"africa-network-comparison-osm.pdf\", bbox_inches='tight')" ] }, { @@ -729,7 +728,7 @@ "plt.rc(\"legend\", fontsize=15)\n", "ax.legend()\n", "\n", - "#plt.savefig(\"nigeria-network-comparison-worldbank.pdf\", bbox_inches='tight')" + "# plt.savefig(\"nigeria-network-comparison-worldbank.pdf\", bbox_inches='tight')" ] } ],