Skip to content
Snippets Groups Projects
Commit f63567c8 authored by Raphael's avatar Raphael
Browse files

multi column operations

parent 2b80f007
No related branches found
No related tags found
No related merge requests found
......@@ -26,7 +26,12 @@ def compute_trajectory(times, time_gap):
def apply_func_on_window(dat, func, radius, on_edge='copy'):
result = np.zeros(dat.shape)
if on_edge == 'copy':
dat = np.concatenate([np.repeat(dat[0], radius), dat, np.repeat(dat[-1], radius)])
if len(dat.shape) == 1:
dat = np.concatenate([np.full(radius, dat[0]), dat, np.full(radius, dat[-1])])
else:
dat = np.concatenate([np.repeat(np.array(dat[0]).reshape((1, len(dat[0]))), radius, axis=0),
dat,
np.repeat(np.array(dat[-1]).reshape((1, len(dat[-1]))), radius, axis=0)])
for i in range(radius, dat.shape[0] - radius):
data = dat[i - radius:i + radius + 1]
result[i - radius] = func(data)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment