Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#
import os
import sys
from importlib.metadata import version as get_version
sys.path.insert(0, os.path.abspath('..'))

# -- Project information -----------------------------------------------------
Expand All @@ -20,7 +21,7 @@
project = 'LEDSmokeAnalysis'
copyright = '2026, CCE'
author = 'CCE'
release = '0.9.6'
release = get_version('ledsa')

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
2 changes: 1 addition & 1 deletion examples/postprocessing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@
"closest_time = sim.get_closest_time(time)\n",
"\n",
"extco = sim.get_extco_at_time(channel=channel, time=closest_time, window=window, yaxis='height')\n",
"sns.heatmap(extco, cmap='jet', vmax=0.4, cbar_kws={'label': 'Extinction Coefficient / $\\mathrm{m^{-1}}$'})\n",
"sns.heatmap(extco.iloc[::-1], cmap='jet', vmax=0.4, cbar_kws={'label': 'Extinction Coefficient / $\\mathrm{m^{-1}}$'})\n",
"plt.tight_layout()"
],
"outputs": [],
Expand Down
6 changes: 4 additions & 2 deletions ledsa/analysis/ExtinctionCoefficients.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from ledsa.analysis.Experiment import Experiment, Layers, Camera
from ledsa.core.file_handling import read_hdf, read_hdf_avg, extend_hdf, create_analysis_infos_avg

from importlib.metadata import version

class ExtinctionCoefficients(ABC):
"""
Expand Down Expand Up @@ -57,7 +58,7 @@ def __init__(self, experiment, reference_property='sum_col_val', num_ref_imgs=10

def __str__(self):
out = str(self.experiment) + \
f'reference_property: {self.reference_property}, num_ref_imgs: {self.num_ref_imgs}\n'
f'reference_property: {self.reference_property}, num_ref_imgs: {self.num_ref_imgs}, LEDSA {version("ledsa")}\n'
return out

def calc_and_set_coefficients(self) -> None:
Expand Down Expand Up @@ -151,7 +152,8 @@ def calc_distance_array(self) -> np.ndarray:
"""
distances = np.zeros((self.experiment.num_leds, self.experiment.layers.amount))
count = 0
for led in self.experiment.leds:
# self.experiment.leds need to be reversed to build the distance array the right way
for led in reversed(self.experiment.leds):
d = self.experiment.calc_traversed_dist_per_layer(led)
distances[count] = d
count += 1
Expand Down
5 changes: 3 additions & 2 deletions ledsa/analysis/ExtinctionCoefficientsLinear.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ def calc_coefficients_of_img(self, rel_intensities: np.ndarray) -> np.ndarray:
"""
# Avoid log(0) by clipping intensities to a small positive value
eps = 1e-10
target = np.clip(rel_intensities, eps, 1.0)
rel_intensities_clipped = np.clip(rel_intensities, eps, 1.0)

# Compute the optical depth vector: b = -ln(I_e/I_0)
# This linearizes the Beer-Lambert law: I_e/I_0 = exp(-sum(sigma_i * distance_i))
optical_depths = -np.log(target)
optical_depths = -np.log(rel_intensities_clipped)

# Get dimensions of the problem
n_leds, n_layers = self.distances_per_led_and_layer.shape
Expand Down Expand Up @@ -85,6 +85,7 @@ def calc_coefficients_of_img(self, rel_intensities: np.ndarray) -> np.ndarray:

# Solve the non-negative least squares problem: min ||A_aug*x - b_aug||^2 subject to x >= 0
sigmas, residuals = nnls(A_aug, b_aug)
# sigmas, residuals, rank, s = np.linalg.lstsq(A_aug, b_aug, rcond=None)

return sigmas

Expand Down
Loading
Loading