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

introducing union support in ObservationFilter #4616

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

MRegeard
Copy link
Member

This pull request introduce "union" filtering in ObservationFilter, as mentioned in #4511.

First of all, I introduce a new input parameter to the class, event_filter_method, which can take either the value 'intersect'or 'union'. By default it is set to 'intersect' to stick to the former behaviour.

Then I modified the filter_events method to be able to do "union filtering". For that, I take the event filtered by each filter one by one, vstacktheir table, sort the table by 'TIME', apply unique to table and then put this in a new EventList which is retuned.

I also modified the _check_filter_phase (that check for "phase filter" and apply the livetime correction if needed) so that it can support multiple filtering.

Finally, I also added a staticmethod _check_overlap_phase, which check if there are overlap in the define bandof "phase filter". This is mandatory to avoid having livetime that are not corresponding to the really fraction of livetime that is kept.

Signed-off-by: Maxime Regeard <regeard@apc.in2p3.fr>
Signed-off-by: Maxime Regeard <regeard@apc.in2p3.fr>
Signed-off-by: Maxime Regeard <regeard@apc.in2p3.fr>
Signed-off-by: Maxime Regeard <regeard@apc.in2p3.fr>
Signed-off-by: Maxime Regeard <regeard@apc.in2p3.fr>
@@ -23,8 +26,10 @@ class ObservationFilter:
class that corresponds to the filter type
(see `~gammapy.data.ObservationFilter.EVENT_FILTER_TYPES`)

The filtered event list will be an intersection of all filters. A union
of filters is not supported yet.
event_filter_method: str
Copy link
Member

Choose a reason for hiding this comment

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

Should we add an example with this argument in the docstring exemple?

@@ -102,6 +102,13 @@ def test_filter_gti(observation):
"p_in": [],
"p_out": 1,
},
{
"p_in": [
Copy link
Member

Choose a reason for hiding this comment

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

Should we add other test with an union and an intersection?

@bkhelifi bkhelifi added this to the 1.2 milestone Jul 5, 2023
@MRegeard MRegeard marked this pull request as draft July 21, 2023 14:23
@bkhelifi bkhelifi requested a review from QRemy September 15, 2023 09:52
@bkhelifi bkhelifi added this to To do in gammapy.data via automation Sep 15, 2023
@registerrier
Copy link
Contributor

What is the status here @MRegeard ?
Is the event filtering working with GTIs that have holes?

@registerrier registerrier modified the milestones: 1.2, 1.3 Jan 31, 2024
@MRegeard
Copy link
Member Author

MRegeard commented Jan 31, 2024

@registerrier, I think that the logic that I introduce here is not satisfactory. That's why I didn't went further.
I need to think about it again.
For the GTI, I'm not sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
gammapy.data
  
To do
Development

Successfully merging this pull request may close these issues.

None yet

3 participants