Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Support user-defined filters #99

Open
HDembinski opened this issue Dec 15, 2022 · 0 comments
Open

Support user-defined filters #99

HDembinski opened this issue Dec 15, 2022 · 0 comments
Assignees
Labels
CLI Everything regarding the command-line interface

Comments

@HDembinski
Copy link
Collaborator

One of the main advantages of using Python in the CLI is that we can let the user write some Python code to filter the raw event produced by impy. We add a command line argument to the CLI, which points to user-defined a Python file which contains the filter code, which applies transformations on the EventData object.

impy --filter=my_filter.py ...

my_filter.py is a normal Python file. We expect that a function filter(event) is defined. It should accept the original event and return a modified event. Example:

# keep only long-lived particles
from impy.constants import long_lived

def filter(event):
     apid = np.abs(event.pid)
     ma = False
     for llpid in long_lived:
           ma |= apid == llpid
     return event[ma]  # or return None to discard the event completely

We can ship a couple of standard filters with the library, like we already do (filters like EventData.final_charged() etc. ... already exist), but it would be very useful to expose this generic functionality via the CLI.

@HDembinski HDembinski added the CLI Everything regarding the command-line interface label Dec 15, 2022
@HDembinski HDembinski self-assigned this Dec 15, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
CLI Everything regarding the command-line interface
Projects
None yet
Development

No branches or pull requests

1 participant