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

Flat field #161

Draft
wants to merge 20 commits into
base: main
Choose a base branch
from
Draft

Flat field #161

wants to merge 20 commits into from

Conversation

ArmelleJB
Copy link

Add component, container and tool for calculation of flat field coefficients.

Copy link
Collaborator

@jlenain jlenain left a comment

Choose a reason for hiding this comment

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

Hi @ArmelleJB !
Many thanks for this PR. I'll mark it as draft for the time being, as I understand it is not yet complete.
At some point, in your user script, could you provide an example on how to launch a flatfield computation please ?
Could you also please run pre-commit hooks and commit the linted code ?

@jlenain jlenain marked this pull request as draft November 29, 2024 14:04
@jlenain
Copy link
Collaborator

jlenain commented Jan 16, 2025

Hi!

The PR #163 has been merged, which results in a couple of small conflicts in this one that I'll try to resolve.

@jlenain
Copy link
Collaborator

jlenain commented Jan 16, 2025

Note that I had to rebase this branch from main, but a good point is that the CI/Lint job now passes !

Copy link

codecov bot commented Jan 16, 2025

Codecov Report

Attention: Patch coverage is 53.53535% with 46 lines in your changes missing coverage. Please review.

Project coverage is 63.03%. Comparing base (b306f30) to head (a0a1eeb).
Report is 40 commits behind head on main.

Files with missing lines Patch % Lines
...archain/makers/component/preflatfield_component.py 36.36% 42 Missing ⚠️
...nectarchain/makers/calibration/flatfield_makers.py 69.23% 4 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main     #161       +/-   ##
===========================================
+ Coverage   40.76%   63.03%   +22.26%     
===========================================
  Files          65       66        +1     
  Lines        4452     4829      +377     
===========================================
+ Hits         1815     3044     +1229     
+ Misses       2637     1785      -852     

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

wfs_pedsub = self.subtract_pedestal(wfs, 20)

# get the masked array for integration window
t_peak = np.argmax(wfs_pedsub, axis=3)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just a naive question here: if I am correct, you are manually computing the charge here as what the GlobalPeakWindowSum from ctapipe would do (or LocalPeakWindowSum ?). Why wouldn't we use the ctapipe implementation here? Or maybe I am missing something.

Copy link
Author

Choose a reason for hiding this comment

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

No you're right, of course we can use that - it's a left over from my original code, I didn't think about what is already implemented in ctapipe.

Copy link
Collaborator

Choose a reason for hiding this comment

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

No worry at all! Actually, I am never clear whether we should use a global or local charge integrator for the flat field estimation.

To be checked, but it may even be that the ctapipe charge extractors have a correction option when the pulses are on the edges of the time window, as we discussed the last couple of days.


# get integrated amplitude and mean amplitude over all pixels per event
amp_int_per_pix_per_event = np.sum(
wfs_pedsub[0], axis=2, where=masked_wfs.astype("bool")
Copy link
Collaborator

@jlenain jlenain Jan 17, 2025

Choose a reason for hiding this comment

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

I guess "0" here refers to the high gain channel, is that right ? In such a case, it would be better to use ctapipe_io_nectarcam.constants.HIGH_GAIN instead, in order to avoid hardcoding stuff.

Copy link
Author

Choose a reason for hiding this comment

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

Yes ! True, thanks.

Copy link
Author

@ArmelleJB ArmelleJB Jan 17, 2025

Choose a reason for hiding this comment

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

Ah, actually no, this zero was calling the first event (and there is always only one event in wfs and wfs_pedsum) - I fixed that.

amp_int_per_pix_per_event = np.sum(
wfs_pedsub[0], axis=2, where=masked_wfs.astype("bool")
)
amp_int_per_pix_per_event = np.sum(wfs_pedsub, axis=-1, where=masked_wfs)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not keeping where=masked_wfs.astype("bool") here, to ensure masked_wfs is a boolean array ?

Copy link
Author

Choose a reason for hiding this comment

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

Yes we can ! I removed it because I now define the mask array as boolean, but it doesn't hurt to keep it here.

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

Successfully merging this pull request may close these issues.

4 participants