问题描述
我创建了一个 xarray 数据数组的子集,以获取从 (301,660,24,7676) 到 (61,106,7676) 的维度。这些维度是(纬度、经度、小时、天)。我还尝试将小时和天合并为一个时间戳维度(这可能不正确),然后新维度现在是(61、106、184224)。但是,我正在尝试快速绘制以检查所有经纬度位置的第二个时间戳的值,并且它引发了一个内存错误,该错误看起来会恢复到原始大小经纬度?我的子集是否不正确?:
#---------- Read in data,ERA5------------------
files_ERA5 = glob.glob(r'D:\ERA5 investigation data\ERA5 data\*.grib')
combined_ERA5=xr.open_mfdataset(files_ERA5,chunks={'latitude': 10,'longitude': 10},combine='by_coords',engine="cfgrib")
print("ERA5 Dimensions:")
combined_ERA5
输出:
我定义了选定的纬度和经度数组以选择仅使用:
#-------subset with defined array of lat/lon (ERA5_closest_lat) for new dimensions
ERA5_closest_lat1 = list(set(ERA5_closest_lat))
ERA5_closest_lon1 = list(set(ERA5_closest_lon))
#select only the locations from the ERA5_closest_lat and ERA5_closest_lon arrays to create a subset:
subset_ERA5=combined_ERA5.sel(latitude=ERA5_closest_lat1,longitude=ERA5_closest_lon1)
print("ERA5 subset Dimensions:")
subset_ERA5
#combine the step and time dimensions
subset_ERA5_new = subset_ERA5.stack(timestep=("step","time"))
试图绘制这是引发错误的原因,有什么想法吗?:
subset_ERA5_new[:,:,2].plot()
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)