Skip to content
Snippets Groups Projects
Commit 4145f759 authored by Jean-Baptiste Bayle's avatar Jean-Baptiste Bayle
Browse files

Fix a bug in `timeshift` when shifts are larger than data size

parent 2b08cbf9
No related branches found
No related tags found
1 merge request!10Fix a bug in `timeshift` when shifts are larger than data size
Pipeline #103740 passed
......@@ -43,6 +43,10 @@ def timeshift(data, shifts, order=31):
logging.debug("Constant shifts, using correlation method")
i_min = shift_ints - (halfp - 1)
i_max = shift_ints + halfp + data.size
if i_max - 1 < 0:
return numpy.repeat(data[0], data.size)
if i_min > data.size - 1:
return numpy.repeat(data[-1], data.size)
logging.debug("Padding data (left=%d, right=%d)", max(0, -i_min), max(0, i_max - data.size))
data_trimmed = data[max(0, i_min):min(data.size, i_max)]
data_padded = numpy.pad(data_trimmed, (max(0, -i_min), max(0, i_max - data.size)), mode='edge')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment