Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 2.7 Python重新填充二维旋转网格网格_Python 2.7_Scipy_Grid_Interpolation - Fatal编程技术网

Python 2.7 Python重新填充二维旋转网格网格

Python 2.7 Python重新填充二维旋转网格网格,python-2.7,scipy,grid,interpolation,Python 2.7,Scipy,Grid,Interpolation,我有一个二维旋转矩形网格,其经纬度值为[405555],我不知道如何对其进行重磨,我想要一个轴与平行线和子午线“平行”的矩形网格 我曾尝试将scipy插值函数用作:griddata或RegularGridInterpolator,但我始终对旧的网格维度存在问题,因为它们是二维的且旋转的,值不会重复,我不知道如何解决它 很抱歉,我不能发布我的原始代码和数据,因为它们是专有的,我不知道如何创建MWE 我试过这个: import scipy.interpolate.ndgriddata as ndgr

我有一个二维旋转矩形网格,其经纬度值为[405555],我不知道如何对其进行重磨,我想要一个轴与平行线和子午线“平行”的矩形网格

我曾尝试将scipy插值函数用作:griddata或RegularGridInterpolator,但我始终对旧的网格维度存在问题,因为它们是二维的且旋转的,值不会重复,我不知道如何解决它

很抱歉,我不能发布我的原始代码和数据,因为它们是专有的,我不知道如何创建MWE

我试过这个:

import scipy.interpolate.ndgriddata as ndgriddata
import numpy as np

x = np.linspace(35.0, 42.0, 405) # my new longitude
y = np.linspace(36.0, 48.0, 555) # my new latitude
X, Y = np.meshgrid(x, y)

# grid_lon: old 2D array [405, 555] for the longitude
# grid_lat: old 2D array [405, 555] for the latitude
# data: old 2D array [405, 555] for the data
test = ndgriddata.griddata((grid_lon, grid_lat), data, (X, Y), method="linear")
但是,我当然得到了错误:

ValueError:输入数据点的形状无效

我知道这很难回答,但如果有人有想法,请告诉我

谢谢


Ciccio

我只需将旧坐标和数据展平

ndgriddata.griddata((grid_lon.flatten(), grid_lat.flatten()), 
                    data.flatten(), (X, Y), method="linear")

嗨@ciciodevoto-我也对这个问题感兴趣。但是,你能在你的ode中更清楚地说明你在使用哪些scipy函数吗?不清楚ndgriddata.griddata来自何处。CheersHi@dreab对不起,你说得对,我更新了包括导入在内的内容。ndgriddata来自scipy.interpolate,我希望这可以帮助您,如果您有任何其他问题,请告诉我:-)