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

Quality query falling back to default for ctapipe-optimize-event-selection #2699

Open
BastienLacave opened this issue Feb 13, 2025 · 1 comment

Comments

@BastienLacave
Copy link

BastienLacave commented Feb 13, 2025

when running ctapipe-optimize-event-selection I have the following error:

2025-02-13 09:33:06,171 ERROR [ctapipe.ctapipe-optimize-event-selection] (tool.run): Caught unexpected exception: Error evaluating expression '('multiplicity 4', 'np.count_nonzero(HillasReconstructor_telescopes,axis=1) >= 4')': name 'HillasReconstructor_telescopes' is not defined Traceback (most recent call last): File "/home/blacave/CTLearn/Software/ctapipe/src/ctapipe/core/tool.py", line 439, in run self.start() File "/home/blacave/CTLearn/Software/ctapipe/src/ctapipe/tools/optimize_event_selection.py", line 150, in start events, count, meta = loader.load_preselected_events( File "/home/blacave/CTLearn/Software/ctapipe/src/ctapipe/irf/preprocessing.py", line 227, in load_preselected_events selected = events[self.epp.quality_query.get_table_mask(events)] File "/home/blacave/CTLearn/Software/ctapipe/src/ctapipe/core/qualityquery.py", line 138, in get_table_mask for i, res in enumerate(self.engine(table), start=1): File "/home/blacave/CTLearn/Software/ctapipe/src/ctapipe/core/expression_engine.py", line 44, in __call__ raise ExpressionError( ctapipe.core.expression_engine.ExpressionError: Error evaluating expression '('multiplicity 4', 'np.count_nonzero(HillasReconstructor_telescopes,axis=1) >= 4')': name 'HillasReconstructor_telescopes' is not defined

But in my config I specify

EventPreProcessor:
  energy_reconstructor: "CTLearn"
  gammaness_classifier: "CTLearn"
  geometry_reconstructor: "CTLearn"
  quality_criteria:
    - ["multiplicity", "np.count_nonzero(CTLearn_telescopes,axis=1) == 2"]
    - ["valid classifier", "CTLearn_is_valid"]
    - ["valid geom reco", "CTLearn_is_valid"]
    - ["valid energy reco", "CTLearn_is_valid"]`

public-conf.txt

@Hckjs
Copy link
Contributor

Hckjs commented Feb 17, 2025

Hey Bastien,
I think you need to set the quality_criteria trait of the EventQualityQuery Component to make the config system work because its not a direct trait of the EventPreprocessor Component, e.g.:

EventPreprocessor: 
    energy_reconstructor: "CTLearn" 
    gammaness_classifier: "CTLearn" 
    geometry_reconstructor: "CTLearn"

    EventQualityQuery:
        quality_criteria: 
            - ["multiplicity", "np.count_nonzero(CTLearn_telescopes,axis=1) == 2"] 
            - ["valid classifier", "CTLearn_is_valid"]
            - ["valid geom reco", "CTLearn_is_valid"] 
            - ["valid energy reco", "CTLearn_is_valid"]

Just like this example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants