-
Notifications
You must be signed in to change notification settings - Fork 272
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
fwhm, rise/fall time #2151
base: main
Are you sure you want to change the base?
fwhm, rise/fall time #2151
Conversation
Alternatively to this implementation for fwhm, one could do the same as for time over threshold with a slightly worst result but quicker and maybe interpolate before. |
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #2151 +/- ##
==========================================
- Coverage 92.55% 92.32% -0.23%
==========================================
Files 234 234
Lines 20006 20073 +67
==========================================
+ Hits 18516 18532 +16
- Misses 1490 1541 +51 ☔ View full report in Codecov by Sentry. |
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.
Looks fine. In a future PR, we can add it perhaps as an optional output of the ImageExtractors, so if enabled, you get images of t_rise, t_fall, and t_over_threshold.
Do you know why some tests, unrelated to the implementation, are failing? |
Yes, it's due to a change in scikit learn that causes a problem with astropy. @maxnoe opened a PR to fix it, so shortly you should be able to just merge or rebase the main branch and your tests should pass again. #2496 Feel free to review it! We need a second reviewer to commit (and it's a minimal change)... |
nopython=True, | ||
cache=True, | ||
) | ||
def time_parameters(waveform, fwhm_arr, rise_time_arr, fall_time_arr): |
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.
I think this new method is missing in __all__
at the top.
|
||
""" | ||
peak_index = np.argmax(waveform) | ||
amplitude = np.max(waveform) |
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.
This is wasteful, you don't need to find the maximum again, just do amplitude = waveform[peak_index]
rt_10 = ti - (ampl_10percent - yi) / (yj - yi) | ||
|
||
fwhm = 0.0 | ||
if None not in (fwhm_right, fwhm_left): |
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.
You initialize these two with np.nan
above, so None
will never be in (fwhm_right, fwhm_left)
.
I think you can just subtract the two anyways, and the result will be nan if either is nan. Check if there is a warning and maybe silence it in case we don't want to have a warning like "invalid valid encountered in subtract".
fwhm = fwhm_right - fwhm_left | ||
|
||
rise_time = 0.0 | ||
if None not in (rt_90, rt_10): |
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.
Same as above with the other if
rise_time = rt_90 - rt_10 | ||
|
||
fall_time = 0.0 | ||
if None not in (ft_90, ft_10): |
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.
Same as above with the other if
fall_time_arr[0] = fall_time | ||
|
||
|
||
def time_over_threshold(waveforms, thr): |
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.
Technically, this is "samples above threshold", for "time over threshold you would have to divide by the sampling frequency.
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.
See inline comments
No description provided.