python - 将 xarray DataArray 的一部分转换为 NumPy 数组
问题描述
我有一个太大而无法转换为 NumPy 数组的 DataArray:
da = xr.open_dataset('tprate.grib', engine='cfgrib').tprate
da.values
我有:
Unable to allocate 8.56 TiB for an array with shape (28, 7008, 185, 180, 360) and data type float32
如果我isel
是前两个维度的 DataArray 的一部分,它能够转换:
ncep_da.isel(number=0, time=0).values
但是如果我isel
最后两个维度,使用的内存保持不变:
ncep_da.isel(latitude=0, longitude=0).values
我仍然得到:
Unable to allocate 8.56 TiB for an array with shape (28, 7008, 185, 180, 360) and data type float32
我猜这是因为第二个子数组没有按顺序存储在磁盘上,因为最右边的维度是数据的内部循环。
有没有办法提取第二个子数组并将其有效地转换为 NumPy 数组?
解决方案
推荐阅读
- r - ggplot - 定义小数位的对数轴标签
- python - 检查是否返回 JSON
- conda - 如何使用 conda 为 R4.1.1 安装 r-devel
- arrays - const 数组数组作为函数参数
- calendar - 有什么方法可以更新 GitLab 日历以指示周数?
- mongodb - MongoDB(猫鼬):转换为 [string] 失败
- arrays - 如何使用matlab在netcdf文件中所需的变量值级别内制作空间图
- vba - 如何优化vba中的连接
- python - 如何获取列表中一对字典的所有值的列表,每个字典都有不同的键?
- karate - 无法在空手道 maven 项目的另一个模块中调用实用程序