summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2023-03-08 11:47:39 +0100
committerAnton Khirnov <anton@khirnov.net>2023-03-08 11:47:39 +0100
commiteff1bf008658ce9a77b21407bfc3175fc595a02a (patch)
tree79211a69324f6202979f6afd7d77a8d30502d312
parentf7e1380547471db864a385ea376ca7154ac65c51 (diff)
interp: allow extrapolation in interp1d
-rw-r--r--interp.py1
1 files changed, 1 insertions, 0 deletions
diff --git a/interp.py b/interp.py
index e326e6d..778fc52 100644
--- a/interp.py
+++ b/interp.py
@@ -4,6 +4,7 @@ import numpy as np
def interp1d(src_start, src_step, src_val, dst_coords, stencil):
idx_src = ((dst_coords - src_start) / src_step - (stencil / 2 - 1)).astype(int)
+ idx_src = np.minimum(np.maximum(idx_src, 0), len(src_val) - stencil)
src_coord = np.linspace(src_start, src_start + src_step * (src_val.shape[0] - 1),
src_val.shape[0], dtype = src_val.dtype)