-
Notifications
You must be signed in to change notification settings - Fork 270
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
Create numba ufunc for sum of samples within charge extraction window #1038
Conversation
- Replace extract_charge_from_peakpos_array
Codecov Report
@@ Coverage Diff @@
## master #1038 +/- ##
========================================
Coverage ? 83.2%
========================================
Files ? 186
Lines ? 10583
Branches ? 0
========================================
Hits ? 8806
Misses ? 1777
Partials ? 0
Continue to review full report at Codecov.
|
* master: Set out-of-bounds pulse time to -1 Set to nan if out of range Rename UserWindowSum to FixedWindowSum
I have had a look over the code and have run some tests to compare these changes to the extraction methods in the current master branch. Everything seems good to me, in fact this pull request also fixes a current bug in the GlobalPeakWindowSum which causes it to fail if there is only one channel. I would suggest that the PR is approved. (One note, there is a typo in the sum_samples_around_peak description "The ret argument is required by numpy to creae the numpy array which is") |
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.
Other than a typo looks good
* master: Correct function name Create extract_pulse_time_around_peakpos Fix passing config the CameraCalibrator Correct test Add test to show error in creating CameraCalibrator with config Correct min to max Fix test Update bokeh plotters to handle nan # Conflicts: # ctapipe/image/extractor.py
…sum_numba * 'sum_numba' of https://github.com/watsonjj/ctapipe: Fixed typo
* master: Fix See Also docs for sphinx 2 (cta-observatory#1051)
* master: Create numba ufunc for sum of samples within charge extraction window (cta-observatory#1038) Implement nan-handling like matplotlib high-level api (cta-observatory#1050) Fix See Also docs for sphinx 2 (cta-observatory#1051) Correct function name Create extract_pulse_time_around_peakpos Correct min to max Fix test Update bokeh plotters to handle nan
This PR replaces the
extract_charge_from_peakpos_array
function withsum_samples_around_peakpos
. This is a numba function that more efficiently extracts the charge from the waveform within the window defined by the peak position, window width, and window size.It is defined using the
@guvectorize
decorator, which creates a numpy universal function, enabling the passing of both scalars and arrays for the peak position, window width, and window shift arguments.The way the
@guvectorize
works (in this case) is that you define the operation that is applied for each channel and pixel. The operation is then optimised using numba's just-in-time compilation.I have profiled
sum_samples_around_peakpos
against the previousextract_charge_from_peakpos_array
function. The new function provides a factor of 60 reduction in execution time (from a couple of ms, to tens of µs).It also provides a factor of 2 reduction in execution time upon the
waveforms[:, :, start:end].sum(2)
operation performed inGlobalPeakWindowSum
.The execution time for the extractors before this change were:
The execution time for the extractors following this change are:
The bottleneck is now the pulse_time calculation, which I could address in a different PR.