espdev / csaps

Cubic spline approximation (smoothing)
https://csaps.readthedocs.io
MIT License
164 stars 27 forks source link

Input data aspects for smoothing #41

Closed nsankar closed 3 years ago

nsankar commented 3 years ago

Hi, Thanks for developing this interesting data smoothing library.

espdev commented 3 years ago

Hi @nsankar,

Yes, you can use time stamp values for X (data sites). X-values must increase or decrease strictly monotonically. You can use ndarray for temperature and pressure data as Y-values at the same X-values. In this case you have a multivariate data. And yes, you can use the same X-values for Xi. In this case you just evaluate the spline for the same X-values without interpolation.

For example:

x = [5, 10, 15, 20, 25, 30]  # time stamps
y = [
    [0.5, 1.2, 0.7, 1.3, 0.4, 0.1],  # temperature
    [5.5, 7.1, 1.8, 2.2, 4.3, 1.5],  # pressure
]

ys = csaps(x, y, x, smooth=0.8)
nsankar commented 3 years ago

@espdev Great! Thank you for the inputs.

espdev commented 3 years ago

@nsankar You are welcome :)