【发布时间】:2021-09-11 23:12:00
【问题描述】:
当我尝试打开这个看起来像这样的 .nc 文件时,我不知道如何解决这个错误:
remote_var
Out[99]:
<xarray.Dataset>
Dimensions: (lat: 721, lon: 1440, time: 1)
Coordinates:
* lat (lat) float64 90.0 89.75 89.5 89.25 ... -89.25 -89.5 -89.75 -90.0
* lon (lon) float64 0.0 0.25 0.5 0.75 1.0 ... 359.0 359.2 359.5 359.8
Dimensions without coordinates: time
Data variables:
M (time, lat, lon) float32 dask.array<chunksize=(1, 721, 1440), meta=np.ndarray>
我的错误如下所示:
Traceback (most recent call last):
File "C:\Users\U321103\.spyder-py3\ERA5_MAPPING\ERA5_MAP_100M_WSPD.py", line 35, in <module>
selectvar.M.plot()
IndexError: index -1 is out of bounds for axis 0 with size 0
<Figure size 432x288 with 0 Axes>
我的代码如下所示:
#The easiest way to read the data is:
path = "//porfiler03/gtdshare/VORTEX/ANOMALY_FILES/anomaly.M.2021.05.vs30y/era5.M.2021.05.nc"
remote_var = xr.open_mfdataset(path,combine='nested',concat_dim='time')
selectvar = remote_var.where((-135 < remote_var.lon) & (remote_var.lon < -60)
& (25 < remote_var.lat) & (remote_var.lat < 50), drop=True)
#plot M
plt.figure()
selectvar.M.plot()
exit()
在这里感谢您的帮助!
【问题讨论】:
标签: python matplotlib python-xarray