|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "metadata": { |
| 6 | + "collapsed": true, |
| 7 | + "pycharm": { |
| 8 | + "name": "#%% md\n" |
| 9 | + } |
| 10 | + }, |
| 11 | + "source": [ |
| 12 | + "# Dependencies" |
| 13 | + ] |
| 14 | + }, |
| 15 | + { |
| 16 | + "metadata": {}, |
| 17 | + "cell_type": "code", |
| 18 | + "source": [ |
| 19 | + "import os\n", |
| 20 | + "import numpy as np\n", |
| 21 | + "\n", |
| 22 | + "import matplotlib.pyplot as plt\n", |
| 23 | + "from matplotlib import rcParams\n", |
| 24 | + "from mpl_toolkits.axes_grid1.inset_locator import InsetPosition\n", |
| 25 | + "import seaborn as sns\n", |
| 26 | + "\n", |
| 27 | + "from ledsa.postprocessing.simulation import StackedSimData" |
| 28 | + ], |
| 29 | + "outputs": [], |
| 30 | + "execution_count": null |
| 31 | + }, |
| 32 | + { |
| 33 | + "cell_type": "markdown", |
| 34 | + "source": "# Display Config", |
| 35 | + "metadata": { |
| 36 | + "collapsed": false |
| 37 | + } |
| 38 | + }, |
| 39 | + { |
| 40 | + "cell_type": "code", |
| 41 | + "source": [ |
| 42 | + "rcParams['font.family'] = 'serif'\n", |
| 43 | + "rcParams['font.size'] = 10\n", |
| 44 | + "cm = 1 / 2.54" |
| 45 | + ], |
| 46 | + "metadata": { |
| 47 | + "collapsed": false, |
| 48 | + "pycharm": { |
| 49 | + "name": "#%%\n" |
| 50 | + } |
| 51 | + }, |
| 52 | + "outputs": [], |
| 53 | + "execution_count": null |
| 54 | + }, |
| 55 | + { |
| 56 | + "cell_type": "markdown", |
| 57 | + "source": "# Load Simulation Data", |
| 58 | + "metadata": { |
| 59 | + "collapsed": false |
| 60 | + } |
| 61 | + }, |
| 62 | + { |
| 63 | + "metadata": {}, |
| 64 | + "cell_type": "code", |
| 65 | + "source": [ |
| 66 | + "# Input Dir (Simulations)\n", |
| 67 | + "path_simulation = '/Path/to/simulation'\n", |
| 68 | + "sim = StackedSimData(path_simulation)" |
| 69 | + ], |
| 70 | + "outputs": [], |
| 71 | + "execution_count": null |
| 72 | + }, |
| 73 | + { |
| 74 | + "metadata": {}, |
| 75 | + "cell_type": "markdown", |
| 76 | + "source": "# Extinction Coefficients" |
| 77 | + }, |
| 78 | + { |
| 79 | + "metadata": {}, |
| 80 | + "cell_type": "markdown", |
| 81 | + "source": "## Plot extinction coefficients as a function of time for a specific LED array and height" |
| 82 | + }, |
| 83 | + { |
| 84 | + "metadata": {}, |
| 85 | + "cell_type": "code", |
| 86 | + "source": [ |
| 87 | + "# Parameters\n", |
| 88 | + "led_array_id = 1 # LED array to analyze\n", |
| 89 | + "window = 3 # Size of moving average window\n", |
| 90 | + "color_channels = [0, 1, 2] # RGB channels\n", |
| 91 | + "height = 2\n", |
| 92 | + "\n", |
| 93 | + "# Create figure\n", |
| 94 | + "fig, ax = plt.subplots(figsize=(10, 6))\n", |
| 95 | + "\n", |
| 96 | + "# Plot extinction coefficients for each channel\n", |
| 97 | + "for channel in color_channels:\n", |
| 98 | + " # Get extinction coefficients at specified height\n", |
| 99 | + " extco = sim.get_extco_at_height(channel=channel, height=height, window=window)\n", |
| 100 | + "\n", |
| 101 | + " # Plot with different colors for each channel\n", |
| 102 | + " colors = ['red', 'green', 'blue']\n", |
| 103 | + " ax.plot(extco.index, extco.iloc[:, led_array_id],\n", |
| 104 | + " color=colors[channel],\n", |
| 105 | + " label=f'Channel {channel}')\n", |
| 106 | + "\n", |
| 107 | + "ax.set_xlabel('Time / s')\n", |
| 108 | + "ax.set_ylabel('Extinction Coefficient / $\\mathrm{m^{-1}}$')\n", |
| 109 | + "ax.set_title(f'Extinction Coefficients at Height {height} m, LED Array {led_array_id}')\n", |
| 110 | + "ax.grid(True)\n", |
| 111 | + "ax.legend()\n", |
| 112 | + "plt.tight_layout()\n", |
| 113 | + "plt.show()" |
| 114 | + ], |
| 115 | + "outputs": [], |
| 116 | + "execution_count": null |
| 117 | + }, |
| 118 | + { |
| 119 | + "metadata": {}, |
| 120 | + "cell_type": "markdown", |
| 121 | + "source": "## Plot extinction coefficients as a function of height and LED array for a specific point in time" |
| 122 | + }, |
| 123 | + { |
| 124 | + "metadata": {}, |
| 125 | + "cell_type": "code", |
| 126 | + "source": [ |
| 127 | + "# Parameters\n", |
| 128 | + "time = 200 # Time point to analyze in seconds\n", |
| 129 | + "channel = 0 # RGB channels\n", |
| 130 | + "window = 20 # Size of moving average window\n", |
| 131 | + "\n", |
| 132 | + "# Find closest time point to given time\n", |
| 133 | + "closest_time = sim.get_closest_time(time)\n", |
| 134 | + "\n", |
| 135 | + "extco = sim.get_extco_at_time(channel=channel, time=closest_time, window=window, yaxis='height')\n", |
| 136 | + "sns.heatmap(extco.iloc[::-1], cmap='jet', vmax=0.4, cbar_kws={'label': 'Extinction Coefficient / $\\mathrm{m^{-1}}$'})\n", |
| 137 | + "plt.tight_layout()" |
| 138 | + ], |
| 139 | + "outputs": [], |
| 140 | + "execution_count": null |
| 141 | + }, |
| 142 | + { |
| 143 | + "metadata": {}, |
| 144 | + "cell_type": "markdown", |
| 145 | + "source": "## Plot extinction coefficients as a function of height for a specific LED array and point in time\n" |
| 146 | + }, |
| 147 | + { |
| 148 | + "cell_type": "code", |
| 149 | + "source": [ |
| 150 | + "# Parameters\n", |
| 151 | + "time = 200 # Time point to analyze in seconds\n", |
| 152 | + "window = 3 # Size of moving average window\n", |
| 153 | + "led_array_id = 2 # LED array to analyze\n", |
| 154 | + "color_channels = [0, 1, 2] # RGB channels\n", |
| 155 | + "\n", |
| 156 | + "# Find closest time point to given time\n", |
| 157 | + "closest_time = sim.get_closest_time(time)\n", |
| 158 | + "\n", |
| 159 | + "# Create figure\n", |
| 160 | + "fig, ax = plt.subplots(figsize=(10, 6))\n", |
| 161 | + "\n", |
| 162 | + "# Plot extinction coefficients for each channel\n", |
| 163 | + "for channel in color_channels:\n", |
| 164 | + " # Get extinction coefficients at specified time\n", |
| 165 | + " extco = sim.get_extco_at_time(channel=channel, time=closest_time, window=window, yaxis='height')\n", |
| 166 | + "\n", |
| 167 | + " # Plot with different colors for each channel\n", |
| 168 | + " colors = ['red', 'green', 'blue']\n", |
| 169 | + " ax.plot(extco.iloc[:, led_array_id], extco.index,\n", |
| 170 | + " color=colors[channel],\n", |
| 171 | + " label=f'Channel {channel}')\n", |
| 172 | + "\n", |
| 173 | + "ax.set_xlabel('Extinction Coefficient / $\\mathrm{m^{-1}}$')\n", |
| 174 | + "ax.set_ylabel('Height / m')\n", |
| 175 | + "ax.set_title(f'Extinction Coefficients at Time {closest_time} s, LED Array {led_array_id}')\n", |
| 176 | + "ax.grid(True)\n", |
| 177 | + "ax.legend()\n", |
| 178 | + "plt.tight_layout()\n", |
| 179 | + "plt.show()\n" |
| 180 | + ], |
| 181 | + "metadata": { |
| 182 | + "collapsed": false, |
| 183 | + "pycharm": { |
| 184 | + "name": "#%%\n" |
| 185 | + } |
| 186 | + }, |
| 187 | + "outputs": [], |
| 188 | + "execution_count": null |
| 189 | + }, |
| 190 | + { |
| 191 | + "metadata": {}, |
| 192 | + "cell_type": "code", |
| 193 | + "source": "", |
| 194 | + "outputs": [], |
| 195 | + "execution_count": null |
| 196 | + }, |
| 197 | + { |
| 198 | + "metadata": {}, |
| 199 | + "cell_type": "code", |
| 200 | + "source": "", |
| 201 | + "outputs": [], |
| 202 | + "execution_count": null |
| 203 | + } |
| 204 | + ], |
| 205 | + "metadata": { |
| 206 | + "kernelspec": { |
| 207 | + "display_name": "Python 3", |
| 208 | + "language": "python", |
| 209 | + "name": "python3" |
| 210 | + }, |
| 211 | + "language_info": { |
| 212 | + "codemirror_mode": { |
| 213 | + "name": "ipython", |
| 214 | + "version": 2 |
| 215 | + }, |
| 216 | + "file_extension": ".py", |
| 217 | + "mimetype": "text/x-python", |
| 218 | + "name": "python", |
| 219 | + "nbconvert_exporter": "python", |
| 220 | + "pygments_lexer": "ipython2", |
| 221 | + "version": "2.7.6" |
| 222 | + } |
| 223 | + }, |
| 224 | + "nbformat": 4, |
| 225 | + "nbformat_minor": 0 |
| 226 | +} |
0 commit comments