打开具有许多组的远程 zarr 商店并使用 xarray 保持坐标

问题描述

我想读入 https://hrrrzarr.s3.amazonaws.com/index.html#sfc/20210208/20210208_00z_anl.zarr/ 的远程 zarr 存储。 zarr 商店的信息位于 https://mesowest.utah.edu/html/hrrr/zarr_documentation/zarrFileVariables.html

我能够读入一个变量,但它似乎没有捕获与该变量相关的坐标或属性(我很可能缺少 open_mfdatasetopen_zarrkwargs)。因为有不同级别的嵌套,我不确定什么是正确的传递路径

import xarray as xr
import s3fs

fs = s3fs.S3FileSystem(anon=True)
uri = "s3://hrrrzarr/sfc/20210208/20210208_00z_anl.zarr/10m_above_ground/UGrd/10m_above_ground"

file = s3fs.S3Map(uri,s3=fs)
ds = xr.open_mfdataset([file],engine="zarr")
>>> ds
<xarray.Dataset>
Dimensions:  (projection_x_coordinate: 1799,projection_y_coordinate: 1059)
Dimensions without coordinates: projection_x_coordinate,projection_y_coordinate
Data variables:
    UGrd     (projection_y_coordinate,projection_x_coordinate) float16 dask.array<chunksize=(150,150),Meta=np.ndarray>

uri = "s3://hrrrzarr/sfc/20210208/20210208_00z_anl.zarr/10m_above_ground/UGrd"
file = s3fs.S3Map(uri,engine="zarr")
>>> ds
<xarray.Dataset>
Dimensions:                  (projection_x_coordinate: 1799,projection_y_coordinate: 1059)
Coordinates:
  * projection_x_coordinate  (projection_x_coordinate) float64 -2.698e+06 ......
  * projection_y_coordinate  (projection_y_coordinate) float64 -1.587e+06 ......
Data variables:
    forecast_period          timedelta64[ns] ...
    forecast_reference_time  datetime64[ns] ...
    height                   float64 ...
    pressure                 float64 ...
    time                     datetime64[ns] ...

解决方法

Xarray 无法理解嵌套的 zarr 组。它期望所有变量和坐标都在一个平面组中。我认为您唯一的选择是手动合并数据集。你试过吗

ds = xr.open_mfdataset([file1,file2],engine="zarr")

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...