trichter / rf

Receiver function calculation in seismology
MIT License
106 stars 62 forks source link

_find_nearest raises exception when passed empty array #8

Closed amedlin closed 5 years ago

amedlin commented 5 years ago

https://github.com/trichter/rf/blob/2e2589b186fc07db09a11022b2cbebfbb5522122/rf/deconvolve.py#L23

If the array is empty, the function should simply return 0. Instead, after np.searchsorted returns 0, if tries to index into the empty array.

trichter commented 5 years ago

Hi, in my opinion, if the array is empty, it does not make sense to return any index, so I think it is OK that the function errors. I also see, that there can be an error if value > max(array), but both are edge cases with defective data which will not lead to a reasonable deconvolution/receiver function.

trichter commented 5 years ago

@amedlin Can I close this issue? What was your setting that the error got triggered?

amedlin commented 5 years ago

Actually I think I agree with your opinion on this function. In my situation an empty array was throwing the error. Now I'm avoiding the situation by better filtering of my input data.