Skip to content
Snippets Groups Projects
Commit 9a88cb27 authored by Philipp Niedermayer's avatar Philipp Niedermayer
Browse files

Generalize avg function

parent 61a58ffa
No related branches found
No related tags found
No related merge requests found
......@@ -46,7 +46,12 @@ CMD_BEAM_INJECTION = 283
def avg(*data, n=100):
return [np.array(d)[:int(len(d)/n)*n].reshape(-1, n).mean(axis=1) for d in data] if n else data
"""Averages the data by combining n subsequent points into one (works on last axis)"""
result = []
for d in data:
w = int(d.shape[-1]/n)
result.append(d[...,:w*n].reshape(*d.shape[:-1], w, n).mean(axis=-1))
return result
def smooth(*data, n):
return [scipy.signal.savgol_filter(d, n, 0) for d in data] if n else data
......
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