我正在尝试分析时间序列中的数据。我想插入原始数据并使它们在时间上等间隔,所以我使用scipy立方样条。一切都好,直到10000点(浮点数),但在这个点数之后似乎不起作用。我尝试过10001点并且插值失败。这是记忆问题吗?我正在使用Canopy(学术许可证)。
# reading the timeseries and interpolating with cubic splines
# for creating equally spaced in time data
import numpy as np
import matplotlib.pyplot as plt
import scipy.stats.stats as st
from scipy import interpolate
# Reading the timeseries data file as a two column ASCII file
data = np.loadtxt('cut.dat')
data_tot = np.loadtxt('mynrg.dat')
# creating the arrays of each observable
# 10000 has been set during my tests i want 65536 points
time = np.array(data[:10000,0]);
heat_flux =np.array( data[:10000,1]);
#new time values equaly spaced
new_time_values = np.linspace(time[0], time[np.size(time)-1],endpoint=True,num = np.size(time));
# cubic spline interpolation
# plot original and interpolated data
spl_fit = interpolate.splrep(time , heat_flux, s =0 , k =3);
new_heat_flux = interpolate.splev(new_time_values, spl_fit, der=0);
答案 0 :(得分:0)
样条拟合是一个全球过程。您的splrep调用尝试操作10000乘10000矩阵。底层的Fortran代码扮演了一些相当聪明的技巧,但仍然 - 你真的需要持续的差异化吗?你可能最好使用分段多项式插值器(看看scipy.interpolate.PPoly和BPoly)。