All Projects → espdev → Csaps

espdev / Csaps

Licence: mit
Cubic spline approximation (smoothing)

Programming Languages

python
139335 projects - #7 most used programming language

Labels

Projects that are alternatives of or similar to Csaps

Vanilla Tilt.js
A smooth 3D tilt javascript library.
Stars: ✭ 2,851 (+3752.7%)
Mutual labels:  smooth
react-svg-curve
React components to draw different types of curves with svg
Stars: ✭ 42 (-43.24%)
Mutual labels:  smooth
Between.js
Lightweight JavaScript (ES6) tweening engine
Stars: ✭ 703 (+850%)
Mutual labels:  smooth
ReactZooApp
ReactZooApp
Stars: ✭ 33 (-55.41%)
Mutual labels:  smooth
array-smooth
Moving average smooth algorithm
Stars: ✭ 20 (-72.97%)
Mutual labels:  smooth
Jump.js
A modern smooth scrolling library.
Stars: ✭ 3,459 (+4574.32%)
Mutual labels:  smooth
Snappyrecyclerview
An extension to RecyclerView which will snap to child Views to the specified anchor, START, CENTER or END.
Stars: ✭ 178 (+140.54%)
Mutual labels:  smooth
Aiflatswitch
Nicely animated flat design switch alternative to UISwitch
Stars: ✭ 904 (+1121.62%)
Mutual labels:  smooth
smoovy
A collection of small and useful js packages (smooth scrolling, utils, etc.) preventing copy & paste
Stars: ✭ 25 (-66.22%)
Mutual labels:  smooth
Superslide.js
A flexible, smooth, GPU accelerated sliding menu for your next PWA
Stars: ✭ 496 (+570.27%)
Mutual labels:  smooth
universalSmoothScroll
A cross-browser smooth-scrolling API which supports multiple and interruptable scroll-animations on all DOM's elements, even at the same time!
Stars: ✭ 46 (-37.84%)
Mutual labels:  smooth
react-svg-pathline
React component for drawing SVG path through set of points, smoothing the corners
Stars: ✭ 42 (-43.24%)
Mutual labels:  smooth
React Smooth Range Input
🎚 React beautiful input range slider
Stars: ✭ 356 (+381.08%)
Mutual labels:  smooth
Moveto
A lightweight scroll animation javascript library without any dependency
Stars: ✭ 2,746 (+3610.81%)
Mutual labels:  smooth
Mos
一个用于在 macOS 上平滑你的鼠标滚动效果或单独设置滚动方向的小工具, 让你的滚轮爽如触控板 | A lightweight tool used to smooth scrolling and set scroll direction independently for your mouse on macOS
Stars: ✭ 7,772 (+10402.7%)
Mutual labels:  smooth
Vue Smooth Picker
🏄🏼 A SmoothPicker for Vue 2 (like native datetime picker of iOS)
Stars: ✭ 188 (+154.05%)
Mutual labels:  smooth
smooth-polyline
〰️ Smoothing algorithm for 2D lines and polygons
Stars: ✭ 23 (-68.92%)
Mutual labels:  smooth
Mgs Camera
Unity plugin for control camera in scene.
Stars: ✭ 66 (-10.81%)
Mutual labels:  smooth
Scroll Into View If Needed
Element.scrollIntoView ponyfills for things like "if-needed" and "smooth"
Stars: ✭ 811 (+995.95%)
Mutual labels:  smooth
Ngx Scrollbar
Custom overlay-scrollbars with native scrolling mechanism
Stars: ✭ 355 (+379.73%)
Mutual labels:  smooth

csaps

PyPI version Supported Python versions GitHub Actions (Tests) Documentation Status Coverage Status License

csaps is a Python package for univariate, multivariate and n-dimensional grid data approximation using cubic smoothing splines. The package can be useful in practical engineering tasks for data approximation and smoothing.

Installing

Use pip for installing:

pip install -U csaps

The module depends only on NumPy and SciPy. Python 3.6 or above is supported.

Simple Examples

Here is a couple of examples of smoothing data.

An univariate data smoothing:

import numpy as np
import matplotlib.pyplot as plt

from csaps import csaps

np.random.seed(1234)

x = np.linspace(-5., 5., 25)
y = np.exp(-(x/2.5)**2) + (np.random.rand(25) - 0.2) * 0.3
xs = np.linspace(x[0], x[-1], 150)

ys = csaps(x, y, xs, smooth=0.85)

plt.plot(x, y, 'o', xs, ys, '-')
plt.show()

univariate

A surface data smoothing:

import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

from csaps import csaps

np.random.seed(1234)
xdata = [np.linspace(-3, 3, 41), np.linspace(-3.5, 3.5, 31)]
i, j = np.meshgrid(*xdata, indexing='ij')
ydata = (3 * (1 - j)**2. * np.exp(-(j**2) - (i + 1)**2)
         - 10 * (j / 5 - j**3 - i**5) * np.exp(-j**2 - i**2)
         - 1 / 3 * np.exp(-(j + 1)**2 - i**2))
ydata = ydata + (np.random.randn(*ydata.shape) * 0.75)

ydata_s = csaps(xdata, ydata, xdata, smooth=0.988)

fig = plt.figure(figsize=(7, 4.5))
ax = fig.add_subplot(111, projection='3d')
ax.set_facecolor('none')
c = [s['color'] for s in plt.rcParams['axes.prop_cycle']]
ax.plot_wireframe(j, i, ydata, linewidths=0.5, color=c[0], alpha=0.5)
ax.scatter(j, i, ydata, s=10, c=c[0], alpha=0.5)
ax.plot_surface(j, i, ydata_s, color=c[1], linewidth=0, alpha=1.0)
ax.view_init(elev=9., azim=290)

plt.show()

surface

Documentation

More examples of usage and the full documentation can be found at https://csaps.readthedocs.io.

Testing

We use pytest for testing.

cd /path/to/csaps/project/directory
pip install -e .[tests]
pytest

Algorithm and Implementation

csaps Python package is inspired by MATLAB CSAPS function that is an implementation of Fortran routine SMOOTH from PGS (originally written by Carl de Boor).

Also the algothithm implementation in other languages:

  • csaps-rs Rust ndarray/sprs based implementation
  • csaps-cpp C++11 Eigen based implementation (incomplete)

References

C. de Boor, A Practical Guide to Splines, Springer-Verlag, 1978.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].