Skip to content

Commit c6eb6e6

Browse files
authored
Merge pull request #192 from VERITAS-Observatory/readme-updates
Readme updates
2 parents efe693a + a8a9386 commit c6eb6e6

File tree

2 files changed

+68
-121
lines changed

2 files changed

+68
-121
lines changed

CITATION.cff

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
cff-version: 1.2.0
44
message: If you use this software, please cite it using these metadata.
55
title: "V2DL3 - VERITAS (VEGAS and Eventdisplay) to DL3 Converter."
6-
# doi: TO BE FILLED
7-
version: 0.2.0
8-
date-released: 2022-02-28
6+
doi: 10.5281/zenodo.8306205
7+
version: 0.5.0
8+
date-released: 2023-09-08
99
keywords:
1010
- "gamma-ray astronomy"
1111
- "astronomy software"

README.md

Lines changed: 65 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -1,210 +1,157 @@
1-
# V2DL3 - VERITAS (VEGAS and Eventdisplay) to DL3 Converter.
1+
# V2DL3 - VERITAS (VEGAS and Eventdisplay) to DL3 Converter
22

3-
V2DL3 is a tool to convert VERITAS data products to DL3 FITS format, allowing to use e.g. the [Gammapy science tools](https://gammapy.org/) for analysis.
3+
[![License](https://img.shields.io/badge/License-BSD_3--Clause-blue.svg)](https://github.com/VERITAS-Observatory/V2DL3/blob/main/LICENSE)
4+
[![DOI](https://zenodo.org/badge/138582622.svg)](https://zenodo.org/badge/latestdoi/138582622)
45

5-
The converter can be used to convert point-like and full-enclosure IRFs.
6+
V2DL3 is a tool to convert [VERITAS](https://veritas.sao.arizona.edu/) data products to DL3 FITS format, allowing to use e.g. the [gammapy science tools](https://gammapy.org/) for the high-level analysis.
7+
8+
DL3 files include event lists, instrument response functions (IRFs) and observation index tables.
9+
The V2DL3 converter can be used to convert point-like and full-enclosure IRFs.
610
The FITS output follows the data formats for gamma-ray astronomy as defined in open [gamma-astro-data-formats](https://github.com/open-gamma-ray-astro/gamma-astro-data-formats) (GADF) repository.
711

8-
The projects tries to share as many tools as possible between VEGAS and Eventdisplay, especially those used for writing the FITS files.
12+
The V2DL3 project tries to share as many tools as possible between VEGAS and [Eventdisplay](https://github.com/VERITAS-Observatory/EventDisplay_v4), especially those used for writing the FITS files.
913

10-
The two main tools required to convert VERITAS data products to DL3 FITS format and use them with gammapy are:
11-
- converter to DL3 (`v2dl3-vegas` for VEGAS, `v2dl3_for_Eventdisplay.py` for Eventdisplay)
12-
- tool to generate observation index tables
14+
Two main steps are required to convert VERITAS data products to DL3 FITS format and use them with gammapy.
15+
Each of these steps are covered by one of the following tools:
1316

14-
For contributors: please note the section for developers below.
17+
- converter of event lists and instrument response functions to DL3 (`v2dl3-vegas` for VEGAS, `v2dl3-for-eventdisplay` for Eventdisplay)
18+
- `v2dl3-generate-index-file` tool to generate observation index tables
1519

16-
---
17-
# V2DL3 for VEGAS
20+
## V2DL3 for VEGAS
1821

19-
* VEGAS version >= 2.5.7
20-
* Requirements are listed in the ```environment-vegas.yml``` file.
21-
* Alternatively, a script which builds a Docker image with the latest V2DL3 and the prerequesite software for v2dl3-vegas is available. See *utils/v2dl3-vegas-docker/README.md*
22+
- VEGAS version >= 2.5.7
23+
- Requirements are listed in the ```environment-vegas.yml``` file.
24+
- Alternatively, a script which builds a Docker image with the latest V2DL3 and the prerequisite software for v2dl3-vegas is available. See *utils/v2dl3-vegas-docker/README.md*
2225

23-
## Installation
26+
### Installation
2427

25-
Use the [conda package manager](https://docs.conda.io/projects/conda/en/latest/user-guide/install/index.html) to install the dependenies:
26-
```
28+
Use the [conda package manager](https://docs.conda.io/projects/conda/en/latest/user-guide/install/index.html) to install the dependencies:
29+
30+
```bash
2731
conda env create -f environment-vegas.yml
2832
```
33+
2934
The environment ```v2dl3-vegas``` will be created and can be activated with:
3035

31-
```
36+
```bash
3237
conda activate v2dl3-vegas
3338
```
3439

3540
Install now pyV2DL3:
36-
```
41+
42+
```bash
3743
pip install .
3844
```
3945

4046
### Docker recipe
47+
4148
To use a Docker image with v2dl3-vegas pre-installed, see *utils/v2dl3-vegas-docker/README.md*
4249

43-
## The commandline tool v2dl3 with VEGAS
50+
### The command line tool v2dl3 with VEGAS
4451

4552
Run `v2dl3-vegas --help` to see all options.
4653

4754
See *README_vegas.md* for more information on newer v2dl3-vegas features such as ITM reconstruction, full-enclosure, and event classes.
4855

4956
Make sure you have ROOT with pyROOT enabled and VEGAS(>=v2.5.7) installed to proceed.
50-
Now, lets create the DL3 fits files from the stage 5 files in the ```./VEGAS/``` folder.
57+
Now, lets create the DL3 fits files from the stage 5 files in the ```./VEGAS/``` folder.
5158

52-
### One file at a time
59+
#### One file at a time
5360

54-
To convert a single stage 5 file to DL3 fits you need to provide the path to the stage 5 file as well as the corresponding effective area file using the flag ```-f```. The last argument is the name of the ouput DL3 file.
61+
To convert a single stage 5 file to DL3 fits you need to provide the path to the stage 5 file as well as the corresponding effective area file using the flag ```-f```. The last argument is the name of the output DL3 file.
5562

56-
```
63+
```bash
5764
v2dl3-vegas -f ./VEGAS/54809.med.ED.050.St5_Stereo.root ./VEGAS/EA_na21stan_medPoint_050_ED_GRISU.root ./test.fits
5865
```
5966

60-
### Generate from a VEGAS stage6 runlist
67+
#### Generate from a VEGAS stage6 run list
6168

62-
You can also provide a stage6 runlist to the command line tool. In this case the last argument is the folder where all the output DL3 files will be saved. Beware that the file names for the outputs are inferred from the root file name (xxx.root -> xxx.fits)
69+
You can also provide a stage6 run list to the command line tool. In this case the last argument is the folder where all the output DL3 files will be saved. Beware that the file names for the outputs are inferred from the root file name (xxx.root -> xxx.fits)
6370

64-
```
71+
```bash
6572
v2dl3-vegas -l ./runlist.txt ./test
6673
```
6774

68-
Runlists may be generated via a utility script.
75+
Run lists may be generated via a utility script.
6976

70-
```
77+
```bash
7178
python utils/vegas_runlister.py --help
7279
```
7380

74-
---
81+
## V2DL3 for EventDisplay
7582

76-
# V2DL3 for EventDisplay
83+
Requires data products generated with Eventdisplay version >= 490.
7784

78-
- use Eventdisplay version >= 487
79-
- recipes for Docker containers are available from the [V2DL3-Docker-recipes](https://github.com/Eventdisplay/V2DL3-Docker-recipes) repository.
85+
### Developer Installation
8086

81-
## Installation
87+
Install dependencies and activate the environment using the [conda package manager](https://docs.conda.io/projects/conda/en/latest/user-guide/install/index.html):
8288

83-
Use the [conda package manager](https://docs.conda.io/projects/conda/en/latest/user-guide/install/index.html) to install the dependenies:
84-
```
89+
```bash
8590
conda env create -f environment-eventdisplay.yml
86-
```
87-
88-
Activate the environment ```v2dl3Eventdisplay``` and set `PYTHONPATH`:
89-
90-
```
9191
conda activate v2dl3Eventdisplay
9292
export PYTHONPATH=$PYTHONPATH:"${PWD}"
9393
```
9494

95-
Note that no pip is required for using the v2dl3 tool with Eventdisplay.
95+
Note that no pip is required for using the v2dl3 tool with Eventdisplay
96+
(this will change in future).
9697

97-
## Usage of commandline tool v2dl3
98+
### Converting Eventdisplay data products to DL3
9899

99100
Run `python pyV2DL3/script/v2dl3_for_Eventdisplay.py --help` to see all options.
100101

101102
Convert an anasum output file to DL3.
102103
The following input is required:
104+
103105
- anasum file for a given run
104106
- effective area file for the corresponding cut applied during the preparation of the anasum file (DL3 version)
105107

106108
Example for point-like analysis:
107-
```
109+
110+
```bash
108111
python pyV2DL3/script/v2dl3_for_Eventdisplay.py -f 54809.anasum.root [Effective Area File] ./outputdir/54809.anasum.fits
109112
```
113+
110114
Example for full-enclosure analysis:
111-
```
115+
116+
```bash
112117
python pyV2DL3/script/v2dl3_for_Eventdisplay.py --full-enclosure -f 64080.anasum.root [Effective Area File] ./outputdir/64080.anasum.fits
113118
```
114119

115-
The run having their observational parameters (zenith, night sky background) outside but close to corresponding IRF axes range can be run with the one of the following two commandline parameters:
120+
The run having their observational parameters (e.g., zenith, night sky background) outside but close to corresponding IRF axes range can be converted with the one of the following two command line parameters:
116121

117-
- `--force_extrapolation`: This option extrapolates linearly the IRF at the run parameter value. Use this option with a caution since the exptrapolation happens even for run parameter values very far from the corresponding IRF axes range.
122+
- `--force_extrapolation`: This option extrapolates linearly the IRF at the run parameter value. Use this option with a caution since the extrapolation is applied even for run parameter values very far from the corresponding IRF axes range.
118123

119-
- `--fuzzy_boundary tolerance`: This option interpolates the IRF at the boundary value if the run parameter value is within the given tolerance. The tolerance is define as the ratio of absolute difference between boundary and run parameter value to boundary. Tolerances are given per IRF axes, with allowed axes are `zenith` and `pedvar` This option is preferable over `--force_extrapolation`. Example: `--fuzzy_boundary pedvar 0.10 --fuzzy_boundary zenith 0.05`.
124+
- `--fuzzy_boundary tolerance`: This option interpolates the IRF at the boundary value if the run parameter value is within the given tolerance. The tolerance is define as the ratio of absolute difference between boundary and run parameter value to boundary. This option is preferable over `--force_extrapolation`.
120125

121-
---
122-
# Data storage and generating index files
126+
## Data storage and generating index files
123127

124-
Two index files are required for DL3-type analysis and can be generated with the tool `generate_index_file.py`.
128+
Generate observation index and HDU tables for DL3 data storage are required to use with *gammapy* in for reading and analysis of the generated DL3 data.
129+
This steps is independent of VEGAS or Eventdisplay.
130+
The two index files are generated with the tool `generate_index_file.py`.
131+
132+
The tables are described on the [GADF website](https://gamma-astro-data-formats.readthedocs.io/en/v0.2/data_storage/index.html):
125133

126-
The tables are descriped on the [GADF website](https://gamma-astro-data-formats.readthedocs.io/en/v0.2/data_storage/index.html):
127134
- [Observation index table](https://gamma-astro-data-formats.readthedocs.io/en/v0.2/data_storage/obs_index/index.html)
128135
- [HDU index table](https://gamma-astro-data-formats.readthedocs.io/en/v0.2/data_storage/hdu_index/index.html)
129136

130137
To use `generate_index_file.py`, run:
138+
131139
- `generate_index_file --help` when using VEGAS
132-
- `python pyV2DL3/script/generate_index_file.py --help` when using Eventdisplay
140+
- `python pyV2DL3/script/generate_index_file.py --help` when using Eventdisplay
133141

134-
---
142+
## Contributing and Developing Code
135143

136-
# Contributing and Developing Code
144+
Your contribution is welcome!
137145

138146
A few remarks when contributing code:
147+
139148
- goal is to keep as much common code for converting from VEGAS or Eventdisplay data products
140149
- put package specific code into the [pyV2DL3/vegas](pyV2DL3/vegas) and [pyV2DL3/eventdisplay](pyV2DL3/eventdisplay) directories. As different environments are used for both packages, do not put any imports to vegas/eventdisplay in modules in pyV2DL3
141150

142-
To ensure readability, we try follow the Python [PEP8](https://www.python.org/dev/peps/pep-0008/) style guide.
151+
To ensure readability, we try follow the Python [PEP8](https://www.python.org/dev/peps/pep-0008/) style guide.
143152

144153
Functions and classes should contain a docstring with a short description.
145154

146-
Unit tests are encouraged and are available for few cases at this point. Unit tests are in the tests directory and can be called using [pytest](http://docs.pytest.org/).
155+
Unit tests are encouraged and are available for few cases at this point. Unit tests are in the tests directory and can be called using [pytest](http://docs.pytest.org/).
147156

148157
Use the [python logging system](https://docs.python.org/3/howto/logging.html) instead of the ‘print()’ function to output text. This allows to pipe all output into a log file and for different logging levels (INFO, DEBUG, …).
149-
150-
---
151-
152-
##### Multi file processing
153-
154-
To convert many runs at once with different Effective Area files there is a anasum script [ANALYSIS.anasum_parallel_from_runlist.sh](https://github.com/VERITAS-Observatory/Eventdisplay_AnalysisScripts_VTS/blob/main/scripts/ANALYSIS.anasum_parallel_from_runlist.sh), that can be used to create a ``` v2dl3_for_runlist_from_EDxxxx-anasum.sh ``` script. This script then contains one line for each processed file in the formatting as shown above in the point-like case. Here, xxxx is the Eventdisplay version (for eg. v487).
155-
156-
Then in your bash run
157-
```
158-
./v2dl3_for_runlist_from_EDxxxx-anasum.sh
159-
```
160-
to create the fits files one after another.
161-
162-
Alternatively, you can submit one job for each entry of this script using
163-
```bash
164-
v2dl3_qsub --v2dl3_script <script>
165-
```
166-
where `<script>` is the script that was written out by `ANALYSIS.anasum_parallel_from_runlist_v2dl3.sh`.
167-
`v2dl3_qsub` has the following options:
168-
- `--conda_env` name of the conda environment. Default is `v2dl3`
169-
- `--conda_exe` path to the conda executable. Only needed if `$CONDA_EXE` is not set.
170-
- `--rootsys` path to rootsys. Only needed if `$ROOTSYS` is not set
171-
- `--add_option` allows to add further options to v2dl3. (e.g. `--add_option '--evt_filter /path/to/file.yaml'`)
172-
173-
---
174-
**TEXT BELOW REQUIRES REVIEW**
175-
176-
#### Filter events
177-
Using --evt_filter option, you can filter which events are written to the fits file. The argument takes the path of a
178-
yaml file that stores conditions. E.g. to select only events between 0.5 and 1.0 TeV:
179-
```yaml
180-
Energy: [0.5, 1.0]
181-
```
182-
183-
---
184-
### Git pushing
185-
If two people have used the same notebook at the same time it gets a bit nasty with a merge due to differences in outputs and cell run counts. To overcome this I have followed the instructions in http://timstaley.co.uk/posts/making-git-and-jupyter-notebooks-play-nice/
186-
187-
Specifically, this requires that you have jq (https://stedolan.github.io/jq/) which should be easy enough to install, I get it through brew on my mac (I'm not sure what happens if you don't have jq installed - maybe you will find out!).
188-
189-
The following files have been edited to allow for this (in this repository directory, if you want you can set some of this up globally).
190-
191-
.git/config
192-
```
193-
[core]
194-
attributesfile = .gitattributes
195-
196-
[filter "nbstrip_full"]
197-
clean = "jq --indent 1 \
198-
'(.cells[] | select(has(\"outputs\")) | .outputs) = [] \
199-
| (.cells[] | select(has(\"execution_count\")) | .execution_count) = null \
200-
| .metadata = {\"language_info\": {\"name\": \"python\", \"pygments_lexer\": \"ipython3\"}} \
201-
| .cells[].metadata = {} \
202-
'"
203-
smudge = cat
204-
required = true
205-
```
206-
207-
.gitattributes
208-
```
209-
*.ipynb filter=nbstrip_full
210-
```

0 commit comments

Comments
 (0)