Subsetting xarray.Dataset with respect to multiple coordinates

后端 未结 1 894
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-26 20:51

Say I have an xarray.Dataset object loaded in using xarray.open_dataset(..., decode_times=False) that looks like this when printed:

<         


        
1条回答
  •  粉色の甜心
    2021-01-26 21:15

    NetCDF4 doesn't support all of the multi-dimensional indexing operations supported by NumPy. But does support slicing (which is very fast) and one dimensional indexing (somewhat slower).

    Some things to try:

    • Index with slices (e.g., .sel(time=slice(start, end))) before indexing with 1-dimensional arrays. This should offload the array-based indexing from netCDF4 to Dask/NumPy.
    • Split up your indexing operations into more intermediate operations that index along fewer dimensions at once. It sounds like you've already tried this one, but maybe it's worth exploring a little more.
    • To optimize performance, try different Dask chunking schemes using the .chunk().

    If that doesn't work, post a full self-contained example to the xarray issue tracker on GitHub and we can take a look into it in more detail.

    0 讨论(0)
提交回复
热议问题