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 34 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
226 changes: 226 additions & 0 deletions magicctapipe/scripts/lst1_magic/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,226 @@
# 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.py` on MAGIC data to merge subruns and/or runs together.
- `lst1_magic_event_coincidence.py` to find coincident events between MAGIC and LST-1, starting from DL1 data.
- `lst1_magic_stereo_reco.py` to add stereo parameters to the DL1 data.
- `lst1_magic_train_rfs.py` to train the RFs (energy, direction, classification) on train gamma MCs and protons.
- `lst1_magic_dl1_stereo_to_dl2.py` to apply the RFs to stereo DL1 data (real and test MCs) and produce DL2 data.
- `lst1_magic_create_irf.py` to create the IRF.
- `lst1_magic_dl2_to_dl3.py` to create DL3 files, and `create_dl3_index_files.py` to create DL3 HDU and index files.

From DL3 on, the analysis is done with gammapy.

## Installation

1) The very first step to reduce MAGIC-LST data is to have remote access/credentials to the IT Container, so provide one. Once you have it, the connection steps are the following:

Authorized institute server (Client) → ssh connection to CTALaPalma → ssh connection to cp01/02.
jsitarek marked this conversation as resolved.
Show resolved Hide resolved

2) Once connected to the IT Container, install magic-cta-pipe (e.g. in your home directory in the IT Container) with the following commands (if you have mamba installed, we recommend you to use it instead of conda. The installation process will be much faster.):
jsitarek marked this conversation as resolved.
Show resolved Hide resolved

```
git clone -b Torino_auto_MCP https://github.com/cta-observatory/magic-cta-pipe.git
jsitarek marked this conversation as resolved.
Show resolved Hide resolved
cd magic-cta-pipe
conda env create -n magic-lst -f environment.yml
conda activate magic-lst
pip install .
```

## Analysis

During the analysis, some files are automatically produced by the scripts and are saved on your working directory. These files are necessary for the subsequent steps in the analysis chain. It is furthermore mandatory that you always launch the scripts from the same working directory since the output files stored there can be correctly read as input files at the subsequent analysis steps.
jsitarek marked this conversation as resolved.
Show resolved Hide resolved

### DL0 to DL1

In this step, we will convert the MAGIC and Monte Carlo (MC) Data Level (DL) 0 to DL1 (our goal is to reach DL3).

In your working IT Container directory (e.g. /fefs/aswg/workspace/yourname/yourprojectname), open the magic-lst environment with the command `conda activate magic-lst` and update the file `config_general.yaml` according to your analysis.

The file `config_general.yaml` must contain the telescope IDs and the directories with the MC data, as shown below, as well as the data selection and some information on the night sky background (NSB) level and software versions:

```
mc_tel_ids:
LST-1: 1
LST-2: 0
LST-3: 0
LST-4: 0
MAGIC-I: 2
MAGIC-II: 3

directories:
workspace_dir : "/fefs/aswg/workspace/yourname/yourprojectname/" # Output directory where all the data products will be saved.
# MC paths below are ignored if you set NSB_matching = true.
MC_gammas : "/fefs/aswg/data/mc/DL0/LSTProd2/TestDataset/sim_telarray" # set to "" if you don't want to process these Monte Carlo simulations.
jsitarek marked this conversation as resolved.
Show resolved Hide resolved
MC_electrons : ""
MC_helium : ""
MC_protons : "/fefs/aswg/data/mc/DL0/LSTProd2/TrainingDataset/Protons/dec_2276/sim_telarray"
MC_gammadiff : "/fefs/aswg/data/mc/DL0/LSTProd2/TrainingDataset/GammaDiffuse/dec_2276/sim_telarray/"

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.
target_RA_deg : 83.629 # RA in degrees; Please set it to null if source_name_database=null.
target_Dec_deg: 22.015 # Dec in degrees; Please set it to null 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:
SimTel_version: "v1.4"
LST_version : "v0.10"
LST_tailcut : "tailcut84"
focal_length : "effective"
proton_train_fraction : 0.8 # 0.8 means that 80% of the DL1 protons will be used for training the Random Forest.
nsb : [0.5, 1.0, 1.5, 2.0, 2.5, 3.0]
env_name : auto_MCP_PR # 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).
NSB_matching : true # Set to false to process also the MCs. Set to true if adequate MC productions (DLx) are already available on the IT Container.
NSB_MC : 0.5 # extra noise in dim pixels used to process MCs; e.g., you could put here the average NSB value of the processed LST runs. Ignored if NSB_matching=true.


```

Now that the configuration file is ready, lets create a list with all the MAGIC+LST1 runs for the chosen time window (or list of nights):

> $ list_from_h5 -c config_general.yaml

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

The output in the terminal will be something like this:
```
*** Converting DL0 into DL1 data ***
Process name: yourprojectname
To check the jobs submitted to the cluster, type: squeue -n yourprojectname
This process will take about 10 min to run if the IT cluster is free.
```

The command `setting_up_config_and_dir` does a series of things:
- Collects the txt files produced above into a single txt file per NSB bin (e.g., `LST_1.5_.txt`), whose content is a list of all the `date,runs` couples associated to this background value.
- According to the date of the selected MAGIC runs, each run is associated (actually, each day, but here it is done run-wise) to the corresponding MAGIC observation period ST_XXXX.
- Creates a directory with the target name within the directory `yourprojectname` and several subdirectories inside it that are necessary for the rest of the data reduction. The main directories are:
```
/fefs/aswg/workspace/yourname/yourprojectname/Crab/
/fefs/aswg/workspace/yourname/yourprojectname/Crab/VERSION/DL1
/fefs/aswg/workspace/yourname/yourprojectname/Crab/VERSION/DL1/ST{}
/fefs/aswg/workspace/yourname/yourprojectname/Crab/VERSION/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/Crab/` 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 yourprojectname_Crab

or

> $ squeue -u your_user_name

Once it is done, all of the subdirectories in `/fefs/aswg/workspace/yourname/yourprojectname/Crab/VERSION/DL1/` will be filled with files of the type `dl1_MX.RunXXXXXX.0XX.h5` for each MAGIC subrun. The next step of the conversion from DL0 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_general.yaml)

**The command inside parenthesis is not mandatory if you are running the command in the working directory**. By the way, it is better if you don't use it unless you know what you are doing.
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_Crab
To check the jobs submitted to the cluster, type: squeue -n merging_Crab
This process will take about 10 to 30 min to run.
```

This script will merge the MAGIC data files in the following order:
- MAGIC subruns are merged into single runs.
- MAGIC I and II runs are merged (only if both telescopes are used, of course).
- All runs in specific nights are merged, such that in the end we have only one datafile per night.

### 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_general.yaml)

This script creates the file config_coincidence.yaml containing the telescope IDs and the following parameters:
```
event_coincidence:
timestamp_type_lst: "dragon_time" # select "dragon_time", "tib_time" or "ucts_time"
pre_offset_search: true
n_pre_offset_search_events: 100
window_half_width: "300 ns"
time_offset:
start: "-10 us"
stop: "0 us
```

Then, for each NSB level, it reads the corresponding txt file generated by the second script and, taking into account the day (and, as a consequence the MAGIC period of the joint MAGIC runs) links the LST data files for these runs to the output directory [...]DL1Coincident/ST{}/NSB{}, and 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_general.yaml)

This script creates the file config_stereo.yaml with the following parameters:
```
stereo_reco:
quality_cuts: "(intensity > 50) & (width > 0)"
theta_uplim: "6 arcmin"
```

It then creates the output directories for the DL1 with stereo parameters [...]DL1CoincidentStereo/ST{}/NSB{}, 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.

### 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.

We prepared a [Jupyter Notebook](https://github.com/ranieremenezes/magic-cta-pipe/blob/master/magicctapipe/scripts/lst1_magic/SED_and_LC_from_DL3.ipynb) that quickly creates a counts map, a significance curve, an SED, and a light curve. You can give it a try.
jsitarek marked this conversation as resolved.
Show resolved Hide resolved

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. Note that the notebooks run with gammapy v0.20 or higher, while the gammapy version adopted in the MAGIC+LST-1 pipeline is v0.19.
jsitarek marked this conversation as resolved.
Show resolved Hide resolved


## For mainteiners (creation of MAGIC adn 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 (NaN by default), lstchain version (one column per version, False by default) and error codes (NaN by default). Launched as `python create_lst_table.py`

- `nsb_level`: evaluates, for every LST run, the respective NSB value (i.e., the median over the NSB estimated by lstchain over approx. 25 sub-runs per run). This scripts launch a set of jobs (one per run; each job calls the `LSTnsb` 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, you should always provide a begin and a end date (format YYYY_MM_DD) in the options. Launched as `python nsb_level.py -c config_general.yaml -b begin_date -e end_date`

- `LSTnsb`: called by `nsb_level`, it gathers all the subruns for a run, evaluates the NSB for approx. 25 of them (using the lstchain `calculate_noise_parameters` function), evaluates the median over these values and the approximate NSB level (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 database `nsb` column

- `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 database at the location of the respective run number. It also put '000' as an error code in case the NSB is NaN (i.e., not evaluated for the LST run), '001' in case NSB>3.0 (too high NSB to be processed with a standard analysis!). Launched as `python nsb_to_h5.py`

- `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 saved in the IT (i.e., which version of lstchain has been used to process a run). For each run, it sets to True the lstchain_0.9(0.10) cell if this run has been processed up to DL1 with lstchain 0.9(0.10). It sets error code '002' in case none of the two versions has been used to process the run. Launched as `python lstchain_version.py`

Error codes:

- 000: no NSB

- 001: NSB>3.0

- 002: neither 0.9 nor 0.10 lstchain version
29 changes: 29 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,29 @@
from .coincident_events import configfile_coincidence, linking_bash_lst
from .database_production.LSTnsb import nsb
from .merging_runs import cleaning, merge, mergeMC, split_train_test
from .database_production.nsb_level import bash_scripts
from .setting_up_config_and_dir import (
config_file_gen,
directories_generator,
lists_and_bash_gen_MAGIC,
lists_and_bash_generator,
)
from .stereo_events import bash_stereo, bash_stereoMC, configfile_stereo

__all__ = [
"nsb",
"cleaning",
"split_train_test",
"merge",
"mergeMC",
"bash_scripts",
"config_file_gen",
"lists_and_bash_generator",
"lists_and_bash_gen_MAGIC",
"directories_generator",
"configfile_coincidence",
"linking_bash_lst",
"configfile_stereo",
"bash_stereo",
"bash_stereoMC",
]
Loading
Loading