Skip to content

Commit 2329514

Browse files
dmousadiMOUSADI Despoina
andauthored
TRR tools in user scripts (#155)
* Scripts for NectarCAM camera test suite * Added test scripts * pre-commit * Delete src/nectarchain/user_scripts/dmousadi/test_scripts/requirements.txt --------- Co-authored-by: MOUSADI Despoina <[email protected]>
1 parent 2358b3c commit 2329514

File tree

10 files changed

+4214
-0
lines changed

10 files changed

+4214
-0
lines changed
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
2+
# NectarCAM Test Scripts
3+
4+
Automated tests from the Test Readiness Review document for the CTA NectarCAM based on [nectarchain](https://github.com/cta-observatory/nectarchain) and [ctapipe](https://github.com/cta-observatory/ctapipe). This project can test for the following requirements:
5+
- B-TEL-1010 Intensity resolution & B-TEL-1390 Linearity (script [linearity_test.py](tests/linearity_test.py))
6+
- B-TEL-1030 Time resolution (script [pix_couple_tim_uncertainty_test.py](tests/pix_couple_tim_uncertainty_test.py))
7+
- B-TEL-1260 Deadtime, B-TEL-1270 Deadtime Measurement & B-MST-1280 Event Rate (script [deadtime_test.py](tests/deadtime_test.py))
8+
- B-TEL-1370 Pedestal subtraction (script [pedestal_test.py](tests/pedestal_test.py))
9+
- B-TEL-1380 Systematic pixel timing uncertainty (script [pix_tim_uncertainty_test.py](tests/pix_tim_uncertainty_test.py))
10+
11+
12+
## Table of Contents
13+
14+
- [Installation](#installation)
15+
- [Usage](#usage)
16+
- [Features](#features)
17+
- [Contributing](#contributing)
18+
19+
20+
## Installation
21+
22+
Instructions on how to install and set up the project:
23+
```
24+
git clone https://drf-gitlab.cea.fr/dmousadi/camera-test-scripts
25+
cd camera-test-scripts
26+
pip install -r requirements.txt
27+
```
28+
If you want to automatically download your data, one of the requirements is also DIRAC, for which you need to have a grid certificate. It is not necessary for this repo, if you have your NectarCAM runs (fits files) locally stored. You can find more information about DIRAC [here](https://gitlab.cta-observatory.org/cta-computing/dpps/workload/CTADIRAC). If you are installing these packages for the first time and getting 'error building wheel', you might need to (re)install some of these: swig, ca-certificates, openssl, boost, protobuff, cmake.
29+
30+
Once you have set up your environment, if you're not already a nectarchain user you need to set the NECTARCAMDATA environment variable to the directory where you have the NectarCAM runs:
31+
```
32+
conda activate your_env_name
33+
mkdir -p $CONDA_PREFIX/etc/conda/activate.d
34+
mkdir -p $CONDA_PREFIX/etc/conda/deactivate.d
35+
nano $CONDA_PREFIX/etc/conda/activate.d/env_vars.sh
36+
nano $CONDA_PREFIX/etc/conda/deactivate.d/env_vars.sh
37+
```
38+
In activate.d/env_vars.sh add:
39+
```
40+
export NECTARCAMDATA=your_path_to_nectarcamdata
41+
```
42+
And then in deactivate.d/env_vars.sh:
43+
```
44+
unset NECTARCAMDATA
45+
```
46+
47+
48+
According to nectarchain, the directory should have this structure:
49+
```
50+
NECTARCAMDATA/runs/{fits_files}
51+
```
52+
If the structure is different in your server (testbench server, looking at you) you could do a symbolic link of the form:
53+
```
54+
ln -s /data/ZFITS/*/*/* nectarcamdatafolder/runs
55+
```
56+
57+
58+
## Usage
59+
60+
The test scripts can be run autonomously, or through a GUI. To run the gui you can just start it with python:
61+
```
62+
python gui.py
63+
```
64+
In the gui you can pick the test and set the parameters needed or keep the default ones. The most important parameter in every test is <b>runlist</b>, where you state which runs you want to process. If you have this runs in your NECTARCAMDATA, they will be found there and processed, otherwise if you don't have them but you're using DIRAC, they will be downloaded there. All tests have an <b>output</b> parameter, where you state where you want to save the plots produced by the tests. The <b>evts</b> parameter indicates the amount of events that are going to be processed (more events = more accurate results but more runtime). The linearity test also requires the corresponding transmission for each of the runs in the list, while in the timing uncertainty between couples of pixels you have to add the path to the csv file containing the PMT transit time values (calculated by Federica, might be stored in a database later).
65+
To have a better look at the parameters, you can also run the tests on their own with the help option:
66+
```
67+
python tests/linearity_test.py --help
68+
```
69+
When everything is ready, you can press on run test.
70+
71+
72+
## Features
73+
74+
List of key features of the project:
75+
76+
- GUI to run tests automatically
77+
- If runs aren't already present, they will be downloaded with DIRAC
78+
- Tests process runs and create a plot showing the results. Intermediate results for each separate run are saved in HDF5 tables in a folder in NECTARCAMDATA. The plot is saved in a specified folder, as well as in a temporary file which is read by the GUI
79+
- Plot display with zoom and navigation
80+
- Output logs and parameters displayed dynamically
81+
82+
The test scripts essentially loop through the runs using the ctapipe Tool and Component classes, and then process the runs all together to calculate the results that go into the final plot.
83+
84+
## Contributing
85+
86+
You can contribute by adding more tests. The full list of tests is [here](https://docs.google.com/spreadsheets/d/1t5Z9ZHRESB6BYzmMbyFCDDALgTqvSb1KpJ8JMEiZgnI/edit?usp=sharing). It is planned to discuss about the implementation of more of the tests.
87+
88+
Guidelines for contributing to the project:
89+
90+
1. Fork the repository
91+
2. Create a new branch (`git checkout -b feature-branch`)
92+
3. Make your changes
93+
4. Commit your changes (`git commit -am 'Add new feature'`)
94+
5. Push to the branch (`git push origin feature-branch`)
95+
6. Create a new Pull Request
96+
97+
## Notes
98+
99+
This project uses a lot of methods developped by Federica Bradascio, and has also taken inspiration from Guillaume Grolleron's tutorials in nectarchain about using the ctapipe Tool class.
100+
101+
For the in-code documentation I have used Cody (Copilot's free-ish cousin). I have checked everything but I still could have missed some mistake in explaining the code's functions.

0 commit comments

Comments
 (0)