简体   繁体   English

Scipy样条插值:在实际计算之前确定tck中的节点/ B样条系数的矢量的数组长度

[英]Scipy spline interpolation: Determine array length of vector of knots / B-spline coefficients in tck before actual computation

Is it somehow possible to determine the array length of the arrays in the tck tuple returned by scipy.interpolate.splprep before computing the values? 在计算值之前,在scipy.interpolate.splprep返回的tck元组中数组的数组长度吗?

I have to fit a spline interpolation to noisy data with 5 million data points (or less, can be varying). 我必须将样条插值拟合到具有500万个数据点(或更少,可以变化)的噪声数据。 My observation is that the interpolation at an array length of ~ 90 is pretty good, while it takes a long time to compute the interpolation for higher array lengths (it sometimes also directly jumps from ~ 90 to ~ 1000 while making s one step smaller and the interpolation also becomes noisy) and it is not appropriate enough, if the array length is far less (<50)... 我的观察是,阵列长度为~90的插值是相当不错的,而计算插值需要很长时间才能获得更高的数组长度(有时也可以直接从~90跳到~1000,同时使s更小一步插值也变得有噪声)如果阵列长度远小于(<50),那就不够合适了......

Actually, this array length depends on the smoothing factor s provided to the splprep function, but for different measurement data, s varies a lot to get a consistent array length of around 90. Eg for data1 s has a value of around 1000 to get len(cfk[0]) equals to 90, for data2 s has a value of around 100 to get len(cfk[0]) equals to 90 at same lengths of data1 and data2 . 实际上,这个数组的长度取决于提供给splprep函数的平滑因子s ,但是对于不同的测量数据, s变化很大,以获得大约90的一致数组长度。例如,对于data1 s ,其值大约为1000以获得len(cfk[0])等于90,因为data2 s的值大约为100,所以len(cfk[0])等于90, data1data2长度相同。 It might be dependent on the noise of the data... 它可能取决于数据的噪音......

I have thought about a loop where s starts at some point and decreases through the loop while len(cfk[0]) is constantly being checked - but this takes ages, especially if len(cfk[0]) gets closer to 90. 我已经考虑了一个循环,其中s从某个点开始并在循环中减少而len(cfk[0])经常被检查 - 但这需要很len(cfk[0]) ,特别是如果len(cfk[0])接近90。

Therefore, it would be useful to somehow know the smoothing factor to get the desired array length before computing the cfk tuple. 因此,在计算cfk元组之前以某种方式知道平滑因子以获得所需的阵列长度将是有用的。

Short answer: no, not easily. 简短回答:不,不容易。 Dierckx Fortran library, which splrep wraps, uses some fairly non-trivial logic for determining the knot vector, and it's all baked into the Fortran code. Direckx Fortran库,splrep包装,使用一些相当重要的逻辑来确定结向量,并且它们都被融入Fortran代码中。 So, the only way is to carefully trace the latter. 因此,唯一的方法是仔细追踪后者。 It's available from netlib, also scipy/interpolate/fitpack 它可以从netlib获得,也可以scipy / interpolate / fitpack

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM