Metadata-Version: 2.1
Name: csaps
Version: 0.8.0
Summary: Cubic spline approximation (smoothing)
Home-page: https://github.com/espdev/csaps
Author: Eugene Prilepin
Author-email: esp.home@gmail.com
License: MIT
Project-URL: Documentation, https://csaps.readthedocs.io
Project-URL: Code, https://github.com/espdev/csaps
Project-URL: Issue tracker, https://github.com/espdev/csaps/issues
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Scientific/Engineering :: Mathematics
Classifier: Topic :: Software Development :: Libraries
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: Implementation :: CPython
Requires-Python: >=3.5, <4
Description-Content-Type: text/markdown
Requires-Dist: numpy (<1.20.0,>=0.12.1)
Requires-Dist: scipy (<1.6.0,>=0.19.1)
Provides-Extra: docs
Requires-Dist: sphinx (>=2.3) ; extra == 'docs'
Requires-Dist: matplotlib (>=3.1) ; extra == 'docs'
Requires-Dist: numpydoc ; extra == 'docs'
Requires-Dist: m2r ; extra == 'docs'
Provides-Extra: tests
Requires-Dist: pytest ; extra == 'tests'

# CSAPS: Cubic spline approximation (smoothing)

[![PyPI version](https://img.shields.io/pypi/v/csaps.svg)](https://pypi.python.org/pypi/csaps)
[![Documentation Status](https://readthedocs.org/projects/csaps/badge/?version=latest)](https://csaps.readthedocs.io/en/latest/?badge=latest)
[![Build status](https://travis-ci.org/espdev/csaps.svg?branch=master)](https://travis-ci.org/espdev/csaps)
[![Coverage Status](https://coveralls.io/repos/github/espdev/csaps/badge.svg?branch=master)](https://coveralls.io/github/espdev/csaps?branch=master)
![Supported Python versions](https://img.shields.io/pypi/pyversions/csaps.svg)
[![License](https://img.shields.io/pypi/l/csaps.svg)](LICENSE)

**csaps** is a package for univariate, multivariate and nd-gridded data approximation using cubic smoothing splines.

## Installation

Python 3.5 or above is supported.

```
pip install -U csaps
```

The module depends only on NumPy and SciPy.

## Simple Examples

Here are 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()
```

![univariate](https://user-images.githubusercontent.com/1299189/72231304-cd774380-35cb-11ea-821d-d5662cc1eedf.png)

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()
```

![surface](https://user-images.githubusercontent.com/1299189/72231252-7a9d8c00-35cb-11ea-8890-487b8a7dbd1d.png)

## Documentation

More examples of usage and the full documentation can be found at ReadTheDocs.

https://csaps.readthedocs.io

## Testing

pytest, tox and Travis CI are used for testing. Please see [test_csaps.py](tests).

## Algorithms and implementations

**csaps** package is a Python modified port of 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).

[csaps-cpp](https://github.com/espdev/csaps-cpp) C++11 Eigen based implementation of the algorithm.

## References

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

## License

[MIT](https://choosealicense.com/licenses/mit/)

# Changelog

## v0.8.0

* Add `csaps` function that can be used as the main API
* Refactor the internal structure of the package
* Add the [documentation](https://csaps.readthedocs.io)

**Attention**

This is the last version that supports Python 3.5. 
The next versions will support Python 3.6 or above.

## v0.7.0

* Add Generic-based type-hints and mypy-compatibility

## v0.6.1

* A slight refactoring and extra data copies removing

## v0.6.0

* Add "axis" parameter for univariate/multivariate cases

## v0.5.0

* Reorganize the project to package-based structure
* Add the interface class for all smoothing spline classes

## v0.4.2

* FIX: "smooth" value is 0.0 was not used

## v0.4.1

* First PyPI release


