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
CutPlugin class for cuts in straxen #274
Conversation
The cuts currently in straxen (https://github.com/XENONnT/straxen/blob/master/straxen/plugins/x1t_cuts.py ) have a quite lot of overlap with one another. Most of the time a simple Boolean array is all that is returned. However, we each time have to add the time fields et cetera which may somewhat obscure the functionality. To simplify the cuts somewhat I've written a simple Plugin Class. In straxen it could be used as for example: ``` class CutS1s(CutPlugin): depends_on = ('events', 'corrected_areas') provides = 'cs1_cut' cut_description = "Remove cS1 above 100 PE" cut_name ='cut_high_cs1' __version__ = '0.0.0' def cut_by(self, events): return events['cs1'] > 100 ``` ``` class CutS2s(CutPlugin): depends_on = ('events', 'corrected_areas') cut_description = "Remove cS2s below 100 PE" def cut_by(self, events): return events['cs2'] < 100 ```
Hej Joran, nice Idea. I have not checked your code yet, but one quick question. In your current version cuts would be the same data_kind as events would not they be? Maybe it is better to have a new "cut"-data_kind instead? |
Hi Daniel, |
As @WenzDaniel just correctly pointed out the endtime needs to be computed when we are working with lower level plugins. Although it's not really the envisaged application it's easy enough to implement. See now for example:
|
In 752f521 I've added a test mainly since I think I should learn how how to write tests. Also it's completely fine to add more tests. If someone foresees a good metric to add to this test, please let me know. |
@ ACs this is ready for merge |
tests/test_cut_plugin.py
Outdated
targets=strax.camel_to_snake(CutSomething.__name__)) | ||
correct_answer = np.sum(input_peaks[_dtype_name] > cut_threshold) | ||
assert len(result) == len(input_peaks), "WTF??" | ||
assert correct_answer == np.sum(result['cut_something']), "Cut plugin does not give boolean arrays correctly" |
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.
Maybe just add one additional test checking the endtime since we had these issues in peaks and you are computing some new endtimes here. Does not hurt much to have this little check. All the rest looks fine.
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.
Thanks, this is done in 3673c28 !
The cuts currently in straxen (https://github.com/XENONnT/straxen/blob/master/straxen/plugins/x1t_cuts.py ) have a quite lot of overlap with one another. Most of the time a simple Boolean array is all that is returned. However, we each time have to add the time fields et cetera which may somewhat obscure the functionality.
To simplify the cuts somewhat I've written a simple Plugin Class. In straxen it could be used as for example: