<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
```
or Poetry:
```
poetry add csaps
```
The module depends only on NumPy and SciPy. Python 3.10 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.
## Development
We use Poetry to manage the project:
```
git clone https://github.com/espdev/csaps.git
cd csaps
poetry install -E docs
```
Also, install pre-commit hooks:
```
poetry run pre-commit install
```
## Testing and Linting
We use pytest for testing and ruff/mypy for linting.
Use `poethepoet` to run tests and linters:
```
poetry run poe test
poetry run poe check
```
## 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": null,
"name": "csaps",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"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/d4/3a/fe35895aa266d02db8418db543b6b967e466a9e3e510524a01fa07ba02bc/csaps-1.3.3.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\nor Poetry:\n\n```\npoetry add csaps\n```\n\nThe module depends only on NumPy and SciPy. Python 3.10 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## Development\n\nWe use Poetry to manage the project:\n\n```\ngit clone https://github.com/espdev/csaps.git\ncd csaps\npoetry install -E docs\n```\n\nAlso, install pre-commit hooks:\n\n```\npoetry run pre-commit install\n```\n\n## Testing and Linting\n\nWe use pytest for testing and ruff/mypy for linting.\nUse `poethepoet` to run tests and linters:\n\n```\npoetry run poe test\npoetry run poe check\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## 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\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Cubic spline approximation (smoothing)",
"version": "1.3.3",
"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": null,
"digests": {
"blake2b_256": "8b419d387a411700cdb21613a9a90b45febcad6fd583cad069d5e60de33d71af",
"md5": "920d4cc46ecd2da570cf3c3169ba13c7",
"sha256": "844d1d1258b9fc23a7be08d92bd6f5a33b7eac9c13a9df61569b2b033aa6ca44"
},
"downloads": -1,
"filename": "csaps-1.3.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "920d4cc46ecd2da570cf3c3169ba13c7",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 16319,
"upload_time": "2025-09-07T21:02:50",
"upload_time_iso_8601": "2025-09-07T21:02:50.083597Z",
"url": "https://files.pythonhosted.org/packages/8b/41/9d387a411700cdb21613a9a90b45febcad6fd583cad069d5e60de33d71af/csaps-1.3.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "d43afe35895aa266d02db8418db543b6b967e466a9e3e510524a01fa07ba02bc",
"md5": "6eda89c72e425c167f16479739fc91fc",
"sha256": "ac89c597c4e6b5d53d17acac1283453ea4eab23a7f4e31bf1db8cad0a10dec19"
},
"downloads": -1,
"filename": "csaps-1.3.3.tar.gz",
"has_sig": false,
"md5_digest": "6eda89c72e425c167f16479739fc91fc",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 16274,
"upload_time": "2025-09-07T21:02:51",
"upload_time_iso_8601": "2025-09-07T21:02:51.584861Z",
"url": "https://files.pythonhosted.org/packages/d4/3a/fe35895aa266d02db8418db543b6b967e466a9e3e510524a01fa07ba02bc/csaps-1.3.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-09-07 21:02:51",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "espdev",
"github_project": "csaps",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"lcname": "csaps"
}