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

Semi-automatic scripts on the last MCP version #217

Merged
merged 292 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
292 commits
Select commit Hold shift + click to select a range
5416209
bug
Elisa-Visentin Apr 30, 2024
a0c0529
multi-source merging
Elisa-Visentin Apr 30, 2024
361f20a
Updates on list_from_h5.py
ranieremenezes Apr 30, 2024
ba7a5af
Update list_from_h5.py
ranieremenezes Apr 30, 2024
a5a738e
Updates in setting_up_config_and_dir.py
ranieremenezes Apr 30, 2024
3ca3464
bug fix
Elisa-Visentin Apr 30, 2024
68eb31d
Merge branch 'Torino_auto_MCP' of https://github.com/cta-observatory/…
Elisa-Visentin Apr 30, 2024
3ef52dd
typo/bug
Elisa-Visentin Apr 30, 2024
d0807ba
Update README.md
ranieremenezes Apr 30, 2024
240dbe2
fix directories
Elisa-Visentin Apr 30, 2024
13d6aed
directories
Elisa-Visentin Apr 30, 2024
50107a3
coincidence updates
Elisa-Visentin May 1, 2024
36590ed
stereo
Elisa-Visentin May 2, 2024
1370c57
Update check_MAGIC_runs.py
joannaWojS May 2, 2024
ff5d52c
pre-commit + both h5 + minor fixes
Elisa-Visentin May 3, 2024
0c45a2d
SLURM fixes
Elisa-Visentin May 3, 2024
672fa0c
bug
Elisa-Visentin May 3, 2024
8ec28e6
some fixes
Elisa-Visentin May 3, 2024
818551d
bug in slurm
Elisa-Visentin May 3, 2024
04e54d0
moved production of slurm script lines to a separate function
jsitarek May 8, 2024
27f234c
added acccidently removed new line
jsitarek May 8, 2024
151d55b
using bash slurm lines generated in clusters.py
jsitarek May 8, 2024
76ed2e2
Database updates
Elisa-Visentin May 8, 2024
32f770a
added missing --mem line
jsitarek May 8, 2024
b24a287
Merge pull request #219 from cta-observatory/auto_MCP_clusters
jsitarek May 9, 2024
6adee2a
fixed search for lstchain (last) versions
Elisa-Visentin May 9, 2024
741dfd4
Merge branch 'Torino_auto_MCP' of https://github.com/cta-observatory/…
Elisa-Visentin May 9, 2024
e49b9a0
fix setup
Elisa-Visentin May 9, 2024
f0549b2
added simple error tracking and removed duplication of code
jsitarek May 9, 2024
6076d23
uncommented a forgotten line
jsitarek May 9, 2024
df69c17
bug fix
Elisa-Visentin May 10, 2024
4f99db6
bug + linter
Elisa-Visentin May 10, 2024
e04ded3
added a script for statistics of job completion and errors
jsitarek May 10, 2024
f119906
bug
Elisa-Visentin May 13, 2024
e826703
exit if no runs (MAGIC or LST)
Elisa-Visentin May 13, 2024
956ce3e
os.makedirs
Elisa-Visentin May 13, 2024
2063708
fix doc
Elisa-Visentin May 13, 2024
e7ff655
df_lst index
Elisa-Visentin May 13, 2024
6da6336
remove skip
Elisa-Visentin May 13, 2024
8999000
linter
Elisa-Visentin May 13, 2024
664a047
Merge remote-tracking branch 'origin/Torino_auto_MCP' into autoMCP_er…
jsitarek May 13, 2024
493662b
extensive refactoring for calib to DL1 processing for MAGIC data
jsitarek May 13, 2024
048a24f
try to remove duplicated code + minor fixes
Elisa-Visentin May 13, 2024
d9d1a23
clean up of the code for running over MCs
jsitarek May 13, 2024
c69cb3c
stereo events
Elisa-Visentin May 14, 2024
5cfb273
fixed paths for MC generation
jsitarek May 14, 2024
979a19d
added a check if the list of directories is empty with the list of av…
jsitarek May 14, 2024
abcb905
added an option to skip CPU and memory accounting
jsitarek May 14, 2024
a5fb481
Merge pull request #220 from cta-observatory/autoMCP_errors
jsitarek May 14, 2024
5ba5003
renamed parameters of slurm_lines
jsitarek May 14, 2024
97d6225
changes in the docstring
jsitarek May 14, 2024
a21a155
removed outdated note about gammapy 0.19
jsitarek May 14, 2024
cee1cef
refactoring of the code to avoid duplication of code for M1 and M2
jsitarek May 15, 2024
adae025
refactoring for the case of NSB_match set to true
jsitarek May 15, 2024
cec4833
refactoring to unify the code for NSB_match yes and no
jsitarek May 15, 2024
e3f8b9e
Fix bug sources
May 16, 2024
12bd08f
added error management for merging scripts
jsitarek May 16, 2024
c829703
added support for job_accounting running over merging files
jsitarek May 16, 2024
6917646
Fixed script + deleted useless file
Elisa-Visentin May 16, 2024
91c1e5f
Merge branch 'Torino_auto_MCP' of https://github.com/cta-observatory/…
Elisa-Visentin May 16, 2024
87423b3
minor fix
Elisa-Visentin May 16, 2024
2111e95
added counting of total CPU time
jsitarek May 16, 2024
584b632
Merge pull request #221 from cta-observatory/auto_MCP_errors_coin
jsitarek May 16, 2024
725fdb3
minor fix
Elisa-Visentin May 17, 2024
f5eb24f
Merge branch 'Torino_auto_MCP' of https://github.com/cta-observatory/…
Elisa-Visentin May 17, 2024
e9dfca0
Merge branch 'Torino_auto_MCP' into devoto_dev
Elisa-Visentin May 17, 2024
9f1389d
linter
Elisa-Visentin May 17, 2024
ae4b28a
Merge branch 'Torino_auto_MCP' into devoto_dev
Elisa-Visentin May 17, 2024
50407be
Bug
FedericoDevoto757 May 17, 2024
7116807
Merge branch 'devoto_dev' of https://github.com/cta-observatory/magic…
FedericoDevoto757 May 17, 2024
5e357de
Bug
FedericoDevoto757 May 17, 2024
21fbf4c
Bug fix
FedericoDevoto757 May 17, 2024
17ec0a8
Merge pull request #222 from cta-observatory/devoto_dev
jsitarek May 23, 2024
a31fb3f
introduced error logging for coincidence script
jsitarek May 23, 2024
ddfa1bc
removed forgotten print
jsitarek May 23, 2024
f52e024
error logging for stereo reconstruction script
jsitarek May 23, 2024
e082d28
Merge pull request #223 from cta-observatory/auto_MCP_coincidence
jsitarek May 23, 2024
d170ea9
changed name of output directory from DL1CoincidentStereo to DL1Stereo
jsitarek May 23, 2024
9cf549f
Merge branch 'Torino_auto_MCP' into auto_MCP_stereo
jsitarek May 23, 2024
e9e1ff5
Merge pull request #225 from cta-observatory/auto_MCP_stereo
jsitarek May 23, 2024
3519132
Merge branch 'auto_MCP_stereo' of github.com:cta-observatory/magic-ct…
jsitarek May 23, 2024
c1059e2
fixed nsb
Elisa-Visentin May 24, 2024
9c0561e
Update check_MAGIC_runs.py
joannaWojS May 24, 2024
b12ba94
cluster type
Elisa-Visentin May 27, 2024
5dfc839
fixed readme and lists
Elisa-Visentin May 27, 2024
250713a
merge DL1 stereo (draft)
Elisa-Visentin May 28, 2024
e5f0624
minor fixes
Elisa-Visentin May 28, 2024
acafa7e
MAGIC calib
Elisa-Visentin May 28, 2024
e0f8c50
Merge pull request #227 from cta-observatory/auto_MCP_stereo
aleberti May 28, 2024
14d6205
Merge branch 'master' into Torino_auto_MCP
Elisa-Visentin May 28, 2024
cde8a21
added list_cal.txt to the list of input files (since it is now used i…
jsitarek May 29, 2024
e503503
Merge pull request #230 from cta-observatory/auto_MCP_list_cal
jsitarek May 29, 2024
f0fb1c3
fix (check on source names)
Elisa-Visentin May 30, 2024
5781d57
Merge branch 'Torino_auto_MCP' of https://github.com/cta-observatory/…
Elisa-Visentin May 30, 2024
fb862b7
Update README.md
Elisa-Visentin May 31, 2024
0e2bce3
Update config_general.yaml
Elisa-Visentin May 31, 2024
97639c0
cluster type
Elisa-Visentin May 31, 2024
3506ce5
minor fixes
Elisa-Visentin May 31, 2024
ccc0e3a
fixed lstchain config
Elisa-Visentin May 31, 2024
4280c42
minor fixes
Elisa-Visentin May 31, 2024
0416d25
Updated docs
Elisa-Visentin Jun 4, 2024
76c6641
fix list
Elisa-Visentin Jun 4, 2024
8eced2d
fix config
Elisa-Visentin Jun 11, 2024
26125b6
auto-deleting of files
Elisa-Visentin Jun 11, 2024
b32151b
MC out of loop on sources (first step)
Elisa-Visentin Jun 11, 2024
390daf9
put config.yaml in config_general (+ default)
Elisa-Visentin Jun 12, 2024
03aacf8
create dir. MC only if MC processed
Elisa-Visentin Jun 12, 2024
832b671
Fix for different MC DL0 simtel output versions
Elisa-Visentin Jun 12, 2024
11e79ea
fix typo
Elisa-Visentin Jun 12, 2024
090cfbb
changes in job_accounting
jsitarek Jun 19, 2024
be85c17
slight refactoring to avoid multiply-broken lines
jsitarek Jun 20, 2024
b51ab18
Merge pull request #233 from cta-observatory/accounting_memory_selection
jsitarek Jun 20, 2024
ad33ed8
introduced updating of the database
jsitarek Jun 20, 2024
0cf29d7
Update check_MAGIC_runs.py
joannaWojS Jun 21, 2024
7d6c4c2
adding updating of the file database with rc also for coincidence and…
jsitarek Jun 24, 2024
5bf2ebf
slight refactoring
jsitarek Jun 24, 2024
02e0350
rename first script
Elisa-Visentin Jun 27, 2024
4f0471d
helium and electrons
Elisa-Visentin Jun 27, 2024
b9e2c92
linting
Elisa-Visentin Jun 27, 2024
460c747
Merge branch 'master' into Torino_auto_MCP
Elisa-Visentin Jun 27, 2024
6cacb1b
logging
Elisa-Visentin Jun 27, 2024
53bd30a
launch jobs
Elisa-Visentin Jun 27, 2024
4ba1fc4
minor fixes
Elisa-Visentin Jul 4, 2024
90ecc44
Update check_MAGIC_runs.py
joannaWojS Jul 9, 2024
6e2a1dc
Update check_MAGIC_runs.py
joannaWojS Jul 11, 2024
c1f3c77
MC merging out of source loop
Elisa-Visentin Jul 12, 2024
4707aa6
Update check_MAGIC_runs.py
joannaWojS Jul 12, 2024
4c2383b
config file for database paths
Elisa-Visentin Jul 16, 2024
685137a
add dates option for update
Elisa-Visentin Jul 17, 2024
e51cd41
fix list from h5 to new database formats
Elisa-Visentin Jul 17, 2024
ad61e3a
Update merge_stereo.py
Elisa-Visentin Jul 17, 2024
c2af643
Merge branch 'Torino_auto_MCP' into merge_stereo
Elisa-Visentin Jul 17, 2024
ec0ab01
bugs, imports, pre-commit
Elisa-Visentin Jul 17, 2024
75859eb
MC out of source
Elisa-Visentin Jul 17, 2024
28c061c
New version of the script with full documentation.
joannaWojS Jul 17, 2024
6ff221a
minor fixes
Elisa-Visentin Jul 18, 2024
d68ff70
Merge branch 'master' into Torino_auto_MCP
Elisa-Visentin Jul 18, 2024
c1d11c2
easier directory structure
Elisa-Visentin Jul 18, 2024
c06684a
CI fixes
Elisa-Visentin Jul 18, 2024
f7f22e9
Merge branch 'Torino_auto_MCP' into auto_MCP_script
Elisa-Visentin Jul 18, 2024
872f29d
Update environment.yml
Elisa-Visentin Jul 18, 2024
3b5e802
Merge branch 'Torino_auto_MCP' into merge_stereo
Elisa-Visentin Jul 18, 2024
e6cbfec
Merge pull request #218 from cta-observatory/auto_MCP_script
jsitarek Jul 18, 2024
8c801c0
Added new script for automatically updating the MAGIC database.
joannaWojS Jul 19, 2024
49c862c
The updated script script update_MAGIC_runs.py (lint fixes).
joannaWojS Jul 20, 2024
61489f0
The updated script script update_MAGIC_runs.py (lint fixes).
joannaWojS Jul 20, 2024
8aae607
fixed typo
Elisa-Visentin Jul 20, 2024
382bc3f
Merge branch 'Torino_auto_MCP' of https://github.com/cta-observatory/…
Elisa-Visentin Jul 20, 2024
6578cd6
The updated script script update_MAGIC_runs.py (lint fixes).
joannaWojS Jul 20, 2024
0c7f5cb
minor fixes to setup
Elisa-Visentin Jul 22, 2024
a14b64f
bug
Elisa-Visentin Jul 22, 2024
184a9d0
bug + minor fixes
Elisa-Visentin Jul 23, 2024
673c5ea
Merge branch 'Torino_auto_MCP' into merge_stereo
Elisa-Visentin Jul 25, 2024
67ab804
bug fixes
Elisa-Visentin Jul 25, 2024
a508c7f
bug & minor fixes db
Elisa-Visentin Jul 26, 2024
3eb3172
job accounting + minor bug fixes
Elisa-Visentin Jul 26, 2024
b7fd414
minor fixes
Elisa-Visentin Jul 29, 2024
b295c9e
doc
Elisa-Visentin Jul 29, 2024
f7b394e
Update update_MAGIC_database.py
joannaWojS Jul 29, 2024
b13deec
fixed wrong indent
jsitarek Jul 30, 2024
91f6524
Merge pull request #234 from cta-observatory/auto_MCP_update_db_errors
jsitarek Jul 30, 2024
6c4664d
removed unused lines (ra/dec)
Elisa-Visentin Jul 30, 2024
ea6c73e
removed comment
Elisa-Visentin Jul 30, 2024
846c2bb
stereo merging changes
Elisa-Visentin Jul 30, 2024
7edf5a4
removed run-> night MAGIC merge
Elisa-Visentin Jul 30, 2024
759fe98
new magic merging directories
Elisa-Visentin Jul 30, 2024
fd11d79
removed unused vars in sbatch
Elisa-Visentin Jul 30, 2024
5a2536a
Merge branch 'Torino_auto_MCP' into merge_stereo
jsitarek Jul 30, 2024
3a2c011
fixing formating
jsitarek Jul 30, 2024
db40f9d
fixing formating
jsitarek Jul 30, 2024
89afc54
Merge pull request #229 from cta-observatory/merge_stereo
jsitarek Jul 30, 2024
d2e2b81
fix bug
Elisa-Visentin Jul 31, 2024
7923381
Update merge_stereo.py
Elisa-Visentin Jul 31, 2024
93eb6a0
upgrade LST db w/ keeping error codes
Elisa-Visentin Aug 1, 2024
8b4e3b9
Merge branch 'Torino_auto_MCP' of https://github.com/cta-observatory/…
Elisa-Visentin Aug 1, 2024
5fbf284
remove merging MAGIC steps
Elisa-Visentin Aug 1, 2024
9c8bc93
fix bug
Elisa-Visentin Aug 2, 2024
f2cf8e7
fix glob
Elisa-Visentin Aug 2, 2024
cbfe1e1
doc
Elisa-Visentin Aug 2, 2024
058cbe2
doc and cleaning unused vars
Elisa-Visentin Aug 2, 2024
f294552
fix linter
Elisa-Visentin Aug 2, 2024
a6bfe65
In database_config.yaml, added the path to the common MAGIC+LST1 data…
joannaWojS Aug 2, 2024
2321e04
Changes made to update_MAGIC_database.py: The script can now be used …
joannaWojS Aug 2, 2024
9117f86
A few corrections in update_MAGIC_database.py
joannaWojS Aug 2, 2024
203ba68
A few corrections in update_MAGIC_database.py
joannaWojS Aug 2, 2024
1124882
A few corrections in update_MAGIC_database.py
joannaWojS Aug 2, 2024
e5119cb
Update README.md
jsitarek Aug 2, 2024
cb9d186
A few corrections in update_MAGIC_database.py
joannaWojS Aug 2, 2024
3c47546
remove auto rm MC
Elisa-Visentin Aug 5, 2024
8c58b94
memory coinc. 6 GB
Elisa-Visentin Aug 5, 2024
83512fe
rename config file
Elisa-Visentin Aug 5, 2024
1f6cbbc
lint
Elisa-Visentin Aug 5, 2024
b5b84de
updated readme
Elisa-Visentin Aug 5, 2024
19204ae
fix docstring
Elisa-Visentin Aug 5, 2024
d89f0d3
allow user input dates and use database config
Elisa-Visentin Aug 5, 2024
5fd2a4a
lint
Elisa-Visentin Aug 5, 2024
d61d158
started removal MC
Elisa-Visentin Aug 6, 2024
7cc74d5
Fix doc string
Elisa-Visentin Aug 6, 2024
5762f4b
Remove wrong comment
Elisa-Visentin Aug 6, 2024
02c4ca1
no MC
Elisa-Visentin Aug 6, 2024
0cd7b7a
remove MC
Elisa-Visentin Aug 7, 2024
4a0fbb0
Merge branch 'master' into Torino_auto_MCP
Elisa-Visentin Aug 7, 2024
e922a3a
fix order columns
Elisa-Visentin Aug 8, 2024
61ce4b9
Update nsb_to_h5.py
Elisa-Visentin Aug 8, 2024
52dc760
Merge branch 'master' into Torino_auto_MCP
aleberti Aug 8, 2024
08553e5
Merge branch 'master' into Torino_auto_MCP
aleberti Aug 8, 2024
02f0bb8
Merge branch 'Torino_auto_MCP' into auto_MCP_no_MC
Elisa-Visentin Aug 8, 2024
7368b27
skip broken subruns
Elisa-Visentin Aug 8, 2024
a55bab3
Merge pull request #240 from cta-observatory/auto_MCP_update_database
jsitarek Aug 8, 2024
5472c2b
minor fixes
Elisa-Visentin Aug 9, 2024
1a37e50
Merge branch 'Torino_auto_MCP' into nsb_broken_runs
Elisa-Visentin Aug 9, 2024
1b1eb42
Merge branch 'Torino_auto_MCP' into auto_MCP_no_MC
Elisa-Visentin Aug 9, 2024
26a63ef
minor fixes
Elisa-Visentin Aug 9, 2024
5865c00
Merge branch 'auto_MCP_no_MC' of https://github.com/cta-observatory/m…
Elisa-Visentin Aug 9, 2024
98795ea
init and setup fixes
Elisa-Visentin Aug 9, 2024
e37f162
fix db paths
Elisa-Visentin Aug 9, 2024
6606020
Merge pull request #246 from cta-observatory/auto_mcp_db_fix
jsitarek Aug 9, 2024
0f73322
Merge pull request #245 from cta-observatory/auto_mcp_console
jsitarek Aug 9, 2024
04e6d6f
remove MC
Elisa-Visentin Aug 9, 2024
51633b8
check number pedestal events
Elisa-Visentin Aug 9, 2024
66c0046
lint
Elisa-Visentin Aug 9, 2024
db5f63d
check on source out name
Elisa-Visentin Aug 9, 2024
99365d6
lint
Elisa-Visentin Aug 9, 2024
ba4af77
use tel id from config.yaml
Elisa-Visentin Aug 9, 2024
05a6d59
Merge branch 'Torino_auto_MCP' into auto_MCP_no_MC
Elisa-Visentin Aug 9, 2024
736718a
Merge pull request #247 from cta-observatory/fix-source
jsitarek Aug 9, 2024
20474b6
Update LSTnsb.py
Elisa-Visentin Aug 12, 2024
5fefaaa
Merge branch 'Torino_auto_MCP' into nsb_broken_runs
Elisa-Visentin Aug 12, 2024
0e6d98f
exit for loop in NSB limits
Elisa-Visentin Aug 12, 2024
bbbf112
minor fix config
Elisa-Visentin Aug 13, 2024
eb56569
Merge branch 'Torino_auto_MCP' into fix-telid
Elisa-Visentin Aug 13, 2024
c17a0eb
merge commit lint
Elisa-Visentin Aug 13, 2024
4dc4153
Merge branch 'Torino_auto_MCP' into auto_MCP_no_MC
Elisa-Visentin Aug 13, 2024
45fc5b5
Update dl1_production.py
Elisa-Visentin Aug 13, 2024
cc75273
Update merging_runs.py
Elisa-Visentin Aug 13, 2024
04c2470
Update dl1_production.py
Elisa-Visentin Aug 13, 2024
4acd21c
Update merging_runs.py
Elisa-Visentin Aug 13, 2024
40d483d
Merge pull request #244 from cta-observatory/nsb_broken_runs
jsitarek Aug 13, 2024
da9cc7b
revert config changes
Elisa-Visentin Aug 13, 2024
7f91349
fix config
Elisa-Visentin Aug 13, 2024
fccd950
swap lines
Elisa-Visentin Aug 13, 2024
71101c6
remove fixed TODO
Elisa-Visentin Aug 13, 2024
c3c0873
fix readme
Elisa-Visentin Aug 13, 2024
dc9a2bf
Merge branch 'Torino_auto_MCP' into auto_MCP_no_MC
Elisa-Visentin Aug 13, 2024
1f3e8dc
Merge branch 'Torino_auto_MCP' into fix-telid
Elisa-Visentin Aug 13, 2024
81482b8
Merge pull request #248 from cta-observatory/fix-telid
jsitarek Aug 13, 2024
598bc54
Merge branch 'Torino_auto_MCP' into auto_MCP_no_MC
Elisa-Visentin Aug 13, 2024
34cc7d7
fix merge problems
Elisa-Visentin Aug 13, 2024
827239c
fixed workspace path (and spaces in the config)
Elisa-Visentin Aug 13, 2024
0dc34e1
Merge pull request #243 from cta-observatory/auto_MCP_no_MC
jsitarek Aug 14, 2024
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
8 changes: 5 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,17 @@ At the moment of the release v0.4.2 of *magic-cta-pipe*, some LST-1 data are pro
Installation for users
----------------------

*magic-cta-pipe* and its dependencies may be installed using the *Anaconda* or *Miniconda* package system. We recommend creating a conda virtual environment
The very first step to reduce MAGIC-LST data is to have remote access/credentials to the IT Container. If you do not have it, please write an email to request it to <[email protected]>, and the admin will send you the instructions to connect to the IT container.

*magic-cta-pipe* and its dependencies may be installed using the *Anaconda* or *Miniconda* package system (if you have mamba installed, we recommend you to use it instead of conda, so that the installation process will be much faster; if you don't have anaconda/miniconda/miniforge, please install one of them into your workspace directory). We recommend creating a conda virtual environment
first, to isolate the installed version and dependencies from your master environment (this is optional).

The following command will set up a conda virtual environment, add the necessary package channels, and install *magic-cta-pipe* and its dependencies::

git clone https://github.com/cta-observatory/magic-cta-pipe.git
cd magic-cta-pipe
conda env create -n magic-lst1 -f environment.yml
conda activate magic-lst1
conda env create -n magic-lst -f environment.yml
conda activate magic-lst
pip install .

In general, *magic-cta-pipe* is still in heavy development phase, so expect large changes between different releases.
Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ dependencies:
- pyyaml
- scipy~=1.11.4
- scikit-learn=1.2
- setuptools
- setuptools<=71
- sphinx
- sphinx-automodapi
- sphinx-design
Expand Down
4 changes: 2 additions & 2 deletions magicctapipe/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,15 +411,15 @@ def config_monly():

@pytest.fixture(scope="session")
def config_gen():
config_path = resource_file("test_config_general.yaml")
config_path = resource_file("test_config_auto_MCP.yaml")
with open(config_path, "rb") as f:
config = yaml.safe_load(f)
return config


@pytest.fixture(scope="session")
def config_gen_4lst():
config_path = resource_file("test_config_general_4LST.yaml")
config_path = resource_file("test_config_auto_MCP_4LST.yaml")
with open(config_path, "rb") as f:
config = yaml.safe_load(f)
return config
Expand Down
12 changes: 12 additions & 0 deletions magicctapipe/resources/database_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
database_paths:
MAGIC+LST1: "/fefs/aswg/workspace/federico.dipierro/MAGIC_LST1_simultaneous_runs_info/simultaneous_obs_summary.h5"
MAGIC+LST1_bis: "/home/alessio.berti/MAGIC-LST_common/runfile/simultaneous_obs_summary.h5"
MAGIC: '/fefs/aswg/workspace/joanna.wojtowicz/data/Common_MAGIC_LST1_data_MAGIC_runs_subruns.h5'
LST: "/fefs/aswg/workspace/elisa.visentin/auto_MCP_PR/observations_LST.h5"

database_keys:
MAGIC+LST1: '/str/table'
MAGIC+LST1_bis: '/str'
MAGIC-I: "MAGIC1/runs_M1"
MAGIC-II: "MAGIC2/runs_M2"
LST: "joint_obs"
192 changes: 192 additions & 0 deletions magicctapipe/scripts/lst1_magic/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
# Scripts for MAGIC+LST analysis

This folder contains the scripts to perform MAGIC+LST analysis in a semi-automatic way.

Each script can be called from the command line from anywhere in your system. Please run them with `-h` option for the first time to check what are the options available.


## Overview


MAGIC+LST analysis starts from MAGIC calibrated data (\_Y\_ files), LST data level 1 (DL1) data and SimTelArray DL0 data, and our goal is to achieve data level 3 (DL3).

Behind the scenes, the semi-automatic scripts will run:
- `magic_calib_to_dl1` on real MAGIC data, to convert them into DL1 format.
jsitarek marked this conversation as resolved.
Show resolved Hide resolved
- `merge_hdf_files` on MAGIC data to merge subruns and/or runs together.
- `lst1_magic_event_coincidence` to find coincident events between MAGIC and LST-1, starting from DL1 data.
- `lst1_magic_stereo_reco` to add stereo parameters to the DL1 data.
- `lst1_magic_train_rfs` to train the RFs (energy, direction, classification) on train gamma MCs and protons.
- `lst1_magic_dl1_stereo_to_dl2` to apply the RFs to stereo DL1 data (real and test MCs) and produce DL2 data.
- `lst1_magic_create_irf` to create the IRF.
- `lst1_magic_dl2_to_dl3` to create DL3 files, and `create_dl3_index_files` to create DL3 HDU and index files.

From DL3 on, the analysis is done with gammapy.


## Analysis

During the analysis, some files (i.e., bash scripts, lists of sources and runs) are automatically produced by the scripts and are saved in your working directory. These files are necessary for the subsequent steps in the analysis chain. It is therefore mandatory to always launch the scripts from the same working directory so that the output files stored there can be correctly assigned as input files at the subsequent analysis steps.

### DL0 to DL1

In this step, we will convert the MAGIC Calibrated data to Data Level (DL) 1 (our goal is to reach DL3).

In your working IT Container directory (i.e., `workspace_dir`), open your environment with the command `conda activate {env_name}` and update the file `config_auto_MCP.yaml` according to your analysis. If you need non-standard parameters (e.g., for the cleaning), take care that the `resources/config.yaml` file gets installed when you install the pipeline, so you will have to copy it, e.g. in your workspace, modify it and put the path to this new file in the `config_auto_MCP.yaml` (this way you don't need to install again the pipeline).

The file `config_auto_MCP.yaml` must contain parameters for data selection and some information on the night sky background (NSB) level and software versions:

```

directories:
workspace_dir : "/fefs/aswg/workspace/elisa.visentin/auto_MCP_PR/" # Output directory where all the data products will be saved.


data_selection:
source_name_database: "CrabNebula" # MUST BE THE SAME AS IN THE DATABASE; Set to null to process all sources in the given time range.
source_name_output: 'Crabtest' # Name tag of your target. Used only if source_name_database != null.
time_range : True # Search for all runs in a LST time range (e.g., 2020_01_01 -> 2022_01_01).
min : "2023_11_17"
max : "2024_03_03"
date_list : ['2020_12_15','2021_03_11'] # LST list of days to be processed (only if time_range=False), format: YYYY_MM_DD.
skip_LST_runs: [3216,3217] # LST runs to ignore.
skip_MAGIC_runs: [5094658] # MAGIC runs to ignore.

general:
base_config_file: '' # path + name to a custom MCP config file. If not provided, the default config.yaml file will be used
LST_version : "v0.10" # check the `processed_lstchain_file` version in the LST database!
LST_tailcut : "tailcut84"
simtel_nsb : "/fefs/aswg/data/mc/DL0/LSTProd2/TestDataset/sim_telarray/node_theta_14.984_az_355.158_/output_v1.4/simtel_corsika_theta_14.984_az_355.158_run10.simtel.gz" # simtel file (DL0) to evaluate NSB
lstchain_modified_config : true # use_flatfield_heuristic = True to evaluate NSB
nsb : [0.5, 1.0, 1.5, 2.0, 2.5, 3.0]
env_name : magic-lst # name of the conda environment to be used to process data.
cluster : "SLURM" # cluster management system on which data are processed. At the moment we have only SLURM available, in the future maybe also condor (PIC, CNAF).


```

WARNING: Only the runs for which the `LST_version` parameter matches the `processed_lstchain_file` version in the LST database (i.e., the version used to evaluate the NSB level; generally the last available and processable version of a run) will be processed.

WARNING: `env_name` must be the same as the name of the environment in which you installed this version of the pipeline

Now that the configuration file is ready, let's create a list with all the MAGIC+LST1 runs for the time window (or list of nights) defined on the `config_auto_MCP.yaml` file:

> $ list_from_h5 -c config_auto_MCP.yaml

The output in the terminal should look like this:
```
Cleaning pre-existing *_LST_runs.txt and *_MAGIC_runs.txt files
Source: XXX
Finding LST runs...
Source: XXX
Finding MAGIC runs...
```
And it will save the files `{TARGET}_LST_runs.txt`, `{TARGET}_MAGIC_runs.txt`, and `list_sources.dat` (i.e., the list of all the sources found in the database according to both custom and default settings) in your current working directory. In case no runs are found for MAGIC and/or LST (for a source and a given time range/list of dates), a warning will be printed and no output text file will be produced for the given source and telescope(s).

At this point, we can convert the MAGIC data into DL1 format with the following command:
> $ dl1_production -c config_auto_MCP.yaml

The output in the terminal will be something like this:
```
*** Converting Calibrated into DL1 data ***
Process name: {source}
To check the jobs submitted to the cluster, type: squeue -n {source}
```

The command `dl1_production` does a series of things:

- Creates a directory with the target name within the directory `yourprojectname/{MCP_version}` and several subdirectories inside it that are necessary for the rest of the data reduction. The main directories are:
```
workspace_dir/VERSION/
workspace_dir/VERSION/{source}/DL1
workspace_dir/VERSION/{source}/DL1/[subdirectories]
```
where [subdirectories] stands for several subdirectories containing the MAGIC subruns in the DL1 format.
- Generates a configuration file called `config_DL0_to_DL1.yaml` with telescope ID information and adopted imaging/cleaning cuts, and puts it in the directory `[...]/yourprojectname/VERSION/{source}/` created in the previous step.
- Links the MAGIC data addresses to their respective subdirectories defined in the previous steps.
- Runs the script `magic_calib_to_dl1.py` for each one of the linked data files.


You can check if this process is done with the following commands:

> $ squeue -n {source}

or

> $ squeue -u your_user_name

Once it is done, all of the subdirectories in `workspace_dir/VERSION/{source}/DL1` will be filled with files of the type `dl1_MX.RunXXXXXX.0XX.h5` for each MAGIC subrun.

WARNING: some of these jobs could fail due to 'broken' input files: before moving to the next step, check for failed jobs (through `job_accounting` and/or log files) and remove the output files produced by these failed jobs (these output files will generally have a very small size, lower than few kB, and cannot be read in the following steps)

The next step of the conversion from calibrated to DL1 is to merge all the MAGIC data files such that in the end, we have only one datafile per night. To do so, we run the following command (always in the directory `yourprojectname`):

> $ merging_runs (-c config_auto_MCP.yaml)

The output in the terminal will be something like this:
```
***** Generating merge_MAGIC bashscripts...
***** Running merge_hdf_files.py in the MAGIC data files...
Process name: merging_{source}
To check the jobs submitted to the cluster, type: squeue -n merging_{source}
```

This script will merge MAGIC-I (and MAGIC-II) subruns into runs.

### Coincident events and stereo parameters on DL1

To find coincident events between MAGIC and LST, starting from DL1 data, we run the following command in the working directory:

> $ coincident_events (-c config_auto_MCP.yaml)

This script creates the file `config_coincidence.yaml` containing both the telescope IDs and the coincidence parameters listed in the general `config.yaml` file (the one in `magicctapipe/resources`).

Then, matches LST and MAGIC dates and links the LST data files to the output directory `[...]/DL1Coincident`; eventually, it runs the script `lst1_magic_event_coincidence.py` in all of them.

Once it is done, we add stereo parameters to the MAGIC+LST coincident DL1 files by running:

> $ stereo_events (-c config_auto_MCP.yaml)

This script creates the file `config_stereo.yaml` containing both the telescope IDs and the stereo parameters listed in the general `config.yaml` file (the one in `magicctapipe/resources`).

It then creates the output directories for the DL1 with stereo parameters `[...]/DL1Stereo`, and then runs the script `lst1_magic_stereo_reco.py` in all of the coincident DL1 files. The stereo DL1 files are then saved in these directories.

Eventually, to merge DL1 stereo (LST) subruns into runs, we run the `merge_stereo.py` script, whose output will be saved in `[...]/DL1Stereo/Merged`:

> $ merge_stereo (-c config_auto_MCP.yaml)

### Random forest and DL1 to DL2

TBD.

### Instrument response function and DL3

TBD.

## High-level analysis

Since the DL3 may have only a few MBs, it is typically convenient to download it to your own computer at this point. It will be necessary to have astropy and gammapy (version >= 0.20) installed before proceeding.

The folder [Notebooks](https://github.com/cta-observatory/magic-cta-pipe/tree/master/notebooks) contains Jupyter notebooks to perform checks on the IRF, to produce theta2 plots and SEDs.


## For mainteiners (MAGIC and LST databases)

To create and update the MAGIC and LST databases (from the one produced by AB and FDP) you should use the scripts in `database_production`

- `create_lst_table`: creates the LST database (1 row per LST run) by dropping some columns from the parent one (AB, FDP) and adding columns for NSB value (default: NaN), lstchain available versions, most recent lstchain version, processed file and NSB error codes (default: -1). It could also be used to update the given database, possibly selecting a given time range from the parent databases (by the -b and -e parameters, which stand for begin and end date of the range). Launched as `create_lst_table (-b YYYYMMDD -e YYYYMMDD)`

- `lstchain_version`: this scripts loop over all the rows of the database, estract date and run number from the table and look for the data stored on the IT (i.e., which version of lstchain has been used to process a run). It evaluates all the versions used to process a run and the most recent MCP-compatible one according to a hard-coded, ordered list. Launched as `lstchain_version`

- `nsb_level`: evaluates, for the last (MCP compatible) version of every LST run, the respective NSB value (i.e., the median over the NSB estimated by lstchain over a sub-set of sub-runs per run). This scripts launch a set of jobs (one per run; each job calls the `LSTnsb.py` script) and each jobs produces an output txt file containing a string like `date,run,NSB`; in the title of these files, both the run number and the NSB range are indicated (0.5=(0,0.75), 1.0=(0.75, 1.25),...., 2.5=(2.25,2.75), 3.0=(2.75,3.25), `high`=(3.25,Infinity) ). To limit the number of simultaneous jobs running on SLURM, the script requires that you provide a begin and a end date (-b and -e parameters) in the options. Launched as `nsb_level -c config_auto_MCP.yaml -b YYYY_MM_DD -e YYYY_MM_DD`

- `LSTnsb`: called by `nsb_level`, it gathers all the subruns for a run, evaluates the NSB for a subset of them (using the lstchain `calculate_noise_parameters` function), evaluates the median over these values and the approximate NSB level according to the list provided in `config_auto_MCP.yaml` (e.g., 0.5, 1.0, 1.5, ...., 2.5, 3.0, `high`) and then creates one txt file per run. These files contain the value of the NSB (i.e., the median over subruns) and are needed to fill the `nsb` column in the LST database. Launched as `LSTnsb (-c MCP_config) -i run -d date -l lstchain_config (-s N_subruns)`

- `nsb_to_h5`: this script reads the txt files created by `nsb_level` to know the NSB value for each run. This value is used to fill the `nsb` column of the LST database at the location of the respective run number. It also updates the error codes (0: NSB lower than 3.0, 1: NSB could not be evaluated, 2: NSB higher than 3.0). Launched as `nsb_to_h5`

- `update_magic_db`: this script updates (or creates, if it does not exist) the MAGIC database from a time range provided by the user (-m and -M parameters, which stand for minimum and maximum date). Not to accidentally destroy the current database, the updated database is saved as a new file instead of overwriting the current one. Launched as `update_magic_db -m YYYYMMDD -M YYYYMMDD`

- `job_accounting`: this script (in `semi_automatic_scripts` directory) allows to track progress of the submitted jobs, in particular listing errors. If you don-t use the `--no-accounting` option, it also provides basic resource statistics (CPU and memory) of the completed jobs. Finally, it can be also used to update the database files with the progress of data processing. Launched as `job_accounting (-c config) (-d data_level) (-v MCP_version) (--no-accounting) (-r h5_database)`

- `check_MAGIC_runs`: this script checks the MAGIC data stored on the IT (i.e., missing and existing data) in a given time range (-m and -M parameters, which stand for minimum and maximum date). Launched as `check_MAGIC_runs -m YYYYMMDD -M YYYYMMDD`


41 changes: 41 additions & 0 deletions magicctapipe/scripts/lst1_magic/semi_automatic_scripts/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from .check_MAGIC_runs import (
existing_files,
fix_lists_and_convert,
missing_files,
table_magic_runs,
)
from .clusters import rc_lines, slurm_lines
from .coincident_events import configfile_coincidence, linking_bash_lst
from .dl1_production import (
config_file_gen,
directories_generator_real,
lists_and_bash_gen_MAGIC,
)
from .job_accounting import run_shell
from .list_from_h5 import clear_files, list_run, magic_date, split_lst_date
from .merge_stereo import MergeStereo
from .merging_runs import merge
from .stereo_events import bash_stereo, configfile_stereo

__all__ = [
"bash_stereo",
"clear_files",
"configfile_coincidence",
"configfile_stereo",
"config_file_gen",
"directories_generator_real",
"existing_files",
"fix_lists_and_convert",
"linking_bash_lst",
"lists_and_bash_gen_MAGIC",
"list_run",
"magic_date",
"merge",
"MergeStereo",
"missing_files",
"rc_lines",
"run_shell",
"slurm_lines",
"split_lst_date",
"table_magic_runs",
]
Loading