Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop kb #72

Merged
merged 124 commits into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
124 commits
Select commit Hold shift + click to select a range
52f77d5
change datatype of several columns for hdf to int
kriboe90 Apr 28, 2021
5037d3d
add option to merge led arrays
kriboe90 Sep 28, 2021
0594754
Avoid skipping num_ref_images at the beginning to prevent averaging r…
kriboe90 Sep 28, 2021
787fd26
Add option for averaging properties of images by summarizing n images…
kriboe90 Sep 30, 2021
59b6fad
bugfixes
kriboe90 Sep 30, 2021
9ef63b3
figing image number bug
kriboe90 Sep 30, 2021
afcaa5c
adding temporary workarounds for merging led arrays
kriboe90 Sep 30, 2021
d849297
add led array merge option to config file
kriboe90 Oct 5, 2021
25ad689
add option to manually change weighting factor for for extinction coe…
kriboe90 Oct 5, 2021
f9d12f2
bugfixes
kriboe90 Oct 5, 2021
a61dc8a
bugfixes + adding option for changing number of iterations
kriboe90 Oct 5, 2021
148cc13
automatically calculate number of led arrays
kriboe90 Oct 5, 2021
782050f
Merge branch 'add_multi_image_averaging' into develop_kb
kriboe90 Jul 4, 2022
b427ddb
add missing imports
kriboe90 Jul 4, 2022
7424711
Merge branch 'master' into develop_kb
kriboe90 Jul 5, 2022
0fc6f77
resolve merge conflicts and add missing dependencies
kriboe90 Jul 5, 2022
cb525ab
Add Config for data analysis
kriboe90 Nov 24, 2022
7d91cce
Change reading of experiment data from config_analysis.ini
kriboe90 Nov 24, 2022
e2ba71b
Add Config for data analysis
kriboe90 Nov 24, 2022
20b9ddd
Change reading of experiment data from config_analysis.ini
kriboe90 Nov 24, 2022
f3bf91d
Merge remote-tracking branch 'origin/develop_kb_add_config' into deve…
kriboe90 Nov 24, 2022
4e20555
change parser argument for reading analysis config
kriboe90 Nov 28, 2022
6b0b5f9
add init config load statements
kriboe90 Nov 28, 2022
519f1ab
add check for availability of computed data from s1 - s3
kriboe90 Nov 28, 2022
e6c9496
move reference_property from parser to config file
kriboe90 Nov 28, 2022
f1e4378
minor changes in config
kriboe90 Nov 28, 2022
fc661e5
automatically activate multicore processing if num_of_cores larger 1
kriboe90 Nov 28, 2022
6043837
add ConfigDataAnalysis and exceptions for reading configk files
kriboe90 Dec 5, 2022
569aa41
refactoring
kriboe90 Dec 5, 2022
21614e3
outsourcing image reading functions
kriboe90 Dec 5, 2022
895a34c
edit config entries
kriboe90 Dec 6, 2022
eb44b4f
edit config entries
kriboe90 Dec 6, 2022
0461a7f
outsourcing image reading functions
kriboe90 Dec 6, 2022
f17c310
outsourcing image reading functions
kriboe90 Dec 6, 2022
76d5c00
add checks for input parameter
kriboe90 Dec 6, 2022
79385ae
refactoring and bugfixes
kriboe90 Dec 6, 2022
f7beff0
Merge branch 'develop_kb_add_config' into develop_kb
kriboe90 Dec 6, 2022
71de49e
refactoring and bugfixes
kriboe90 Dec 6, 2022
a1fd8b6
refactoring and bugfixes
kriboe90 Dec 6, 2022
351e017
refactoring and bugfixes
kriboe90 Dec 14, 2022
cabaa9e
add Acceptance Tests for computation of extinction coefficients
kriboe90 Dec 14, 2022
afc5978
edit tests
kriboe90 Mar 22, 2023
6f7ce36
print output of minimize function instead of internal display argumen…
kriboe90 Aug 8, 2023
70e6d32
add check for computed extinction coefficient results against input data
kriboe90 Aug 9, 2023
0d830a5
edits in tests configuration
kriboe90 Aug 9, 2023
2619656
set tempdir as workdir
kriboe90 Aug 9, 2023
a52e10e
add local yml file for testing
kriboe90 Aug 9, 2023
6606554
make adjustmenst for newer versions of pandas and scipy
kriboe90 Aug 10, 2023
6eba36d
add requirements.txt
kriboe90 Aug 10, 2023
8b48b5c
refactoring on tests
kriboe90 Aug 10, 2023
8557800
update s3 according to updated scipy version
kriboe90 Aug 10, 2023
d6e71e2
edit robot framework yaml file
kriboe90 Aug 10, 2023
22cf173
edit robot framework yaml file
kriboe90 Aug 10, 2023
ced066f
edit gitignore
kriboe90 Aug 10, 2023
0d5b3e4
fixing typos
kriboe90 Aug 10, 2023
450be99
resolving bugfixes, warnings and typos
kriboe90 Aug 10, 2023
5180566
remove unit tests
kriboe90 Aug 10, 2023
f253649
remove multi camera
kriboe90 Aug 10, 2023
a981607
remove GUI
kriboe90 Aug 10, 2023
820988c
remove testtools
kriboe90 Aug 10, 2023
5772173
refactoring and defining path by os.path.join()
kriboe90 Aug 11, 2023
ff1843e
bugfixing
kriboe90 Aug 11, 2023
a211507
adding docstrings and typehints
kriboe90 Aug 17, 2023
e1808d6
adding docstrings and typehints
kriboe90 Aug 17, 2023
dfcbb3d
adding docstrings and typehints
kriboe90 Aug 17, 2023
f1f1182
adding docstrings and typehints
kriboe90 Aug 17, 2023
4a69bd5
adding docstrings and typehints
kriboe90 Aug 17, 2023
7f2ec09
adding docstrings and typehints
kriboe90 Aug 17, 2023
563cef0
adding docstrings and typehints
kriboe90 Aug 18, 2023
d368324
adding docstrings and typehints
kriboe90 Aug 18, 2023
043d59d
adding docstrings and typehints
kriboe90 Aug 18, 2023
fa02371
adding docstrings and typehints
kriboe90 Aug 18, 2023
31235be
adding docstrings and typehints and delete unused code
kriboe90 Aug 18, 2023
6289e5c
adding docstrings and typehints and delete unused code
kriboe90 Aug 18, 2023
c78d006
adding docstrings
kriboe90 Aug 18, 2023
880e81e
adding docstrings
kriboe90 Aug 18, 2023
9d8a3f2
adding docstrings and typehints
kriboe90 Aug 20, 2023
531ea84
adding docstrings and typehints
kriboe90 Aug 20, 2023
bf1505c
adding docstrings and typehints
kriboe90 Aug 20, 2023
e483c48
adding docstrings
kriboe90 Aug 21, 2023
81bcbaa
adding docstrings
kriboe90 Aug 21, 2023
ff84715
adding docstrings and typehints
kriboe90 Aug 22, 2023
68192b0
adding docstrings
kriboe90 Aug 22, 2023
6ef78ce
adding docstrings and typehints
kriboe90 Aug 22, 2023
adadd86
adding docstrings
kriboe90 Aug 22, 2023
fb5cbbe
removing dead code
kriboe90 Aug 22, 2023
eb200ae
adding docstrings
kriboe90 Aug 22, 2023
14ec2e9
adding docstrings
kriboe90 Aug 22, 2023
7d4bca5
adding docstrings and typehints
kriboe90 Aug 22, 2023
b7caa05
make adjustements according to changed structure of config file
kriboe90 Aug 22, 2023
9ad30f5
edit Sphinx Config
kriboe90 Aug 22, 2023
9969afa
edit makefile for sphinx
kriboe90 Aug 22, 2023
6d9664d
edit sphinx requirements
kriboe90 Aug 22, 2023
9b5a18d
add functions for demo download and setup
kriboe90 Aug 22, 2023
916fb95
move demo module inside ledsa module, edit dem_run, make function to …
kriboe90 Aug 23, 2023
448b354
removing unnecessary code
kriboe90 Aug 23, 2023
49681bf
bugfixes and resolving TODOs
kriboe90 Aug 23, 2023
6cc80ec
editing download function, adding docstrings
kriboe90 Aug 23, 2023
3e90715
move tests inside ledsa nodule
kriboe90 Aug 23, 2023
93627ba
refactoring and moving led_positions calculation
kriboe90 Aug 24, 2023
d7aae51
refactoring demo functions
kriboe90 Aug 24, 2023
df3fb5e
refactoring parser arguments
kriboe90 Aug 24, 2023
617534e
refactoring and aditing documentation
kriboe90 Aug 24, 2023
729a463
refactoring and editing documentation
kriboe90 Aug 24, 2023
f6dce57
outsource parser_arguments_declaration.py arguments and run functions…
kriboe90 Aug 24, 2023
fb402b9
outsource parser_arguments_declaration.py arguments and run functions…
kriboe90 Aug 24, 2023
8406ad5
edit documentation
kriboe90 Aug 24, 2023
b127550
remove unused files
kriboe90 Aug 24, 2023
6684286
update requirements.txt
kriboe90 Aug 24, 2023
5b974f8
move parser files to core
kriboe90 Aug 24, 2023
4504245
edit tests
kriboe90 Aug 24, 2023
4a59379
remove ledpositions main function
kriboe90 Aug 24, 2023
e9b91fa
remove todos
kriboe90 Aug 24, 2023
b0b60cc
edit test working dir
kriboe90 Aug 24, 2023
3584b1f
cleanup
kriboe90 Aug 24, 2023
0730ae7
edit setup.cfg and LICENSE.md
kriboe90 Aug 24, 2023
e5a7b20
update requirements.txt
kriboe90 Aug 25, 2023
c1c87d3
adjust test directory in github workflow file
kriboe90 Aug 25, 2023
df364df
update_gitignore
kriboe90 Aug 25, 2023
b9e83df
remove files
kriboe90 Aug 25, 2023
c7264d7
fixing typo in tests path
kriboe90 Aug 25, 2023
aafcce1
remove temp workflow file
kriboe90 Aug 25, 2023
ac27326
edit README.md
kriboe90 Aug 25, 2023
6a574ce
edit run_robot_framework_tests.yml
kriboe90 Aug 25, 2023
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
78 changes: 36 additions & 42 deletions .github/workflows/run_robot_framework_tests.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# runs tests for push-events, for pull requests and using cron schedule:
name: Run Robot Framework Tests

