插值

作者: 榴莲气象 | 来源:发表于2019-01-10 15:10 被阅读5次

METPY
https://unidata.github.io/MetPy/latest/examples/gridding/Point_Interpolation.html?highlight=point
SCIPY
https://docs.scipy.org/doc/scipy/reference/tutorial/interpolate.html

from scipy.interpolate import griddata
import numpy as np
def func(x, y):
    return x*(1-x)*np.cos(4*np.pi*x) * np.sin(4*np.pi*y**2)**2
grid_x, grid_y = np.mgrid[0:1:50j, 0:1:100j]
points = np.random.rand(1000, 2)
x=points[:,0]
y=points[:,1]
print(x)
print(points.shape)
print(grid_x.shape)
print(grid_y.shape)
values = func(points[:,0], points[:,1])
#print(grid_x)
#print(points[:,0])
print(values.shape)
grid_z0 = griddata((x,y), values, (grid_x, grid_y), method='nearest')
grid_z1 = griddata(points, values, (grid_x, grid_y), method='linear')
grid_z2 = griddata(points, values, (grid_x, grid_y), method='cubic')

print(grid_z0.shape)
print(grid_z1.shape)
print(grid_z2.shape)

(1000, 2)# 对numpy.meshgrid()理解## numpy.meshgrid()理解
(50, 100)
(50, 100)
(1000,) ##只有一列
(50, 100)
(50, 100)
(50, 100)

相关文章

  • 缺失值处理-拉格朗日插值

    常用的插值法有:一维插值法:拉格朗日插值、牛顿插值、分段低次插值、埃尔米特插值、样条插值。二维插值法:双线性插值、...

  • 28. 图像缩放

    插值方法 四种插值,最近邻域插值 双线性插值 像素关系重采样 立方插值其中最近邻域插值、双线性插值原理如下: 1)...

  • 数值分析之插值

    插值 一.基本概念 1.1插值需要研究的问题 插值函数是否存在? 如何构造插值函数? 如何评估误差? 1.2插值法...

  • Less_变量插值

    选择器名插值 属性名插值 URL插值 import插值 媒体查询插值 less的作用域,就近原则,如果自己有这个变...

  • vue.js权威指南第2章——数据绑定

    一: 插值(Mustache标签)1: {{}},插值为数据;变体{{*text}},2: {{{}}} , 插值...

  • 【图像缩放算法】双立方(三次)插值

    当我们进行图像缩放的时候,我们就需要用到插值算法。常见的插值有: 最邻近插值 双线性插值 双立方(三次)插值在这三...

  • AngularJS学习之路——表达式(2)

    插值字符串 插值字符串就是拥有插值标记的字符串 举个栗子 这里的 {{ expr }} 就是插值标记,str 就是...

  • Android动画中篇(插值器、估值器)

    插值器(Interpolator)&估值器(TypeEvaluator) 插值器(Interpolator) 定义...

  • 插值

    格点插值到站点 R = linint2_points_Wrap (precip&lon,precip&lat,pr...

  • 插值#{}

    使用 CSS 预处理器语言的一个主要原因是想使用 Sass 获得一个更好的结构体系。比如说你想写更干净的、高效的和...

网友评论

      本文标题:插值

      本文链接:https://www.haomeiwen.com/subject/mcjarqtx.html