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

Moving average smoothing

parent 05036561
No related branches found
No related tags found
No related merge requests found
......@@ -223,8 +223,10 @@ def plot_tune_spectrum(ax, libera_data, xy, turn_range=None, time_range=None, tu
if smoothing is not None:
ls, = ax.plot(freq, mag, **dict(kwargs, zorder=-100, alpha=0.1))
if 'c' not in kwargs and 'color' not in kwargs: kwargs.update(c=ls.get_color())
freq, mag, phase = avg(freq, mag, phase, n=smoothing)
add_scale(ax, smoothing*np.mean(np.diff(freq)))
#freq, mag, phase = avg(freq, mag, phase, n=smoothing)
freq, mag, phase = [scipy.signal.savgol_filter(_, smoothing, 0) for _ in (freq, mag, phase)] # savgol filter with order 0 is moving average
ax.plot(freq, mag, **kwargs)
ax.set(xlim=tune_range, xlabel=f'Tune $q_{xy}$',
......
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