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

Last updated scripts (4-LSTs): Torino group #180

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from
Draft

Conversation

Elisa-Visentin
Copy link
Collaborator

Here the last updated analysis steps (RFs, DL2, DL3): new RF implementation (one per telescope instead of one per telescope per combination).
Again a huge PR, and it would be great if we could merge it before the LST school (to remove hardcoded variables and duplicated functions due to the new-old glueing at the DL1-stereo level).
The Doc strings must still be fixed a bit (to pass the tests), but you can already take a look into it.
Thanks

@aleberti
Copy link
Collaborator

aleberti commented Dec 5, 2023

Hi, many changes are in the documentation of the functions, but most of them, they should not have been changed. I.e. the spaces removed between the name of the parameter and the colon. I think you have some setting in your editor which is removing them automatically, but that makes the lint and docs checks fail.

Copy link

codecov bot commented Dec 5, 2023

Codecov Report

Attention: 7 lines in your changes are missing coverage. Please review.

Comparison is base (9b8776e) 76.17% compared to head (e5d8a1a) 75.36%.
Report is 82 commits behind head on master.

Files Patch % Lines
magicctapipe/io/io.py 85.41% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #180      +/-   ##
==========================================
- Coverage   76.17%   75.36%   -0.82%     
==========================================
  Files          21       21              
  Lines        2493     2419      -74     
==========================================
- Hits         1899     1823      -76     
- Misses        594      596       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Elisa-Visentin
Copy link
Collaborator Author

Elisa-Visentin commented Dec 5, 2023 via email

@Elisa-Visentin
Copy link
Collaborator Author

Fixed :)

@Elisa-Visentin Elisa-Visentin marked this pull request as ready for review December 6, 2023 07:25
@aleberti
Copy link
Collaborator

aleberti commented Dec 8, 2023

I do not have any major comment. @jsitarek can you also have a look? it should be fast anyway.

Copy link
Collaborator

@jsitarek jsitarek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a few comment/questions

magicctapipe/io/io.py Outdated Show resolved Hide resolved

logger.info(f"\nExtracting the events of the '{event_type}' type...")

if event_type == "software":
# The events of the MAGIC-stereo combination are excluded
df_events.query("(combo_type > 0) & (magic_stereo == True)", inplace=True)
df_events.query(
f"(combo_type < {combo_types[-1]}) & (magic_stereo == True)", inplace=True
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

taking into account the other problem that we had with the combo_type it might be safer to access this combination by name "M1_M2"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

elif event_type == "software_only_3tel":
df_events.query("combo_type == 3", inplace=True)
elif event_type == "software_6_tel":
df_events.query(f"combo_type < {combo_types[-1]}", inplace=True)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


elif event_type == "magic_only":
df_events.query("combo_type == 0", inplace=True)
df_events.query(f"combo_type == {combo_types[-1]}", inplace=True)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -1032,24 +876,36 @@ def load_dl2_data_file(input_file, quality_cuts, event_type, weight_type_dl2):
If the input event type is not known
"""

TEL_NAMES, TEL_COMBINATIONS = telescope_combinations(config)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the same 6 lines are also in load_mc_dl2_data_file
better to extract them in a separate function to make sure that the same code is used for data and MCs

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the only difference is that in real data we do not ask for magic_stereo == True in the 'software' because standard MAGIC + LST-1 data are always collected with MAGIC stereo trigger, but we can take this into account easily

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

magicctapipe/io/io.py Outdated Show resolved Hide resolved

elif event_type == "magic_only":
event_data.query("combo_type == 0", inplace=True)
event_data.query(f"combo_type == {combo_types[-1]}", inplace=True)

elif event_type == "hardware":
logger.warning(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hardware trigger is already implemented in ctapipe_io_magic

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

for the events of the any 2-tel combinations except the MAGIC-stereo
combination at the moment. The "software_only_3tel" type allows for only
the events of the 3-tel combination. The "magic_only" type allows for
The "software_3tels_or_more" type stands for the software event
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we modify the types following my earlier comment they need to be updated here as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

combo_type = list(TEL_COMBINATIONS.values()).index(tel_ids)
df_events = event_data.query(f"combo_type == {combo_type}")
# Extract the events with the same telescope ID
df_events = event_data.query(f"tel_id == {tel_ids[0]}")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not understand why do you always take the first tel_id here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the tel_ids list (i.e., the dictionary in 'estimator') only contains one element (we create one RF file per telescope and this 'list' will contain the ID of the telescope corresponding to the used RF file). So we take always the first because ti is the only tel_id

@aleberti aleberti linked an issue Jan 19, 2024 that may be closed by this pull request
@aleberti aleberti added enhancement New feature or request new functionality For new functionalities optimization For code optimization labels Jan 19, 2024
@Elisa-Visentin
Copy link
Collaborator Author

Due to the large number of conflict with the master (and the 'timescale' of the commits both here and in the master, which will probably cause a mess if we try to merge them), I will open a new branch from the current master (ctapipe 0.19) to implement 'manually' the changes in the RFs; we can then merge this new branch. This PR will be kept open as a draft to allow us to solve the open conversations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request new functionality For new functionalities optimization For code optimization
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants