如何修复*ProjError:x、y、z和时间必须是相同大小+错误
我正在加载一个.nc
文件和视图数据集
lat
、lon
是数据交换的基本映射类型
但是错误消息调用了三个值x
,y
,z
XU_OCEAN_uv = uv.variables['XU_OCEAN'][:]
YU_OCEAN_uv = uv.variables['YU_OCEAN'][:]
lon_0 = XU_OCEAN_uv.mean()
lat_0 = YU_OCEAN_uv.mean()
fig = plt.figure(figsize=[12,15])
plt.rc("font", size=20)
plt.rcParams['font.family'] = 'New Century Schoolbook'
from datetime import datetime
fig = plt.figure(figsize=[12,15])
m = Basemap(width=5000000,height=3500000,
resolution='l',projection='stere',\
lat_ts=40,lat_0=lat_0,lon_0=lon_0)
m.drawcoastlines()
m.drawcountries()
m.drawmapboundary(fill_color='white')
m.drawparallels(np.arange(-90,91,30),labels=[1,0,0,0],dashes=[2,2])
m.drawmeridians(np.arange(0,361,60),labels=[0,0,0,1],dashes=[2,2])
VO_uv_firstTimestep = VO_uv[0,:,:]
cs = m.pcolor(LON,LAT,VO_uv_firstTimestep)
cbar = m.colorbar(cs, location='bottom', pad="10%")
cbar.set_label(VO_uv_units)
# Add Title
plt.title('sea level height')
plt.show()
数据集如下所示:
错误代码为:
---------------------------------------------------------------------------
ProjError Traceback (most recent call last)
<ipython-input-59-abf5ef221078> in <module>
26
27 #m.scatter(X, Y, c=VAL, s=1.0, marker="s", zorder=1, vmin=0, vmax=1200, cmap=plt.cm.get_cmap('jet'), alpha=1.0)
---> 28 LON,LAT = m(XU_OCEAN_uv,YU_OCEAN_uv)
29
30 VO_uv_firstTimestep = VO_uv[0,:,:]
/opt/anaconda3/envs/py37/lib/python3.7/site-packages/mpl_toolkits/basemap/__init__.py in __call__(self, x, y, inverse)
1186 except TypeError:
1187 y = [_dg2rad*yy for yy in y]
-> 1188 xout,yout = self.projtran(x,y,inverse=inverse)
1189 if self.celestial and inverse:
1190 try:
/opt/anaconda3/envs/py37/lib/python3.7/site-packages/mpl_toolkits/basemap/proj.py in __call__(self, *args, **kw)
291 outxy = self._proj4(xy, inverse=inverse)
292 else:
--> 293 outx,outy = self._proj4(x, y, inverse=inverse)
294 if inverse:
295 if self.projection in ['merc','mill','gall']:
/opt/anaconda3/envs/py37/lib/python3.7/site-packages/pyproj/proj.py in __call__(self, longitude, latitude, inverse, errcheck, radians)
185 direction=direction,
186 errcheck=errcheck,
--> 187 radians=radians,
188 )
189
/opt/anaconda3/envs/py37/lib/python3.7/site-packages/pyproj/transformer.py in transform(self, xx, yy, zz, tt, radians, errcheck, direction)
493 direction=direction,
494 radians=radians,
--> 495 errcheck=errcheck,
496 )
497 # if inputs were lists, tuples or floats, convert back.
pyproj/_transformer.pyx in pyproj._transformer._Transformer._transform()
ProjError: x, y, z, and time must be same size
目前没有回答
相关问题 更多 >
编程相关推荐