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
38 changes: 36 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,42 @@ The intensities are not clipped at zero after the black level of the sensor is s
LED that has vanished in dense smoke can give a relative intensity at or below zero. The linear
solver leaves such LEDs out. Where the transmission reaches the read noise of the sensor, the LEDs
that remain are those whose noise happened to be positive, and the extinction coefficients come
out too low: in fog tests by 14 to 31 % at 1.24 and 1.64 1/m, where the transmission of the red
LEDs was 0.1 to 0.2 % of I0.
out too low. With `sum_col_val` this hardly happens, because the pedestal of the search areas (see
below) keeps the relative intensities above zero and limits the extinction coefficients first: in
a fog test, single images came out 21 to 27 % too low at 1.24 1/m and 36 to 42 % at 1.64 1/m.
With the pedestal subtracted (`farbg_sum_col_val`) the read noise limits, by 5 to 6 % and 24 to
26 %, where the transmission of the red LEDs was 0.02 to 0.15 % of I0 and the noise of a single
image about 0.2 % of I0. Averaging seven images (`average_images`) lowered this to 13 to 17 % at
1.64 1/m.

### Pedestal from the far field of the LED strips (optional)

The sum over a search area holds light that does not dim with the LED: the dark level of the
sensor where it differs from the optical black, ambient light and light that smoke scatters into
the line of sight. In dense smoke this pedestal saturates the extinction coefficients. With

```ini
[analyse_photo]
farfield_distances = 150 300
```

in `config.ini`, step 3 estimates the pedestal for every image in two bands parallel to each LED
strip, 150 to 300 px away from it on both sides and at least 150 px away from every LED, smooths
the levels along the strip, takes the lower side and writes two more quantities:
`farbg_sum_col_val`, the sum minus the pedestal of the search area, and `farbg_pedestal`, the
pedestal itself. `reference_property = farbg_sum_col_val` analyses the corrected sum. The bands
have to lie beyond the light of the LEDs and of their halo; `farbg_pedestal / sum_col_val` of the
reference images shows whether they do, it stays below about 1 % there. An LED whose bands hold
no pixel on either side, and no neighbour on its strip within the smoothing that has one, keeps
its plain sum with a pedestal of 0. The default `None` estimates no pedestal and leaves the
result files as they are.

For the dark level of the sensor and for stray light that peaks at the strip, the far-field level
is a lower bound of the pedestal, so the corrected sum lies between the plain sum and the light
of the LED in the search area. Ambient light on a background that is brighter beside the strip
than behind the LEDs breaks this bound; it has been tested in dark rooms only. It does
not correct a search area that loses light of the LED, as behind a fogged window, which is an
error of the opposite sign.

### Features in validation

Expand Down
6 changes: 5 additions & 1 deletion doc/data_extraction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ Data Extraction
.. automodule:: ledsa.data_extraction.LEDAnalysisData
:members:
:undoc-members:
:show-inheritance:
:show-inheritance:
.. automodule:: ledsa.data_extraction.farfield_background
:members:
:undoc-members:
:show-inheritance:
6 changes: 4 additions & 2 deletions ledsa/analysis/ExtinctionCoefficientsLinear.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ def calc_coefficients_of_img(self, rel_intensities: np.ndarray) -> np.ndarray:

Known limitation: where the transmission approaches the read noise of the sensor, the LEDs that
are left are those whose noise happened to be positive, so the extinction coefficients come out
too low. On the Warsaw tests V008 and V009 this was 14 to 31 % at 1.24 and 1.64 1/m, where the
transmission of the red LEDs was 0.1 to 0.2 % of I0.
too low. In single images of the Warsaw fog test V008 this was 5 to 6 % at 1.24 1/m and 24 to 26 %
at 1.64 1/m for farbg_sum_col_val, where the transmission of the red LEDs was 0.02 to 0.15 % of I0.
For sum_col_val the pedestal of the search areas keeps the relative intensities above zero and
limits first, by 21 to 27 % and 36 to 42 %.

:param rel_intensities: Array of relative (normalized) LED intensities (I_e/I_0).
:type rel_intensities: np.ndarray
Expand Down
11 changes: 10 additions & 1 deletion ledsa/core/ConfigData.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __init__(self, load_config_file=True, img_directory=None, search_area_radius
first_img_experiment_id=None, last_img_experiment_id=None, ref_img_id=None, ignore_led_indices=None,
led_array_edge_indices=None, led_array_edge_coordinates=None, first_img_analysis_id=None,
last_img_analysis_id=None, num_skip_imgs=0, ref_img_experiment_ids=None, num_skip_leds=0,
merge_led_array_indices=None): # TODO: merge LED arrays
merge_led_array_indices=None, farfield_distances=None): # TODO: merge LED arrays
"""
:param load_config_file: Determines whether to load the config file on initialization. Defaults to True.
:type load_config_file: bool
Expand Down Expand Up @@ -93,6 +93,10 @@ def __init__(self, load_config_file=True, img_directory=None, search_area_radius
:type num_skip_leds: int
:param merge_led_array_indices: Flag to merge LED arrays for analysis. Defaults to None. TODO: not a flag but list of arrays to merge?
:type merge_led_array_indices: bool or None
:param farfield_distances: Inner and outer distance in pixels across the LED strip of the far-field bands
the pedestal of farbg_sum_col_val is estimated in, e.g. '150 300'. None, the default, estimates no
pedestal: step 3 writes sum_col_val, mean_col_val and max_col_val only.
:type farfield_distances: str or None
"""
cp.ConfigParser.__init__(self, allow_no_value=True)
if load_config_file:
Expand Down Expand Up @@ -177,6 +181,11 @@ def __init__(self, load_config_file=True, img_directory=None, search_area_radius
self['analyse_photo'][' ref_img_experiment_ids'] = str(ref_img_experiment_ids)
self.set('analyse_photo', ' # In the analysis, only LEDs are considered with id dividable by skip_leds + 1.')
self['analyse_photo'][' num_skip_leds'] = str(num_skip_leds)
self.set('analyse_photo', ' # Pedestal of the search areas from the far field of the LED strips (farbg_sum_col_val):')
self.set('analyse_photo', ' # inner and outer distance in pixels across the strip of the bands on both of its sides,')
self.set('analyse_photo', ' # e.g. 150 300. The bands have to lie beyond the light of the LEDs and of their halo.')
self.set('analyse_photo', ' # None: no pedestal is estimated.')
self['analyse_photo'][' farfield_distances'] = str(farfield_distances)

with open('config.ini', 'w', encoding='utf-8') as configfile:
self.write(configfile)
Expand Down
9 changes: 7 additions & 2 deletions ledsa/core/file_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -686,15 +686,20 @@ def create_binary_data(channel: int, path: str = '.') -> None:
BGSUB_COLUMNS = ["bgsub_sum_col_val"]
SIDEBG_COLUMNS = ["sidebg_sum_col_val", "sidebg_pedestal", "bgsub2_sum_col_val"]
NOISE_SUM_COLUMNS = ["noise_sum_col_val"]
FARBG_COLUMNS = ["farbg_sum_col_val", "farbg_pedestal"]
LED_CENTER_COLUMNS = ["led_center_x", "led_center_y"]
FIT_COLUMNS = ["x", "y", "dx", "dy", "A", "alpha", "wx", "wy", "fit_success", "fit_fun", "fit_nfev", "fit_time"]

# Known layouts by the number of names (including img_id). Step 3 writes the first two; the others are those of
# earlier versions, whose background-corrected sums and read noise v0.13.0 no longer computes but still reads.
# Known layouts by the number of names (including img_id). Step 3 writes the first four, the two with the
# far-field pedestal if farfield_distances is set; the others are those of earlier versions, whose
# background-corrected sums and read noise v0.13.0 no longer computes but still reads.
COLUMN_LAYOUTS = {
len(BASE_COLUMNS): BASE_COLUMNS, # -s3_fast, before v0.11.0 and since v0.13.0
len(BASE_COLUMNS + LED_CENTER_COLUMNS + FIT_COLUMNS):
BASE_COLUMNS + LED_CENTER_COLUMNS + FIT_COLUMNS, # -s3 with fit, since v0.13.0
len(BASE_COLUMNS + FARBG_COLUMNS): BASE_COLUMNS + FARBG_COLUMNS, # -s3_fast with the far-field pedestal
len(BASE_COLUMNS + FARBG_COLUMNS + LED_CENTER_COLUMNS + FIT_COLUMNS):
BASE_COLUMNS + FARBG_COLUMNS + LED_CENTER_COLUMNS + FIT_COLUMNS, # -s3 with fit and the far-field pedestal
len(BASE_COLUMNS + BGSUB_COLUMNS): BASE_COLUMNS + BGSUB_COLUMNS, # -s3_fast, before the side band pedestal
len(BASE_COLUMNS + BGSUB_COLUMNS + SIDEBG_COLUMNS):
BASE_COLUMNS + BGSUB_COLUMNS + SIDEBG_COLUMNS, # -s3_fast of v0.11.0
Expand Down
9 changes: 9 additions & 0 deletions ledsa/data_extraction/LEDAnalysisData.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ class LEDAnalysisData:
:vartype sum_color_value: float
:ivar max_color_value: Maximum color value observed for the LED.
:vartype max_color_value: float
:ivar farbg_sum_color_value: Integrated color value minus the far-field pedestal of the search area, None if
the pedestal is not estimated.
:vartype farbg_sum_color_value: float or None
:ivar farbg_pedestal: Far-field pedestal of the search area, None if the pedestal is not estimated.
:vartype farbg_pedestal: float or None
:ivar fit_results: Fit results after fitting.
:vartype fit_results: OptimizeResult
:ivar fit_time: Time taken for fitting.
Expand All @@ -41,6 +46,8 @@ def __init__(self, led_id, led_array, fit_leds):
self.mean_color_value = None
self.sum_color_value = None
self.max_color_value = None
self.farbg_sum_color_value = None
self.farbg_pedestal = None
self.fit_leds = fit_leds
self.fit_results = None
self.fit_time = None
Expand Down Expand Up @@ -68,6 +75,8 @@ def get_main_data_string(self) -> str:
"""
out_str = f'{self.led_id:4d},{self.led_array:2d},'
out_str += f'{self.sum_color_value:10.4e},{self.mean_color_value:10.4e},{self.max_color_value}'
if self.farbg_sum_color_value is not None:
out_str += f',{self.farbg_sum_color_value:10.4e},{self.farbg_pedestal:10.4e}'
return out_str

def get_fit_data_string(self) -> str:
Expand Down
Loading
Loading