{ "cells": [ { "cell_type": "markdown", "id": "0ed2631d", "metadata": {}, "source": [ "# Load Location Data Repositories" ] }, { "cell_type": "markdown", "id": "908a7529-521d-4e66-a19f-9e762a35b733", "metadata": {}, "source": [ "This notebook demonstrates how *OptiWindNet* can load all `osm.pbf` and `.yaml` files from a directory into a *namedtuple* of *networkx* graphs, which can be used to initialize a `WindFarmNetwork()` instance." ] }, { "cell_type": "markdown", "id": "62ca07c2", "metadata": {}, "source": [ "## Import required modules" ] }, { "cell_type": "markdown", "id": "e4d99b99", "metadata": {}, "source": [ "To use this functionality we need `load_repository()` as well as `WindFarmNetwork`." ] }, { "cell_type": "code", "execution_count": 1, "id": "a0ab2186-9b34-4e8b-bfe1-e0e69f8f1c68", "metadata": {}, "outputs": [], "source": [ "from optiwindnet.api import WindFarmNetwork, load_repository" ] }, { "cell_type": "code", "execution_count": 2, "id": "d6709eb8", "metadata": {}, "outputs": [], "source": [ "# Display figures as SVG in Jupyter notebooks\n", "%config InlineBackend.figure_formats = ['svg']" ] }, { "cell_type": "markdown", "id": "929fdb41", "metadata": {}, "source": [ "## Load a repository" ] }, { "cell_type": "markdown", "id": "cb8509f9", "metadata": {}, "source": [ "`load_repository()` reads the `.osm.pbf` and `.yaml` locations distributed with *OptiWindNet* into a *namedtuple* of *networkx* graphs containing location data.\n", "\n", ">Note: if no argument is passed to the function, it loads the default locations included in the *OptiWindNet* repository. However, the user can also provide a custom repository containing `.osm.pbf` and `.yaml` files by:\n", ">\n", ">```python\n", "> locations = load_repository(path='path to the repository folder')\n", ">```" ] }, { "cell_type": "code", "execution_count": 3, "id": "1909519a", "metadata": {}, "outputs": [], "source": [ "locations = load_repository()" ] }, { "cell_type": "code", "execution_count": 4, "id": "b1ef1a8d", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(91,\n", " 'anholt, borkum, borkum2, borssele, butendiek, cazzaro_2022, cazzaro_2022G140, cazzaro_2022G210, dantysk, doggerA, dudgeon, anglia, gode, gabbin, gwynt, horns, horns2, horns3, hornsea, hornsea2w, london, morayeast, moraywest, ormonde, race, rampion, rødsand2, sofia, taylor_2023, thanet, triton, walney1, walney2, walneyext, sands, yi_2019, albatros, amrumbank, arkona, baltic2, eagle, bard, beatrice, belwind, nanpeng, rudongdemo, bucht, fecamp, galloper, gemini1, gemini2, glotech1, hohesee, kustzuid, humber, kaskasi, kfA, kfB, bodhi, lillgrund, lincs, luchterduinen, meerwind, merkur, mermaid, neart, nordsee, nordseeost, norther, northwind, nysted, amalia, rental, riffgat, robin, rudongH10, rudongH6, rudongH8, brieuc, nazaire, sandbank, seagreen, shengsi2, sheringham, binhainorthH2, triborkum, vejamate, vineyard, rough, wikinger, jiaxing1')" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "len(locations), ', '.join(locations._fields)" ] }, { "cell_type": "markdown", "id": "81767378", "metadata": {}, "source": [ "Each location is loaded as a *networkx* graph containing location data." ] }, { "cell_type": "code", "execution_count": 5, "id": "60b90866", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "networkx.classes.graph.Graph" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "type(locations.seagreen)" ] }, { "cell_type": "markdown", "id": "92abd914", "metadata": {}, "source": [ "## Use loaded locations" ] }, { "cell_type": "markdown", "id": "d4505c6f", "metadata": {}, "source": [ "Initialize an instance of `WindFarmNetwork` with one of the locations (e.g. seagreen)." ] }, { "cell_type": "code", "execution_count": 6, "id": "b93c9a50", "metadata": {}, "outputs": [], "source": [ "wfn = WindFarmNetwork(L=locations.seagreen, cables=[(2, 1500.0), (5, 1800.0)])" ] }, { "cell_type": "markdown", "id": "9b53b817", "metadata": {}, "source": [ "### Plot location" ] }, { "cell_type": "markdown", "id": "87bc4a7b", "metadata": {}, "source": [ "> Note: We could use `wfn.plot_location()` for plotting the location. For more details look into the notebook about [plotting](a04_Plotting.ipynb)" ] }, { "cell_type": "code", "execution_count": 7, "id": "c0878ba3", "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "" ], "text/plain": [ "" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "wfn" ] }, { "cell_type": "markdown", "id": "70bf4bce", "metadata": {}, "source": [ "## List locations in the loaded repository" ] }, { "cell_type": "markdown", "id": "a6a1ee1e", "metadata": {}, "source": [ "Print (for all available locations):\n", "- `name`\n", "- `R`: number of Roots (Substations)\n", "- `T`: number of Terminals (Turbines)" ] }, { "cell_type": "code", "execution_count": 8, "id": "66b9d999", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "anholt : Anholt -> 1 , 111\n", "borkum : Borkum Riffgrund 1 -> 1 , 78\n", "borkum2 : Borkum Riffgrund 2 -> 1 , 52\n", "borssele : Borssele -> 2 , 173\n", "butendiek : Butendiek -> 1 , 80\n", "cazzaro_2022 : Cazzaro-2022 -> 1 , 50\n", "cazzaro_2022G140 : Cazzaro-2022G-140 -> 3 , 140\n", "cazzaro_2022G210 : Cazzaro-2022G-210 -> 3 , 210\n", "dantysk : DanTysk -> 1 , 80\n", "doggerA : Dogger Bank A -> 1 , 95\n", "dudgeon : Dudgeon -> 1 , 67\n", "anglia : East Anglia ONE -> 1 , 102\n", "gode : Gode Wind 1 -> 1 , 55\n", "gabbin : Greater Gabbard Inner -> 1 , 102\n", "gwynt : Gwynt y Mor -> 2 , 160\n", "horns : Horns Rev 1 -> 1 , 80\n", "horns2 : Horns Rev 2 -> 1 , 91\n", "horns3 : Horns Rev 3 -> 1 , 49\n", "hornsea : Hornsea One -> 3 , 174\n", "hornsea2w : Hornsea Two West -> 1 , 110\n", "london : London Array -> 2 , 175\n", "morayeast : Moray East -> 3 , 100\n", "moraywest : Moray West -> 2 , 60\n", "ormonde : Ormonde -> 1 , 30\n", "race : Race Bank -> 2 , 91\n", "rampion : Rampion -> 1 , 116\n", "rødsand2 : Rødsand 2 -> 1 , 90\n", "sofia : Sofia -> 1 , 100\n", "taylor_2023 : Taylor-2023 -> 2 , 122\n", "thanet : Thanet -> 1 , 100\n", "triton : Triton Knoll -> 2 , 90\n", "walney1 : Walney 1 -> 1 , 51\n", "walney2 : Walney 2 -> 1 , 51\n", "walneyext : Walney Extension -> 2 , 87\n", "sands : West of Duddon Sands -> 1 , 108\n", "yi_2019 : Yi-2019 -> 2 , 119\n", "albatros : Albatros -> 1 , 16\n", "amrumbank : Amrumbank West -> 1 , 80\n", "arkona : Arkona -> 1 , 60\n", "baltic2 : Baltic 2 -> 1 , 80\n", "eagle : Baltic Eagle -> 1 , 50\n", "bard : BARD Offshore 1 -> 1 , 80\n", "beatrice : Beatrice -> 2 , 84\n", "belwind : Belwind -> 1 , 55\n", "nanpeng : CECEP Yangjiang Nanpeng Island -> 1 , 55\n", "rudongdemo : CGN Rudong Demonstration -> 1 , 38\n", "bucht : Deutsche Bucht -> 1 , 31\n", "fecamp : Fecamp -> 1 , 71\n", "galloper : Galloper Inner -> 1 , 38\n", "gemini1 : Gemini 1 -> 1 , 75\n", "gemini2 : Gemini 2 -> 1 , 75\n", "glotech1 : Global Tech 1 -> 1 , 80\n", "hohesee : Hohe See -> 1 , 71\n", "kustzuid : Hollandse Kust Zuid -> 2 , 139\n", "humber : Humber Gateway -> 1 , 73\n", "kaskasi : Kaskasi -> 1 , 38\n", "kfA : Kriegers Flak A -> 1 , 24\n", "kfB : Kriegers Flak B -> 1 , 48\n", "bodhi : Laoting Bodhi Island -> 1 , 75\n", "lillgrund : Lillgrund -> 1 , 48\n", "lincs : Lincs -> 1 , 75\n", "luchterduinen : Luchterduinen -> 1 , 43\n", "meerwind : Meerwind -> 1 , 80\n", "merkur : Merkur -> 1 , 66\n", "mermaid : Mermaid -> 1 , 27\n", "neart : Neart na Gaoithe -> 2 , 54\n", "nordsee : Nordsee One -> 1 , 54\n", "nordseeost : Nordsee Ost -> 1 , 48\n", "norther : Norther -> 1 , 44\n", "northwind : Northwind -> 1 , 72\n", "nysted : Nysted -> 1 , 72\n", "amalia : Princess Amalia -> 1 , 60\n", "rental : Rentel -> 1 , 42\n", "riffgat : Riffgat -> 1 , 30\n", "robin : Robin Rigg -> 1 , 60\n", "rudongH10 : Rudong H10 -> 1 , 100\n", "rudongH6 : Rudong H6 -> 1 , 100\n", "rudongH8 : Rudong H8 -> 1 , 65\n", "brieuc : Saint-Brieuc -> 1 , 62\n", "nazaire : Saint-Nazaire -> 1 , 80\n", "sandbank : Sandbank -> 1 , 72\n", "seagreen : Seagreen -> 1 , 114\n", "shengsi2 : Shengsi 2 -> 1 , 63\n", "sheringham : Sheringham Shoal -> 2 , 88\n", "binhainorthH2 : SPIC Binhai North H2 -> 1 , 100\n", "triborkum : Trianel Windpark Borkum -> 1 , 72\n", "vejamate : Veja Mate -> 1 , 67\n", "vineyard : Vineyard Wind 1 -> 1 , 62\n", "rough : Westermost Rough -> 1 , 35\n", "wikinger : Wikinger -> 1 , 70\n", "jiaxing1 : Zhejiang Jiaxing 1 -> 1 , 74\n" ] } ], "source": [ "for L in locations:\n", " print(L.graph['handle'], ':', L.graph['name'], '->',\n", " L.graph['R'], ',', L.graph['T'])" ] }, { "cell_type": "markdown", "id": "3cf6486e", "metadata": {}, "source": [ "Any of the locations in this list can be directly passed to `WindFarmNetwork` instance as `L` graph, e.g.:\n", "```python\n", " wfn = WindFarmNetwork(L=locations.seagreen, cables=7)\n", "```" ] } ], "metadata": { "kernelspec": { "display_name": "OptiWindNet", "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.12.9" } }, "nbformat": 4, "nbformat_minor": 5 }