Created
May 19, 2025 10:25
-
-
Save pavlin-policar/6a6b48e30b2c4197689abf9c7128affc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def smooth_line(x, y, sigma=5, interp_points=300): | |
from scipy.ndimage import gaussian_filter1d | |
x_interp = np.linspace(x.min(), x.max(), interp_points) | |
# The gaussian filter assumes spacing 1, so we have to adjust sigma | |
interp_diff = x_interp[1] - x_interp[0] | |
effective_sigma = sigma / interp_diff | |
y_interp = np.interp(x_interp, x, y) | |
y_smooth = gaussian_filter1d(y_interp, sigma=effective_sigma) | |
return x_interp, y_smooth |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment