在过去,我只是将常规插值包装在日志空间中,即
def log_interp(zz, xx, yy):
logz = np.log10(zz)
logx = np.log10(xx)
logy = np.log10(yy)
return np.power(10.0, np.interp(logz, logx, logy))
就个人而言,我更喜欢scipy interpolation functions(如@mylesgallagher提到的),例如:
import scipy as sp
import scipy.interpolate
def log_interp1d(xx, yy, kind='linear'):
logx = np.log10(xx)
logy = np.log10(yy)
lin_interp = sp.interpolate.interp1d(logx, logy, kind=kind)
log_interp = lambda zz: np.power(10.0, lin_interp(np.log10(zz)))
return log_interp
然后你可以把它称为任意值的函数.