我想将地理参考数据重新分配到在纬度和经度维度上具有不同分辨率的特定网格。在我使用basemap.interp
之前,但是此底图已失效。
我正在尝试metpy
软件包,而metpy.interpolate_to_points
似乎是合适的候选人。仅从documentation中,我无法计算出应输入参数的格式。
内容为:
points(点状数组,形状(n,D))–数据点的坐标。 值(array_like,形状(n,))–数据点的值。 xi (array_like,形状(M,D))–要将数据插值到的点。
关于“点”,我尝试将它们提供为一维数组,二维网格(通过np.meshgrid获得),并以长期优先或延迟优先的方式提供。与“ xi”相同。例如:
from metpy.interpolate import interpolate_to_points
out_lons, out_lats = np.meshgrid(out_lons_1Darray, out_lats_1Darray)
downscaled_array = interpolate_to_points( [in_lons, in_lats], input_array, [out_lons, out_lats] )
无论通过哪种尝试,我都会得到ValueError: operands could not be broadcast together with shapes (192,) (288,)
任何对我做错地方的建议都将不胜感激。
答案 0 :(得分:1)
此函数包装scipy.interpolate.griddata
,您可以查看其文档here。
他们的示例显示了以下内容,其功能与metpy.interpolate.interpolate_to_points
函数相同:
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:100j, 0:1:200j]
points = np.random.rand(1000, 2)
values = func(points[:,0], points[:,1])
grid_out = interpolate_to_points(points, values, (grid_x, grid_y))