Skip to content

Commit c369eff

Browse files
authored
Merge pull request #127 from FireDynamics/develop_stacked_extinction_coefficients_computation
Develop stacked extinction coefficients computation
2 parents 9c99d08 + 8c424ff commit c369eff

14 files changed

Lines changed: 1916 additions & 373 deletions

doc/analysis.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ Analysis
2222
:show-inheritance:
2323

2424
.. automodule:: ledsa.analysis.ExperimentData
25+
:members:
26+
:undoc-members:
27+
:show-inheritance:
28+
29+
Stacked Multi-Camera Analysis
30+
------------------------------
31+
32+
.. automodule:: ledsa.analysis.StackedExtinctionCoefficients
2533
:members:
2634
:undoc-members:
2735
:show-inheritance:

doc/cli_documentation.rst

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
CLI Documentation
32
=================
43

@@ -68,6 +67,26 @@ Analysis
6867
.. warning::
6968
Color Correction is in a test state and has not yet been sufficiently evaluated. The application may lead to incorrect results.
7069

70+
Stacked Multi-Camera Analysis
71+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
72+
73+
.. list-table::
74+
:widths: 20 50 30
75+
:header-rows: 1
76+
77+
* - Argument
78+
- Description
79+
- Options
80+
* - ``-conf_s [FILENAME]``, ``--config_stacked [FILENAME]``
81+
- Create a template ``config_stacked.ini`` for multi-camera stacked analysis. The optional argument sets the output filename (default: ``config_stacked.ini``).
82+
- ``--n_simulations N`` sets the number of simulation blocks in the template (default: 2).
83+
* - ``--n_simulations N``
84+
- Number of ``[simulation_N]`` blocks written into the template ``config_stacked.ini``. Only used together with ``-conf_s``.
85+
- Default: 2
86+
* - ``-as``, ``--analysis_stacked``
87+
- Run the stacked multi-camera extinction coefficient calculation using ``config_stacked.ini`` in the current directory.
88+
- --
89+
7190
Coordinates
7291
^^^^^^^^^^^
7392

@@ -117,4 +136,4 @@ Demo
117136
- Optional: Path to setup simulation and image directories. Default to ``'.'``
118137
* - ``--run``
119138
- Run the LEDSA demo in the current working directory.
120-
- --
139+
- --

doc/config.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,11 @@ ConfigDataAnalysis
1717
:members:
1818
:undoc-members:
1919
:show-inheritance:
20+
21+
ConfigDataStacked
22+
-----------------
23+
24+
.. automodule:: ledsa.analysis.ConfigDataStacked
25+
:members:
26+
:undoc-members:
27+
:show-inheritance:
Lines changed: 226 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,226 @@
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+
}

ledsa/__main__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from ledsa.core.parser_arguments_declaration import (add_parser_arguments_tools, add_parser_arguments_data_extraction,
77
add_parser_arguments_testing, add_parser_arguments_demo, add_parser_argument_analysis)
88
from ledsa.core.parser_arguments_run import run_tools_arguments, run_data_extraction_arguments, run_testing_arguments, run_demo_arguments, \
9-
run_analysis_arguments, run_analysis_arguments_with_extinction_coefficient
9+
run_analysis_arguments, run_analysis_arguments_with_extinction_coefficient, run_stacked_analysis
1010

1111

1212
def main(argv: List[str]) -> None:
@@ -40,9 +40,10 @@ def main(argv: List[str]) -> None:
4040
run_data_extraction_arguments(args)
4141
run_analysis_arguments(args)
4242
run_analysis_arguments_with_extinction_coefficient(args)
43+
run_stacked_analysis(args)
4344
run_testing_arguments(args)
4445

4546

4647

4748
if __name__ == "__main__":
48-
main(sys.argv[1:])
49+
main(sys.argv[1:])

0 commit comments

Comments
 (0)