<p align="center">
<a href="https://github.com/espdev/csaps"><img src="https://user-images.githubusercontent.com/1299189/76571441-8d97e400-64c8-11ea-8c05-58850f8311a1.png" alt="csaps" width="400" /></a><br>
</p>
<p align="center">
<a href="https://pypi.python.org/pypi/csaps"><img src="https://img.shields.io/pypi/v/csaps.svg" alt="PyPI version" /></a>
<a href="https://pypi.python.org/pypi/csaps"><img src="https://img.shields.io/pypi/pyversions/csaps.svg" alt="Supported Python versions" /></a>
<a href="https://github.com/espdev/csaps"><img src="https://github.com/espdev/csaps/workflows/main/badge.svg" alt="GitHub Actions (Tests)" /></a>
<a href="https://csaps.readthedocs.io/en/latest/?badge=latest"><img src="https://readthedocs.org/projects/csaps/badge/?version=latest" alt="Documentation Status" /></a>
<a href="https://coveralls.io/github/espdev/csaps?branch=master"><img src="https://coveralls.io/repos/github/espdev/csaps/badge.svg?branch=master" alt="Coverage Status" /></a>
<a href="https://choosealicense.com/licenses/mit/"><img src="https://img.shields.io/pypi/l/csaps.svg" alt="License" /></a>
</p>
**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.9 or above is supported.
## Simple Examples
Here is a couple of examples of smoothing data.
An univariate data smoothing:
```python
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()
```
<p align="center">
<img src="https://user-images.githubusercontent.com/1299189/72231304-cd774380-35cb-11ea-821d-d5662cc1eedf.png" alt="univariate" />
<p/>
A surface data smoothing:
```python
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()
```
<p align="center">
<img src="https://user-images.githubusercontent.com/1299189/72231252-7a9d8c00-35cb-11ea-8890-487b8a7dbd1d.png" alt="surface" />
<p/>
## 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](https://www.mathworks.com/help/curvefit/csaps.html) function that is an implementation of
Fortran routine SMOOTH from [PGS](http://pages.cs.wisc.edu/~deboor/pgs/) (originally written by Carl de Boor).
Also the algothithm implementation in other languages:
* [csaps-rs](https://github.com/espdev/csaps-rs) Rust ndarray/sprs based implementation
* [csaps-cpp](https://github.com/espdev/csaps-cpp) C++11 Eigen based implementation (incomplete)
## References
C. de Boor, A Practical Guide to Splines, Springer-Verlag, 1978.
## License
[MIT](https://choosealicense.com/licenses/mit/)
Raw data
{
"_id": null,
"home_page": "https://github.com/espdev/csaps",
"name": "csaps",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "cubic, spline, approximation, smoothing, interpolation, csaps",
"author": "Evgeny Prilepin",
"author_email": "esp.home@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/3c/60/251c772f3f72f263eb93faa39152a411ace518e33ad33730eeca4fb37024/csaps-1.2.0.tar.gz",
"platform": null,
"description": "<p align=\"center\">\n <a href=\"https://github.com/espdev/csaps\"><img src=\"https://user-images.githubusercontent.com/1299189/76571441-8d97e400-64c8-11ea-8c05-58850f8311a1.png\" alt=\"csaps\" width=\"400\" /></a><br>\n</p>\n\n<p align=\"center\">\n <a href=\"https://pypi.python.org/pypi/csaps\"><img src=\"https://img.shields.io/pypi/v/csaps.svg\" alt=\"PyPI version\" /></a>\n <a href=\"https://pypi.python.org/pypi/csaps\"><img src=\"https://img.shields.io/pypi/pyversions/csaps.svg\" alt=\"Supported Python versions\" /></a>\n <a href=\"https://github.com/espdev/csaps\"><img src=\"https://github.com/espdev/csaps/workflows/main/badge.svg\" alt=\"GitHub Actions (Tests)\" /></a>\n <a href=\"https://csaps.readthedocs.io/en/latest/?badge=latest\"><img src=\"https://readthedocs.org/projects/csaps/badge/?version=latest\" alt=\"Documentation Status\" /></a>\n <a href=\"https://coveralls.io/github/espdev/csaps?branch=master\"><img src=\"https://coveralls.io/repos/github/espdev/csaps/badge.svg?branch=master\" alt=\"Coverage Status\" /></a>\n <a href=\"https://choosealicense.com/licenses/mit/\"><img src=\"https://img.shields.io/pypi/l/csaps.svg\" alt=\"License\" /></a>\n</p>\n\n**csaps** is a Python package for univariate, multivariate and n-dimensional grid data approximation using cubic smoothing splines.\nThe package can be useful in practical engineering tasks for data approximation and smoothing.\n\n## Installing\n\nUse pip for installing:\n\n```\npip install -U csaps\n```\n\nThe module depends only on NumPy and SciPy. Python 3.9 or above is supported.\n\n## Simple Examples\n\nHere is a couple of examples of smoothing data.\n\nAn univariate data smoothing:\n\n```python\nimport numpy as np\nimport matplotlib.pyplot as plt\n\nfrom csaps import csaps\n\nnp.random.seed(1234)\n\nx = np.linspace(-5., 5., 25)\ny = np.exp(-(x/2.5)**2) + (np.random.rand(25) - 0.2) * 0.3\nxs = np.linspace(x[0], x[-1], 150)\n\nys = csaps(x, y, xs, smooth=0.85)\n\nplt.plot(x, y, 'o', xs, ys, '-')\nplt.show()\n```\n\n<p align=\"center\">\n <img src=\"https://user-images.githubusercontent.com/1299189/72231304-cd774380-35cb-11ea-821d-d5662cc1eedf.png\" alt=\"univariate\" />\n<p/>\n\nA surface data smoothing:\n\n```python\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom mpl_toolkits.mplot3d import Axes3D\n\nfrom csaps import csaps\n\nnp.random.seed(1234)\nxdata = [np.linspace(-3, 3, 41), np.linspace(-3.5, 3.5, 31)]\ni, j = np.meshgrid(*xdata, indexing='ij')\nydata = (3 * (1 - j)**2. * np.exp(-(j**2) - (i + 1)**2)\n - 10 * (j / 5 - j**3 - i**5) * np.exp(-j**2 - i**2)\n - 1 / 3 * np.exp(-(j + 1)**2 - i**2))\nydata = ydata + (np.random.randn(*ydata.shape) * 0.75)\n\nydata_s = csaps(xdata, ydata, xdata, smooth=0.988)\n\nfig = plt.figure(figsize=(7, 4.5))\nax = fig.add_subplot(111, projection='3d')\nax.set_facecolor('none')\nc = [s['color'] for s in plt.rcParams['axes.prop_cycle']]\nax.plot_wireframe(j, i, ydata, linewidths=0.5, color=c[0], alpha=0.5)\nax.scatter(j, i, ydata, s=10, c=c[0], alpha=0.5)\nax.plot_surface(j, i, ydata_s, color=c[1], linewidth=0, alpha=1.0)\nax.view_init(elev=9., azim=290)\n\nplt.show()\n```\n\n<p align=\"center\">\n <img src=\"https://user-images.githubusercontent.com/1299189/72231252-7a9d8c00-35cb-11ea-8890-487b8a7dbd1d.png\" alt=\"surface\" />\n<p/>\n\n## Documentation\n\nMore examples of usage and the full documentation can be found at https://csaps.readthedocs.io.\n\n## Testing\n\nWe use pytest for testing.\n\n```\ncd /path/to/csaps/project/directory\npip install -e .[tests]\npytest\n```\n\n## Algorithm and Implementation\n\n**csaps** Python package is inspired by MATLAB [CSAPS](https://www.mathworks.com/help/curvefit/csaps.html) function that is an implementation of \nFortran routine SMOOTH from [PGS](http://pages.cs.wisc.edu/~deboor/pgs/) (originally written by Carl de Boor).\n\nAlso the algothithm implementation in other languages:\n\n* [csaps-rs](https://github.com/espdev/csaps-rs) Rust ndarray/sprs based implementation\n* [csaps-cpp](https://github.com/espdev/csaps-cpp) C++11 Eigen based implementation (incomplete)\n\n\n## References\n\nC. de Boor, A Practical Guide to Splines, Springer-Verlag, 1978.\n\n## License\n\n[MIT](https://choosealicense.com/licenses/mit/)\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Cubic spline approximation (smoothing)",
"version": "1.2.0",
"project_urls": {
"Documentation": "https://csaps.readthedocs.io",
"Homepage": "https://github.com/espdev/csaps",
"Repository": "https://github.com/espdev/csaps"
},
"split_keywords": [
"cubic",
" spline",
" approximation",
" smoothing",
" interpolation",
" csaps"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "39bbbab6eed263cd367cc40362100ea9ae614ac83c94cd8e765421d3050075b9",
"md5": "5c68c7b49b41efc7d492b1a1963ef12b",
"sha256": "648283410864c816a7da55be72d54aeda87993f35c3533eab9d2b25399ddb7e5"
},
"downloads": -1,
"filename": "csaps-1.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "5c68c7b49b41efc7d492b1a1963ef12b",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 18913,
"upload_time": "2024-06-30T12:36:41",
"upload_time_iso_8601": "2024-06-30T12:36:41.421598Z",
"url": "https://files.pythonhosted.org/packages/39/bb/bab6eed263cd367cc40362100ea9ae614ac83c94cd8e765421d3050075b9/csaps-1.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "3c60251c772f3f72f263eb93faa39152a411ace518e33ad33730eeca4fb37024",
"md5": "2c7b3a20c59210bea1d0852f6a80df0b",
"sha256": "346569028eedc6102ac4bcd799aed7b5150e587599719d91b589e21202c25c7a"
},
"downloads": -1,
"filename": "csaps-1.2.0.tar.gz",
"has_sig": false,
"md5_digest": "2c7b3a20c59210bea1d0852f6a80df0b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 14957,
"upload_time": "2024-06-30T12:36:43",
"upload_time_iso_8601": "2024-06-30T12:36:43.749294Z",
"url": "https://files.pythonhosted.org/packages/3c/60/251c772f3f72f263eb93faa39152a411ace518e33ad33730eeca4fb37024/csaps-1.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-06-30 12:36:43",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "espdev",
"github_project": "csaps",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"lcname": "csaps"
}