{ "cells": [ { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "# Static data" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "The `foxes` package comes with a set of data files whose main purpose is to serve for examples and tests. They are also a demonstration of the file formats that are required for input data. Such provided data files are often referred to as _static data_ in foxes terminology.\n", "\n", "Three different types of data are provided: Wind farm layout data, ambient states data, and power and thrust curve data." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n", "\n", "import foxes\n", "import foxes.variables as FV" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## Wind farm layout data" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "### test_farm_67.csv" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "This is a wind farm with 67 turbines with randomly generated turbine coordinates. The file starts as follows:\n", "\n", "```\n", "index,label,x,y\n", "0,T0,101872.70,1004753.57\n", "1,T1,103659.97,1002993.29\n", "2,T2,100780.09,1000779.97\n", "3,T3,100290.42,1004330.88\n", "4,T4,103005.58,1003540.36\n", "5,T5,100102.92,1004849.55\n", "6,T6,104162.21,1001061.70\n", "...\n", "```" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "The random layout looks like this:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "farm = foxes.WindFarm()\n", "foxes.input.farm_layout.add_from_file(\n", " farm, \"test_farm_67.csv\", turbine_models=[], verbosity=0\n", ")\n", "foxes.output.FarmLayoutOutput(farm).get_figure()\n", "plt.show()" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## Ambient states data" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "### WRF-Timeseries-4464.csv.gz" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "This data represents a timeseries with 4464 entries as obtained by the mesoscale simulation software [WRF](https://www.mmm.ucar.edu/models/wrf) at a single horizontal point with 8 different heights:\n", "\n", "```\n", "Time,WS-50,WS-75,...,WS-500,WD-50,WD-75,...,WD-500,TKE-50,TKE-75,...,TKE-500,RHO\n", "2009-01-01 00:00:00,7.37214,7.42685,...,1.28838\n", "...\n", "2009-01-31 23:50:00,10.27767,10.36368,...,1.30095\n", "```\n", "\n", "At 100 m height the wind distribution looks like this:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "states = foxes.input.states.MultiHeightTimeseries(\n", " data_source=\"WRF-Timeseries-4464.csv.gz\",\n", " output_vars=[FV.WS, FV.WD, FV.TI, FV.RHO],\n", " heights=[50, 75, 90, 100, 150, 200, 250, 500],\n", " fixed_vars={FV.TI: 0.05},\n", ")\n", "\n", "o = foxes.output.StatesRosePlotOutput(states, point=[0., 0., 100.])\n", "fig = o.get_figure(16, FV.AMB_WS, [0, 3.5, 6, 10, 15, 20], figsize=(6, 6))\n", "plt.show()" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "### abl_states_6000.csv.gz" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "This file describes binnded atmospheric boundary layer data, including Monin-Obukhov length in the column `mol`:\n", "\n", "```\n", "state,ws,wd,ti,mol,weight\n", "0,8.64,253.6,0.032,0.0,8.542331196166035e-05\n", "1,10.65,207.8,0.145,0.0,0.0001230528308906\n", "2,6.49,46.7,0.116,0.0,0.0001563449299843\n", "3,15.72,314.4,0.048,0.0,6.618827331554488e-05\n", "4,11.18,302.8,0.027,694.5,5.98695302482496e-05\n", "...\n", "```\n", "\n", "The distribution is well populated for all wind directions:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "states = foxes.input.states.StatesTable(\n", " data_source=\"abl_states_6000.csv.gz\",\n", " output_vars=[FV.WS, FV.WD, FV.TI, FV.RHO, FV.MOL],\n", " var2col={FV.WS: \"ws\", FV.WD: \"wd\", FV.TI: \"ti\", FV.MOL: \"mol\"},\n", " fixed_vars={FV.RHO: 1.225, FV.Z0: 0.05, FV.H: 100.0},\n", " profiles={FV.WS: \"ABLLogWsProfile\"},\n", ")\n", "\n", "o = foxes.output.StatesRosePlotOutput(states, point=[0., 0., 100.])\n", "fig = o.get_figure(16, FV.AMB_WS, [0, 3.5, 6, 10, 15, 20], figsize=(6, 6))\n", "plt.show()" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "### timeseries_3000.csv.gz" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "This is a timeseries with 3000 entries:\n", "\n", "```\n", "Time,WS,WD,TI,RHO\n", "2018-09-30 15:00:00,24.29,172.9,0.05,1.27\n", "2018-09-30 16:00:00,22.51,184.13,0.05,1.21\n", "2018-09-30 17:00:00,10.52,198.5,0.04,1.24\n", "2018-09-30 18:00:00,34.36,209.93,0.04,1.27\n", "2018-09-30 19:00:00,31.78,217.35,0.04,1.23\n", "2018-09-30 20:00:00,29.15,223.8,0.04,1.26\n", "2018-09-30 21:00:00,25.68,227.6,0.02,1.24\n", "...\n", "```\n", "\n", "The distribution is as follows:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "states = foxes.input.states.Timeseries(\n", " data_source=\"timeseries_3000.csv.gz\",\n", " output_vars=[FV.WS, FV.WD, FV.TI, FV.RHO],\n", ")\n", "\n", "o = foxes.output.StatesRosePlotOutput(states, point=[0., 0., 100.])\n", "fig = o.get_figure(16, FV.AMB_WS, [0, 3.5, 6, 10, 15, 20], figsize=(6, 6))\n", "plt.show()" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "### timeseries_8000.csv.gz" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "This is a timeseries with 8000 entries:\n", "\n", "```\n", "Time,ws,wd,ti\n", "2017-01-01 00:00:00,15.62,244.06,0.0504\n", "2017-01-01 00:30:00,15.99,243.03,0.0514\n", "2017-01-01 01:00:00,16.31,243.01,0.0522\n", "2017-01-01 01:30:00,16.33,241.26,0.0523\n", "2017-01-01 02:00:00,16.16,241.62,0.0518\n", "2017-01-01 02:30:00,15.95,242.21,0.0513\n", "...\n", "```\n", "\n", "The distribution is as follows:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "states = foxes.input.states.Timeseries(\n", " data_source=\"timeseries_8000.csv.gz\",\n", " output_vars=[FV.WS, FV.WD, FV.TI, FV.RHO],\n", " var2col={FV.WS: \"ws\", FV.WD: \"wd\", FV.TI: \"ti\"},\n", " fixed_vars={FV.RHO: 1.225},\n", ")\n", "\n", "o = foxes.output.StatesRosePlotOutput(states, point=[0., 0., 100.])\n", "fig = o.get_figure(16, FV.AMB_WS, [0, 3.5, 6, 10, 15, 20], figsize=(6, 6))\n", "plt.show()" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "### timeseries_100.csv.gz" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "A short timeseries with 100 entries and one minute time step, varying only wind direction:\n", "```\n", "Time,wd,ws\n", "2023-07-07 12:00:00,270.0,6.0\n", "2023-07-07 12:01:00,270.0,6.0\n", "...\n", "2023-07-07 12:20:00,270.0,6.0\n", "2023-07-07 12:21:00,269.836,6.0\n", "2023-07-07 12:22:00,269.344,6.0\n", "2023-07-07 12:23:00,268.532,6.0\n", "2023-07-07 12:24:00,267.406,6.0\n", "2023-07-07 12:25:00,265.981,6.0\n", "...\n", "2023-07-07 13:39:00,270.0,6.0\n", "```" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "The distribution is as follows:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "states = foxes.input.states.Timeseries(\n", " data_source=\"timeseries_100.csv.gz\",\n", " output_vars=[FV.WS, FV.WD, FV.TI, FV.RHO],\n", " var2col={FV.WS: \"ws\", FV.WD: \"wd\"},\n", " fixed_vars={FV.RHO: 1.225, FV.TI: 0.05},\n", ")\n", "\n", "o = foxes.output.StatesRosePlotOutput(states, point=[0., 0., 100.])\n", "fig = o.get_figure(16, FV.AMB_WS, [0, 3.5, 6, 10, 15, 20], figsize=(6, 6))\n", "plt.show()" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "### wind_rose_bremen.csv" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "This data file represents a (coarse) wind rose with 216 states, representing a site near Bremen, Germany. Each of the states consists of the wind direction and wind speed bin centres, and the respective statistical weight of the bin (normalized such that 1 represents 100%):\n", "\n", "```\n", "state,wd,ws,weight\n", "0,0.0,3.5,0.00158\n", "1,0.0,6.0,0.00244\n", "2,0.0,8.5,0.00319\n", "3,0.0,12.5,0.00367\n", "4,0.0,17.5,0.00042\n", "...\n", "```\n", "\n", "The distribution looks as follows:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "states = foxes.input.states.StatesTable(\n", " data_source=\"wind_rose_bremen.csv\",\n", " output_vars=[FV.WS, FV.WD, FV.TI, FV.RHO],\n", " var2col={FV.WS: \"ws\", FV.WD: \"wd\", FV.WEIGHT: \"weight\"},\n", " fixed_vars={FV.RHO: 1.225, FV.TI: 0.05},\n", ")\n", "\n", "o = foxes.output.StatesRosePlotOutput(states, point=[0., 0., 100.])\n", "fig = o.get_figure(16, FV.AMB_WS, [0, 3.5, 6, 10, 15, 20], figsize=(6, 6))\n", "plt.show()" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "### wind_rotation.nc" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "This is a very small example for inhomogeneous wind data, with 2 states, 4 points and 2 heights:\n", "\n", "```\n", "dimensions:\n", " state = 2 ;\n", " h = 2 ;\n", " y = 2 ;\n", " x = 2 ;\n", "variables:\n", " int state(state) ;\n", " float h(h) ;\n", " h:units = \"m\" ;\n", " h:long_name = \"Height\" ;\n", " float y(y) ;\n", " y:units = \"m\" ;\n", " float x(x) ;\n", " x:units = \"m\" ;\n", " float ws(state, h, y, x) ;\n", " ws:units = \"m/s\" ;\n", " ws:long_name = \"Wind speed\" ;\n", " float wd(state, h, y, x) ;\n", " wd:units = \"deg\" ;\n", " wd:long_name = \"Wind direction\" ;\n", "\n", "// global attributes:\n", " :title = \"Wind Rotation example\" ;\n", " :subtitle = \"A single wind state with uniform wind speed and spatial wind direction changes\" ;\n", " :author = \"IWES\" ;\n", " :date = \"22.06.2021\" ;\n", "data:\n", "\n", " state = 0, 1 ;\n", "\n", " h = 0, 300 ;\n", "\n", " y = 0, 2500 ;\n", "\n", " x = 0, 2500 ;\n", "\n", " ws =\n", " 9, 9,\n", " 9, 9,\n", " 9, 9,\n", " 9, 9,\n", " 9, 9,\n", " 9, 9,\n", " 9, 9,\n", " 9, 9 ;\n", "\n", " wd =\n", " 180, 270,\n", " 220, 250,\n", " 180, 270,\n", " 220, 250,\n", " 0, 120,\n", " 30, 90,\n", " 0, 120,\n", " 30, 90 ;\n", "```" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## Power and thrust curves" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "### DTU-10MW-D178d3-H119.csv" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "This file represents the DTU 10 MW reference turbine:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "mbook = foxes.models.ModelBook()\n", "mbook.turbine_types[\"DTU10\"] = foxes.models.turbine_types.PCtFile(\"DTU-10MW-D178d3-H119.csv\")\n", "\n", "fig, axs = plt.subplots(1, 2, figsize=(10, 4))\n", "o = foxes.output.TurbineTypeCurves(mbook)\n", "o.plot_curves(\"DTU10\", [FV.P, FV.CT], axs=axs)\n", "plt.show()" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "This turbine model is available in the default model book under the name `DTU10MW`." ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "### IEA-15MW-D240-H150.csv" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "This file represents the IEA 15 MW reference turbine:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "mbook = foxes.models.ModelBook()\n", "mbook.turbine_types[\"IEA15\"] = foxes.models.turbine_types.PCtFile(\"IEA-15MW-D240-H150.csv\")\n", "\n", "fig, axs = plt.subplots(1, 2, figsize=(10, 4))\n", "o = foxes.output.TurbineTypeCurves(mbook)\n", "o.plot_curves(\"IEA15\", [FV.P, FV.CT], axs=axs)\n", "plt.show()" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "This turbine model is available in the default model book under the name `IEA15MW`." ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "### IWT-7d5MW-D164-H100.csv" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "This file represents the IWES 7.5 MW reference turbine:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "mbook = foxes.models.ModelBook()\n", "mbook.turbine_types[\"IWT7.5\"] = foxes.models.turbine_types.PCtFile(\"IWT-7d5MW-D164-H100.csv\")\n", "\n", "fig, axs = plt.subplots(1, 2, figsize=(10, 4))\n", "o = foxes.output.TurbineTypeCurves(mbook)\n", "o.plot_curves(\"IWT7.5\", [FV.P, FV.CT], axs=axs)\n", "plt.show()" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "This turbine model is available in the default model book under the name `IWT7.5MW`." ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "### NREL-5MW-D126-H90.csv" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "This file represents the NREL 5 MW reference turbine:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "mbook = foxes.models.ModelBook()\n", "mbook.turbine_types[\"NREL5\"] = foxes.models.turbine_types.PCtFile(\"NREL-5MW-D126-H90.csv\")\n", "\n", "fig, axs = plt.subplots(1, 2, figsize=(10, 4))\n", "o = foxes.output.TurbineTypeCurves(mbook)\n", "o.plot_curves(\"NREL5\", [FV.P, FV.CT], axs=axs)\n", "plt.show()" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "This turbine model is available in the default model book under the name `NREL5MW`." ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## File paths" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "The available static data files can be listed by creating a `StaticData` object:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import foxes" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "dbook = foxes.StaticData()\n", "\n", "print(\"Farm:\\n\", dbook.toc(foxes.FARM))\n", "print(\"\\nStates:\\n\", dbook.toc(foxes.STATES))\n", "print(\"\\nCurves:\\n\", dbook.toc(foxes.PCTCURVE))" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "Note that the `toc` function requires as argument one of the three data categories. For each of the mentioned files we can then get the path in the local system:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "path = dbook.get_file_path(foxes.FARM, \"test_farm_67.csv\")\n", "print(type(path), \":\", path.relative_to(path.parents[3]))" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "The `path` is a full `PosixPath` object here, but only parts of it are shown in the printout (feel invited to print the complete file location when running this example yourself, simply by `print(path)`)." ] } ], "metadata": { "kernelspec": { "display_name": "foxescf", "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.8.10" }, "vscode": { "interpreter": { "hash": "49e77450ac3b792529b8ec53c4156102ea20ff425b704a19d2a6ff376cdbc220" } } }, "nbformat": 4, "nbformat_minor": 2 }