| Conditions | 2 |
| Total Lines | 17 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | # Licensed under a 3-clause BSD style license - see LICENSE |
||
| 30 | def interp_smooth_curve(x, y, s, N=None): |
||
| 31 | """Return an interpolated and smoothed curve of len N. A gaussian kernel of std = s (in units of x) is used for smoothing. |
||
| 32 | If N is None, an array of the same length is returned (but interpolated so it is equispaced). |
||
| 33 | """ |
||
| 34 | |||
| 35 | s = s/np.ptp(x)*len(x) |
||
| 36 | |||
| 37 | if N is None: |
||
| 38 | N = len(x) |
||
| 39 | |||
| 40 | spl = sp.interpolate.splrep(x, y) |
||
| 41 | xs = np.linspace(min(x), max(x), N) |
||
| 42 | ys = sp.interpolate.splev(xs, spl) |
||
| 43 | |||
| 44 | ys = sp.ndimage.gaussian_filter1d(ys, s) |
||
| 45 | |||
| 46 | return xs, ys |
||