ValueError:无法将输入数组从 shape () 广播到 shape()
我使用 for 循环附加一些数组,如下所示:
nx, ny = lon.shape
for i in range(nx):
j = np.argmin(lon[i,:])
lon[i,:] = np.append(lon[i,j:],lon[i,:j])
lat[i,:] = np.append(lat[i,j:],lat[i,:j])
bathy[i,:] = np.append(bathy[i,j:],bathy[i,:j])
到目前为止,循环工作成功,因为像“bathy”这样的变量只有两个维度(lon,lat)。我想附加另一个名为“temp”的变量,但该变量具有(3D)三个维度(时间、经度、纬度),我该怎么做?考虑到当我通过以下方式附加此类变量时:
temp[i,:] = np.append(temp[i,j:],temp[i,:j])
我收到以下错误:
ValueError: could not broadcast input array from shape (1512000,) into shape (12,1331)
I am appending some arrays using a for loop as following :
nx, ny = lon.shape
for i in range(nx):
j = np.argmin(lon[i,:])
lon[i,:] = np.append(lon[i,j:],lon[i,:j])
lat[i,:] = np.append(lat[i,j:],lat[i,:j])
bathy[i,:] = np.append(bathy[i,j:],bathy[i,:j])
so far the loops works successfully because variable like "bathy" has only two dimensions (lon,lat). I want to append another variable called "temp" but this variable has (3D) three dimensions (time,lon,lat), How can i do this ? Taking into account when I append such variable in the following way :
temp[i,:] = np.append(temp[i,j:],temp[i,:j])
I get the following error :
ValueError: could not broadcast input array from shape (1512000,) into shape (12,1331)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论