# This workflow gets triggered on pushes and pull requests to the master branch.
# Tests are not run at changes on the README file.
on:
push:
# runs tests for commits pushed to master
branches:
- master
# do not run tests if file README.md changes
paths-ignore:
- 'README.md'
# run tests for GitHub Pull requests. Test result is visible in the Pull Request page.
pull_request:
paths-ignore:
- 'README.md'
Expand All @@ -17,48 +16,43 @@ jobs:
run_tests:
runs-on: ubuntu-latest
steps:
# checkout code from a repository
- uses: actions/checkout@v2
# checkout code from the repository
- name: Checkout repository
uses: actions/checkout@v3

# Sets up the specified Python version
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip'

# Install project dependencies
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt

# Add LEDSA to PYTHONPATH
- name: Add LEDSA to PYTHONPATH
run: echo "PYTHONPATH=$GITHUB_WORKSPACE" >> $GITHUB_ENV

# create folder for test reports
- name: Create folder for reports
run: mkdir reports
# run Robot Framework tests inside Docker container

# run Robot Framework tests
- name: Run Robot Framework Tests
# container used here is ppodgorsek/robot-framework:latest
# see container documentation for usage: https://hub.docker.com/r/ppodgorsek/robot-framework/dockerfile
# it is required that GitHub repository contains folder "reports". Commit some file inside "reports" to create it
# place tests in folder tests or change docker run command accordingly
# configure -e ROBOT_OPTIONS according to yout tests, or remove it if no special configuration is needed
run: |
docker run \
-v ${PWD}/reports:/opt/robotframework/reports:Z \
-v ${PWD}/tests/AcceptanceTests:/opt/robotframework/tests:Z \
-v ${PWD}/ledsa:/usr/local/lib/python3.8/site-packages/ledsa:Z \
--user $(id -u):$(id -g) \
svor/docker-robot-framework-ledsa:latest
# upload test reports as a zip file
- name: Upload reports
uses: actions/upload-artifact@v1
robot \
--outputdir reports \
ledsa/tests/AcceptanceTests

# If the tests fail, this step ensures the logs are uploaded for inspection
- name: Upload Robot Framework logs
# This condition ensures the step runs regardless of the test outcome
if: always()
uses: actions/upload-artifact@v2
with:
name: reports
# set path to Robot Framework results reports. Exclude dummy file that is needed because of ppodgorsek image priviledges.
path: ${{ github.workspace }}/reports
# repository name is needed for posting test report in a next step
- name: Get Repository Name
run: |
export REPO="$(echo "${{ github.repository }}" | awk -F / '{print $2}' | sed -e "s/:refs//")"
echo "REPOSITORY_NAME=$REPO" >> $GITHUB_ENV
# when test are run for a commit, post results as a comment
# note: comment is not posted for tests triggered for pull requests, only for a main branch (master)
- name: Send test report as comment to commit
uses: joonvena/robotframework-reporter-action@v2
with:
gh_access_token: ${{ secrets.GITHUB_TOKEN }}
if: ${{ github.event_name == 'push' }}
env:
# GH_ACCESS_TOKEN: ${{ github.TOKEN }}
REPO_OWNER: ${{ github.REPOSITORY_OwNER }}
COMMIT_SHA: ${{ github.SHA }}
REPOSITORY: ${{ env.REPOSITORY_NAME }}
REPORT_PATH: ${{ github.workspace }}/tests/AcceptanceTests/reports
name: robot-framework-logs
path: results/
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,19 @@ venv.bak/
# mypy
.mypy_cache/

