Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nomad-vagabond/splinecloud-scipy
A Python client for SplineCloud API
https://github.com/nomad-vagabond/splinecloud-scipy
approximation b-splines curve-fitting interpolation scipy splines
Last synced: about 1 month ago
JSON representation
A Python client for SplineCloud API
- Host: GitHub
- URL: https://github.com/nomad-vagabond/splinecloud-scipy
- Owner: nomad-vagabond
- License: mit
- Created: 2021-11-10T01:21:46.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-01-21T15:06:59.000Z (12 months ago)
- Last Synced: 2024-11-14T15:12:26.177Z (about 2 months ago)
- Topics: approximation, b-splines, curve-fitting, interpolation, scipy, splines
- Language: Python
- Homepage: https://pypi.org/project/splinecloud-scipy
- Size: 569 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# splinecloud-scipy
A Python client for [SplineCloud API](https://splinecloud.com/api/docs/)
The client library is based on [SciPy](https://scipy.org/) and allows to load data and curves from [SplineCloud](https://splinecloud.com/) into your code. Once loaded spline curves can be easily evaluated.
## Installation
```
pip install splinecloud-scipy
```## Example of loading spline curve
```python
from splinecloud_scipy import load_splinecurve_id = 'spl_K5t56P5bormJ' # take curve ID from the 'API link' dropdown at SplineCloud
spline = load_spline(curve_id)
```## Evaluating spline curve for a range of x values
```python
import numpy as np
import matplotlib.pyplot as pltX = np.linspace(0, 20, 100)
Y = [spline.eval(x) for x in X]plt.plot(X,Y)
plt.grid()
plt.show()
```![Spline curve](/docs/img/curve.png?raw=true)
## Load data fitted by spline and evaluate fit accuracy
```python
columns, table = spline.load_data()
x_data, y_data = table.Tplt.plot(X,Y)
plt.plot(x_data, y_data, 'o', color="grey")
plt.grid()
plt.xlabel(columns[0])
plt.ylabel(columns[1])
plt.show()
```![Spline curve](/docs/img/curve_points.png?raw=true)
```python
RMSE = spline.fit_accuracy(table, method="RMSE")
print(RMSE)0.011307453345329156
```## Example of loading data in your code
```python
from splinecloud_scipy import load_subset
subset_id = 'sbt_nDO4XmmYqeGI' # subset id can be taken from the SplineCloud
columns, table = load_subset(subset_id)
``````
>>> columns['Throttle (%)',
'Load Currency (A)',
'Pull (g)',
'Power (W)',
'Efficiency (g/W)']
``````
>>> tablearray([[5.0000e-01, 6.7600e+00, 3.8500e+02, 1.0871e+02, 3.5420e+00],
[6.0000e-01, 1.0200e+01, 4.9500e+02, 1.6249e+02, 3.0460e+00],
[7.0000e-01, 1.3580e+01, 6.0600e+02, 2.1768e+02, 2.7840e+00],
[8.0000e-01, 1.7390e+01, 6.8700e+02, 2.7140e+02, 2.5510e+00],
[9.0000e-01, 2.1030e+01, 7.4700e+02, 3.2813e+02, 2.2770e+00],
[1.0000e+00, 2.5060e+01, 8.0700e+02, 3.8555e+02, 2.0930e+00]])
```These examples are available as notebooks in the project's 'examples' folder.
## Important
This library supports BSpline geometry but does not support weighted BSplines (NURBS). If you adjust the weights of the curve control points use another client, that supports NURBS (a link will be provided here soon).