pydata / xarray

N-D labeled arrays and datasets in Python
https://xarray.dev
Apache License 2.0
3.6k stars 1.08k forks source link

Missing linked coordinates of subgroup variable #6085

Closed zxdawn closed 2 years ago

zxdawn commented 2 years ago

What happened:

I have a NetCDF file that has groups like this:

--/PRODUCT/
--/PRODUCT/SUPPORT_DATA/DETAILED_RESULTS
.....

Screenshots

image

image

When I read the variable named air_mass_factor_clear inside /PRODUCT/SUPPORT_DATA/DETAILED_RESULTS, the coordinates are missing. But, it works for variable named nitrogendioxide_tropospheric_column in the /PRODUCT/ group.

What you expected to happen:

Coordinates of variables in subgroups are loaded.

Minimal Complete Verifiable Example:

xr.open_dataset('./201908/S5P_PAL__L2__NO2____20190811T022605_20190811T040734_09459_01_020301_20211110T023157.nc',
                group='PRODUCT/')['nitrogendioxide_tropospheric_column']

image

xr.open_dataset('./201908/S5P_PAL__L2__NO2____20190811T022605_20190811T040734_09459_01_020301_20211110T023157.nc',
                group='PRODUCT/SUPPORT_DATA/DETAILED_RESULTS/')['air_mass_factor_clear']

image

Environment:

Output of xr.show_versions() INSTALLED VERSIONS ------------------ commit: None python: 3.9.7 | packaged by conda-forge | (default, Sep 29 2021, 19:20:46) [GCC 9.4.0] python-bits: 64 OS: Linux OS-release: 5.11.0-40-generic machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: ('en_US', 'UTF-8') libhdf5: 1.12.1 libnetcdf: 4.8.1 xarray: 0.20.1 pandas: 1.3.4 numpy: 1.20.3 scipy: 1.7.3 netCDF4: 1.5.8 pydap: None h5netcdf: None h5py: 3.6.0 Nio: None zarr: 2.10.3 cftime: 1.5.1.1 nc_time_axis: None PseudoNetCDF: None rasterio: 1.2.10 cfgrib: None iris: None bottleneck: None dask: 2021.11.2 distributed: 2021.11.2 matplotlib: 3.5.0 cartopy: 0.20.1 seaborn: None numbagg: None fsspec: 2021.11.1 cupy: None pint: 0.18 sparse: None setuptools: 59.4.0 pip: 21.3.1 conda: 4.11.0 pytest: None IPython: 7.30.0 sphinx: None
TomNicholas commented 2 years ago

Hi @zxdawn, thanks for the report. Would you say your issue is the same as the one in https://github.com/pydata/xarray/issues/1982 ?

zxdawn commented 2 years ago

Hi @TomNicholas, thanks and yes that's the same issue. Shall we close this duplicated one?

TomNicholas commented 2 years ago

Yes I think we should close this as a duplicate. By the way, this isn't a quick fix in xarray.Dataset as it is (see https://github.com/pydata/xarray/issues/1982#issuecomment-437990188 as for why), so if we do ever support this behaviour it's likely to be via the DataTree route described in #4118.