python中单变量插值的残差

时间:2016-11-01 12:07:39

标签: python interpolation resampling

我正在尝试重新采样一些数据(测井数据,在我的情况下,电阻率与深度),我需要将错误与我的重采样数据相关联。 我选择通过单变量样条函数来做,我该如何计算 每个点的残差(误差条)? 我的原始数据被认为没有错误。

import numpy as np
import matplotlib.pyplot as plt
from scipy.interpolate import UnivariateSpline
import seaborn as sns


depth, resistivity = np.loadtxt('resistivity.txt', unpack=True)

#resampling (every 10 m depth)
depth_coarse = depth[::20] 

resistivity_spline = UnivariateSpline(depth, resistivity, k=1, s=1)

#plot
fig = plt.figure(figsize=(6.5,10))
figure_title = 'Resistivity Log resampled'

ax = fig.add_subplot(1,1,1)

plt.text(0.5, 1.08, figure_title,
     horizontalalignment='center',
     fontsize=20,
     transform = ax.transAxes)


ax.plot(resistivity, depth, c='grey', label='data', alpha=0.6)
ax.plot(resistivity_spline(depth_coarse), depth_coarse, '-x',     label=r'data resampled $\Delta z = 10$ m')


ax.legend(loc='best', fancybox=True, framealpha=0.5)
ax.set_xlabel('Resistivity (ohm m)')
ax.xaxis.set_label_position('top')
ax.set_ylabel('Depth (m)')
ax.xaxis.set_ticks_position('top')
ax.invert_yaxis()


plt.show()

抱歉天真,我是编程新手:/

my plot

0 个答案:

没有答案