# Pycharm
/.idea

#data & output
helper_tools/
data/
out/
plots/
analysis/
test.py
img_infos.csv
config.ini
config_analysis.ini
experiment_data.txt
.vscode/settings.json
/test_output/
log.html
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2021 Lukas Arnold
Copyright 2023 Lukas Arnold, Kristian Börger

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
37 changes: 6 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,46 +1,21 @@
# LEDSmokeAnalysis

LEDSmokeAnalysis (LEDSA) is scientific program to analyse the extinction of light due to smoke in the air from image data. An experimental setup is needed, in which a camera captures pictures of lines of leds. The software is designed to improve our understanding of the propagation of smoke and the visibiltiy in rooms filled with smoke during a fire. For further information about how the program works and the experimental setup see [papers]. An example for an experimental setup is shown below:\
[img setup]
The whole documentation can be found [link to doc]
LEDSA (LEDSmokeAnalysis) is a python based software package for the computation of spatially and temporally resolved light extinction coefficients from photometric measurements. The method relies on capturing the change in intensity of individual light sources due to fire induced smoke. Images can be accquired within laboratory experiments using commercially available digital cameras.


## Installation

To install LEDSA python 3 and an acutal version of pip need to be installed.
To install LEDSA python 3 and an actual version of pip need to be installed.
Then run:

`python3 -m pip install ledsa`

## Usage

LEDSA can be run directly from the console with

`python3 -m ledsa`.

### Configuration File

A configuration file is needed which defines the behaviour of LEDSA and some pathes etc. With the `--config` flag a default configuration file can be created inside the working directory. Further information about all the variables set in the config file can be found [here]. It is a good idea to make a template configuration file if multiple, similar experiments are analysed.

### Intensity Calculations

To find the intensity changes over multiple images, 3 steps are to be taken.\
Step 1 finds and labels each led from a reference image which shoud not contain any smoke. To do this run

`python3 -m ledsa --s1`.

Step 2 finds and labels the different led arrays. You will be asked to write the different indices of the edges of the led arrays into the shell, which will be saved in the config file. The information is found in ./plots/led_search_areas.plot.pdf, generated in step 1. The flag is `--s2`

Step 3 calculates a measure for the itensities for every image and every led. The Flag `--s3` fits a 2D Function over every led as described in [paper]. This is computational very expencive. `--s3_fast` counts the color values of each pixel for every led, which is much faster.

To calculate the extinction coefficients, the 3D coordinates of every led needs to be known. `--coord` calculates them from the coordinates of the edge leds used in step 2.

### Extinction Coefficient Calculations

To calculate the extinction coefficients run
To use the LEDSA CLI, the general structure is as follows:

`python3 -m ledsa.analysis`
`python -m ledsa [ARGUMENT] [OPTIONS]`

after finishing step 3. Some setup data is needed like the position of the camera. `--default_input` creates a file for this information.

## Contributing

Expand All @@ -50,4 +25,4 @@ Pull request drafts can be used to communicate about changes and new functionali

After reviewing and testing the changes, they will be merged into master.

Every merge with master is followed by introducing a new version tag corresponding to the semantic versioning pradigm.
Every merge with master is followed by introducing a new version tag corresponding to the semantic versioning paradigm.
19 changes: 0 additions & 19 deletions demo/__main__.py

This file was deleted.

