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

Change ImageCleaner API #2511

Merged
merged 10 commits into from Mar 22, 2024
Merged

Change ImageCleaner API #2511

merged 10 commits into from Mar 22, 2024

Conversation

Hckjs
Copy link
Contributor

@Hckjs Hckjs commented Feb 16, 2024

Change API of ImageCleaner to be __call__(self, tel_id: int, event: ArrayEventContainer). Closes #2015.

@aleberti

Copy link

codecov bot commented Feb 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.53%. Comparing base (3952e5a) to head (8a05e27).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2511   +/-   ##
=======================================
  Coverage   92.53%   92.53%           
=======================================
  Files         235      235           
  Lines       20063    20064    +1     
=======================================
+ Hits        18565    18566    +1     
  Misses       1498     1498           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Hckjs Hckjs requested review from maxnoe and kosack February 16, 2024 13:00
Copy link
Contributor

@kosack kosack left a comment

Choose a reason for hiding this comment

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

Can you explain why TailCutsDataVolumeReducer was changed as well here? This change seems to remove the ability to change which image cleaner implementation is used inside it, but that is not mentioned at all in the changelog, and seems to be outside of the scope of the PR (aside from the fact that that DataVolumeReducer is confusingly named and should be ImageCleaningDataVolumeReducer or similar, as it is not tail-cuts specific)

@maxnoe
Copy link
Member

maxnoe commented Feb 16, 2024

This change seems to remove the ability to change which image cleaner implementation is used inside it,

Why would something called TailCutsImageCleaner allow to use a different cleaning method than TailCuts?

@kosack
Copy link
Contributor

kosack commented Feb 16, 2024

Why would something called TailCutsImageCleaner allow to use a different cleaning method than TailCuts?

I agree and mentioned that in the request, but that reducer was configurable, presumably for a reason. I suspect more that it was just misnamed, rather than that it should be restricted to one type of cleaning. All it does is iteratively clean and dilate, which should work for any cleaning implementation.

Nevertheless, that should be a different PR if you want to change how it works, and the ACADA people should be involved.

@maxnoe
Copy link
Member

maxnoe commented Feb 16, 2024

Ok...

I think we discussed this already elsewhere: keep the old signature in a method like: clean_low_level (please invent a better name), and have __call__ use that internally.

Then the TailCutsImageReducer (and the TwoStepExtractor) can call the low-level API with minimal changes to them.

@Hckjs
Copy link
Contributor Author

Hckjs commented Feb 19, 2024

Thanks for the comments!
Adapting it now to have a __call__(self, tel_id: int, event: ArrayEventContainer) which internally uses the abstract clean_image(self, tel_id, image, arrival_times) method defined in each ImageCleaner-subclass.

The TwoStepExtractor is already using the low level tailcuts_clean method.

I'll create another PR for renaming the TailCutsDataVolumeReducer.

@maxnoe
Copy link
Member

maxnoe commented Feb 19, 2024

Maybe a better change would be to for now just add the event as new optional parameter?

def __call__(self, tel_id, image, peak_time=None, *, event=None):

That is

a) backwards compatible
b) allows to clean other images than what is in event.dl1.tel[tel_id].image / event.dl1.tel[tel_id].peak_time
c) still allows accessing additional information from the event

@Hckjs Hckjs requested review from kosack and maxnoe March 12, 2024 16:29
@maxnoe
Copy link
Member

maxnoe commented Mar 21, 2024

Just to summarize from the discussions that are now in collapsed threads: we decided to not pass the full event, but just the CameraMonitoringContainer, which should have all information necessary for advanced cleaning algorithms.

@maxnoe maxnoe merged commit c6e1953 into main Mar 22, 2024
15 checks passed
@maxnoe maxnoe deleted the image_cleaner_api branch March 22, 2024 11:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change API of ImageCleaner to be __call__(self, event: ArrayEvent)
4 participants