{ "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": "022c7b45-4650-49b8-b354-a6117cd16e2d", "metadata": {}, "outputs": [], "source": [ "import pprint" ] }, { "cell_type": "code", "execution_count": 2, "id": "a0ab2186-9b34-4e8b-bfe1-e0e69f8f1c68", "metadata": {}, "outputs": [], "source": [ "from optiwindnet.api import WindFarmNetwork, load_repository" ] }, { "cell_type": "code", "execution_count": 3, "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()` (without arguments) reads the `.osm.pbf` and `.yaml` locations distributed with *OptiWindNet*. The function returns a *namedtuple* of *networkx* graphs containing location data.\n", "\n", ">Note: `load_repository('path/to/custom/repo')` loads instead all `.osm.pbf` and `.yaml` files from the custom repository in that directory." ] }, { "cell_type": "code", "execution_count": 4, "id": "1909519a", "metadata": {}, "outputs": [], "source": [ "locations = load_repository()" ] }, { "cell_type": "code", "execution_count": 5, "id": "8c4a0be0-2c06-4240-8c4d-895ea4f5b3fc", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "['albatros', 'amalia', 'amrumbank', 'anglia', 'anholt', 'arkona', 'baltic2',\n", " 'bard', 'beatrice', 'belwind', 'binhainorthH2', 'bodhi', 'borkum', 'borkum2',\n", " 'borkum3', 'borssele', 'brieuc', 'bucht', 'butendiek', 'cazzaro_2022',\n", " 'cazzaro_2022G140', 'cazzaro_2022G210', 'changhua1', 'coastalva', 'dantysk',\n", " 'doggerA', 'doggerB', 'doggerC', 'dudgeon', 'eagle', 'fecamp', 'gabbin',\n", " 'galloper', 'gangkou1', 'gangkou2', 'gemini1', 'gemini2', 'glotech1', 'gode',\n", " 'gwynt', 'hedreiht', 'hohesee', 'horns', 'horns2', 'horns3', 'hornsea',\n", " 'hornsea2w', 'humber', 'inchcape', 'jiaxing1', 'kaskasi', 'kfA', 'kfB',\n", " 'kustzuid', 'lillgrund', 'lincs', 'london', 'luchterduinen', 'meerwind',\n", " 'merkur', 'mermaid', 'morayeast', 'moraywest', 'nanpeng', 'nazaire', 'neart',\n", " 'noirmoutier', 'nordsee', 'nordseeost', 'norther', 'northwind', 'nysted',\n", " 'ormonde', 'race', 'rampion', 'rental', 'riffgat', 'robin', 'rough',\n", " 'rudongH10', 'rudongH6', 'rudongH8', 'rudongdemo', 'rødsand2', 'sandbank',\n", " 'sands', 'seagreen', 'shengsi2', 'sheringham', 'sofia', 'taylor_2023',\n", " 'thanet', 'thor', 'treport', 'triborkum', 'triton', 'vejamate', 'vineyard',\n", " 'walney1', 'walney2', 'walneyext', 'wikinger', 'yi_2019', 'yunlin']\n", "Location count: 104\n" ] } ], "source": [ "pprint.pp(sorted(locations._fields), compact=True)\n", "print(f'Location count: {len(locations)}')" ] }, { "cell_type": "markdown", "id": "81767378", "metadata": {}, "source": [ "Each location is loaded as a *networkx* graph containing location data." ] }, { "cell_type": "code", "execution_count": 6, "id": "60b90866", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "networkx.classes.graph.Graph" ] }, "execution_count": 6, "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": 7, "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": 8, "id": "c0878ba3", "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "" ], "text/plain": [ "" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "wfn" ] }, { "cell_type": "markdown", "id": "70bf4bce", "metadata": {}, "source": [ "## List the locations in OptiWindNet's repository" ] }, { "cell_type": "markdown", "id": "a6a1ee1e", "metadata": {}, "source": [ "Print (for all available locations):\n", "- `handle`: short identifier\n", "- `name`: long form location name\n", "- `R`: number of Roots (Substations)\n", "- `T`: number of Terminals (Turbines)" ] }, { "cell_type": "code", "execution_count": 9, "id": "2b9349d3-0942-4710-aaaf-9e9e5b648877", "metadata": { "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Albatros (albatros) : R = 1, T = 16\n", "Amrumbank West (amrumbank) : R = 1, T = 80\n", "Anholt (anholt) : R = 1, T = 111\n", "Arkona (arkona) : R = 1, T = 60\n", "BARD Offshore 1 (bard) : R = 1, T = 80\n", "Baltic 2 (baltic2) : R = 1, T = 80\n", "Baltic Eagle (eagle) : R = 1, T = 50\n", "Beatrice (beatrice) : R = 2, T = 84\n", "Belwind (belwind) : R = 1, T = 55\n", "Borkum Riffgrund 1 (borkum) : R = 1, T = 78\n", "Borkum Riffgrund 2 (borkum2) : R = 1, T = 52\n", "Borkum Riffgrund 3 (borkum3) : R = 1, T = 83\n", "Borssele (borssele) : R = 2, T = 173\n", "Butendiek (butendiek) : R = 1, T = 80\n", "CECEP Yangjiang Nanpeng Island (nanpeng) : R = 1, T = 55\n", "CGN Rudong Demonstration (rudongdemo) : R = 1, T = 38\n", "Cazzaro-2022 (cazzaro_2022) : R = 1, T = 50\n", "Cazzaro-2022G-140 (cazzaro_2022G140) : R = 3, T = 140\n", "Cazzaro-2022G-210 (cazzaro_2022G210) : R = 3, T = 210\n", "Coastal Virginia (coastalva) : R = 3, T = 176\n", "DanTysk (dantysk) : R = 1, T = 80\n", "Deutsche Bucht (bucht) : R = 1, T = 31\n", "Dogger Bank A (doggerA) : R = 1, T = 95\n", "Dogger Bank B (doggerB) : R = 1, T = 95\n", "Dogger Bank C (doggerC) : R = 1, T = 87\n", "Dudgeon (dudgeon) : R = 1, T = 67\n", "East Anglia ONE (anglia) : R = 1, T = 102\n", "Fecamp (fecamp) : R = 1, T = 71\n", "Galloper Inner (galloper) : R = 1, T = 38\n", "Gemini 1 (gemini1) : R = 1, T = 75\n", "Gemini 2 (gemini2) : R = 1, T = 75\n", "Global Tech 1 (glotech1) : R = 1, T = 80\n", "Gode Wind 1 (gode) : R = 1, T = 55\n", "Greater Changhua 1 (changhua1) : R = 1, T = 75\n", "Greater Gabbard Inner (gabbin) : R = 1, T = 102\n", "Gwynt y Mor (gwynt) : R = 2, T = 160\n", "He Dreiht (hedreiht) : R = 1, T = 64\n", "Hohe See (hohesee) : R = 1, T = 71\n", "Hollandse Kust Zuid (kustzuid) : R = 2, T = 139\n", "Horns Rev 1 (horns) : R = 1, T = 80\n", "Horns Rev 2 (horns2) : R = 1, T = 91\n", "Horns Rev 3 (horns3) : R = 1, T = 49\n", "Hornsea One (hornsea) : R = 3, T = 174\n", "Hornsea Two West (hornsea2w) : R = 1, T = 110\n", "Huizhou Gangkou 1 (gangkou1) : R = 1, T = 40\n", "Huizhou Gangkou 2 (gangkou2) : R = 1, T = 64\n", "Humber Gateway (humber) : R = 1, T = 73\n", "Inch Cape (inchcape) : R = 1, T = 72\n", "Kaskasi (kaskasi) : R = 1, T = 38\n", "Kriegers Flak A (kfA) : R = 1, T = 24\n", "Kriegers Flak B (kfB) : R = 1, T = 48\n", "Laoting Bodhi Island (bodhi) : R = 1, T = 75\n", "Lillgrund (lillgrund) : R = 1, T = 48\n", "Lincs (lincs) : R = 1, T = 75\n", "London Array (london) : R = 2, T = 175\n", "Luchterduinen (luchterduinen) : R = 1, T = 43\n", "Meerwind (meerwind) : R = 1, T = 80\n", "Merkur (merkur) : R = 1, T = 66\n", "Mermaid (mermaid) : R = 1, T = 27\n", "Moray East (morayeast) : R = 3, T = 100\n", "Moray West (moraywest) : R = 2, T = 60\n", "Neart na Gaoithe (neart) : R = 2, T = 54\n", "Noirmoutier (noirmoutier) : R = 1, T = 61\n", "Nordsee One (nordsee) : R = 1, T = 54\n", "Nordsee Ost (nordseeost) : R = 1, T = 48\n", "Norther (norther) : R = 1, T = 44\n", "Northwind (northwind) : R = 1, T = 72\n", "Nysted (nysted) : R = 1, T = 72\n", "Ormonde (ormonde) : R = 1, T = 30\n", "Princess Amalia (amalia) : R = 1, T = 60\n", "Race Bank (race) : R = 2, T = 91\n", "Rampion (rampion) : R = 1, T = 116\n", "Rentel (rental) : R = 1, T = 42\n", "Riffgat (riffgat) : R = 1, T = 30\n", "Robin Rigg (robin) : R = 1, T = 60\n", "Rudong H10 (rudongH10) : R = 1, T = 100\n", "Rudong H6 (rudongH6) : R = 1, T = 100\n", "Rudong H8 (rudongH8) : R = 1, T = 65\n", "Rødsand 2 (rødsand2) : R = 1, T = 90\n", "SPIC Binhai North H2 (binhainorthH2) : R = 1, T = 100\n", "Saint-Brieuc (brieuc) : R = 1, T = 62\n", "Saint-Nazaire (nazaire) : R = 1, T = 80\n", "Sandbank (sandbank) : R = 1, T = 72\n", "Seagreen (seagreen) : R = 1, T = 114\n", "Shengsi 2 (shengsi2) : R = 1, T = 63\n", "Sheringham Shoal (sheringham) : R = 2, T = 88\n", "Sofia (sofia) : R = 1, T = 100\n", "Taylor-2023 (taylor_2023) : R = 2, T = 122\n", "Thanet (thanet) : R = 1, T = 100\n", "Thor (thor) : R = 1, T = 72\n", "Trianel Windpark Borkum (triborkum) : R = 1, T = 72\n", "Triton Knoll (triton) : R = 2, T = 90\n", "Tréport (treport) : R = 1, T = 62\n", "Veja Mate (vejamate) : R = 1, T = 67\n", "Vineyard Wind 1 (vineyard) : R = 1, T = 62\n", "Walney 1 (walney1) : R = 1, T = 51\n", "Walney 2 (walney2) : R = 1, T = 51\n", "Walney Extension (walneyext) : R = 2, T = 87\n", "West of Duddon Sands (sands) : R = 1, T = 108\n", "Westermost Rough (rough) : R = 1, T = 35\n", "Wikinger (wikinger) : R = 1, T = 70\n", "Yi-2019 (yi_2019) : R = 2, T = 119\n", "Yunlin (yunlin) : R = 2, T = 80\n", "Zhejiang Jiaxing 1 (jiaxing1) : R = 1, T = 74\n" ] } ], "source": [ "for L in sorted(locations, key=lambda loc: loc.graph['name']):\n", " print(f'{L.graph['name']} ({L.graph['handle']}) : '\n", " f'R = {L.graph['R']}, T = {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": { "language_info": { "name": "python" } }, "nbformat": 4, "nbformat_minor": 5 }