12 changes: 12 additions & 0 deletions docs/_static/tables.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* Restrict table width to 100% of the container */
.rst-content table.docutils {
width: 100%;
table-layout: auto;
max-width: 100%; /* Ensure table doesn't expand beyond container */
}

/* Ensure table cell content wraps between words */
.rst-content table.docutils td,
.rst-content table.docutils th {
white-space: normal; /* This ensures content will wrap between words */
}
21 changes: 21 additions & 0 deletions docs/analysis.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Analysis
========

.. automodule:: ledsa.analysis.ExtinctionCoefficientsNumeric
:members:
:undoc-members:
:show-inheritance:

.. automodule:: ledsa.analysis.ExtinctionCoefficientsAnalytic
:members:
:undoc-members:
:show-inheritance:

.. warning::
Analytical computation of extinction coefficients is in a test state and has not yet been sufficiently evaluated. The application may lead to incorrect results.


.. automodule:: ledsa.analysis.Experiment
:members:
:undoc-members:
:show-inheritance:
120 changes: 120 additions & 0 deletions docs/cli_documentation.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@

CLI Documentation
=================

General Usage
-------------

To use the LEDSA CLI, the general structure is as follows::

python -m ledsa [ARGUMENT] [OPTIONS]

Arguments
---------

Data Extraction
^^^^^^^^^^^^^^^

.. list-table::
:widths: 20 50 30
:header-rows: 1

* - Argument
- Description
- Options
* - ``-conf``, ``--config``
- Create the data extraction configuration file.
- --
* - ``--s1``, ``--step_1``, ``--find_search_areas``
- Step 1: Analyze a reference image to find the LEDs and create a labeled plot with the search areas.
- --
* - ``-s2``, ``--step_2``, ``--analyse_positions``
- Step 2: Match the LEDs to the arrays according to the line edge indices in the config file.
- --
* - ``-s3``, ``--step_3`, ``--analyse_photo``
- Step 3: Analyse all images to extract pixel values inside the search areas and fit them to an LED model (SLOW!).
- ``--r`` (Use the red channel, default), ``--g`` (Use the green channel), ``--b`` (Use the blue channel), ``-rgb`` (Run for each channel)
* - ``-s3_fast``, ``--step_3_fast`, ``--analyse_photo_fast``
- Step 3: Analyse all images to extract pixel values and calculate the accumulated values inside the search areas (FAST!).
- --
* - ``-re``, ``--restart``
- Restart step 3 if it was previously interrupted. Only the images that have not been analysed are taken into account.
- --


Analysis
^^^^^^^^

.. list-table::
:widths: 20 50 30
:header-rows: 1

* - Argument
- Description
- Options
* - ``-conf_a``, ``--config_analysis``
- Creates the analysis configuration file.
- --
* - ``-a``, ``--analysis``
- Computes the extinction coefficients.
- --
* - ``--cc``
- Applies the color correction matrix before calculating the extinction coefficients. Use only if the reference property is not already color corrected.
- --
* - ``--cc_channels``
- Specifies the channels to which color correction gets applied.
- Can extend the list of channels, Multiple values allowed.

.. warning::
Color Correction is in a test state and has not yet been sufficiently evaluated. The application may lead to incorrect results.

Coordinates
^^^^^^^^^^^

.. list-table::
:widths: 20 50 30
:header-rows: 1

* - Argument
- Description
- Options
* - ``-coord``, ``--coordinates``
- Calculate the 3D coordinates of the LEDs based on the calculated pixel positions and the physical edge coordinates of the LED arrays.
- --

Testing
^^^^^^^

.. list-table::
:widths: 20 50 30
:header-rows: 1

* - Argument
- Description
- Options
* - ``-atest``, ``--acceptance-test``
- Run the acceptance test suite.
- --
* - ``-atest_debug``, ``--acceptance-test_debug``
- Run the acceptance test suite in debug mode.
- --

Demo
^^^^

.. list-table::
:widths: 20 50 30
:header-rows: 1

* - Argument
- Description
- Options
* - ``-d``, ``--demo``
- Flag to indicate that the LEDSA demo should be run.
- Must be used with ``--setup`` or ``--run``
* - ``--setup``
- Create the required directories for the simulations and download images and config files.
- Optional: Path to setup simulation and image directories. Default to ``'.'``
* - ``--run``
- Run the LEDSA demo in the current working directory.
- --
Loading
Loading