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
base: main
Are you sure you want to change the base?
Conversation
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>
415990f
to
255da27
Compare
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 |
There was a problem hiding this comment.
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": [ |
There was a problem hiding this comment.
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?
What is the status here @MRegeard ? |
@registerrier, I think that the logic that I introduce here is not satisfactory. That's why I didn't went further. |
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,vstack
their table, sort the table by'TIME'
, applyunique
to table and then put this in a newEventList
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 defineband
of "phase filter". This is mandatory to avoid having livetime that are not corresponding to the really fraction of livetime that is kept.