NetCDF coordinates in parent group is not used when reading sub group
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.2k
- Forks
- 1.4k
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 14
Description
Code Sample, a copy-pastable example if possible
ncfile_cf = "x07z00017_cf.nc"
with xr.open_dataset(ncfile_cf, group="x07") as ds:
ds_data_cf = ds.copy(deep=True)
print(ds_data_cf)
<xarray.Dataset>
Dimensions: (time1: 100000, time2: 2)
Dimensions without coordinates: time1, time2
Data variables:
aps (time1) float64 ...
iact (time1) float64 ...
vact (time1) float64 ...
dps (time1) float64 ...
tss (time2) float64 ...
Problem description
When reading a sub group from a netCDF file with dimensions defined in the root group, the dimensions are not read from the root group. This contradicts the netCDF documentation, which states that dimensions are scoped such that they can be seen by all sub groups.
The attached netCDF file demonstrates this issue.
x07z00017_cf.nc.zip
Expected Output
The dimensions from the root group should be used when reading the sub-group.
with xr.open_dataset(ncfile_cf) as ds:
for coord in ds.coords:
ds_data_cf.coords[coord] = ds[coord]
print(ds_data_cf)
<xarray.Dataset>
Dimensions: (time1: 100000, time2: 2)
Coordinates:
* time1 (time1) float64 0.0 1e-06 2e-06 3e-06 4e-06 5e-06 6e-06 7e-06 ...
* time2 (time2) float64 0.0 0.1
Data variables:
aps (time1) float64 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 1.0 1.0 ...
iact (time1) float64 -0.00125 -0.000625 -0.00125 -0.0009375 ...
vact (time1) float64 -0.009375 -0.009375 -0.01875 -0.01875 -0.009375 ...
dps (time1) float64 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 ...
tss (time2) float64 0.0 0.0
Output of xr.show_versions()
INSTALLED VERSIONS
commit: None
python: 3.6.4.final.0
python-bits: 64
OS: Linux
OS-release: 4.13.0-36-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_GB.UTF-8
LOCALE: en_GB.UTF-8
xarray: 0.10.0
pandas: 0.22.0
numpy: 1.13.3
scipy: 1.0.0
netCDF4: 1.3.1
h5netcdf: None
Nio: None
bottleneck: 1.2.1
cyordereddict: None
dask: 0.15.3
matplotlib: 2.1.0
cartopy: None
seaborn: 0.8.0
setuptools: 38.5.1
pip: 9.0.1
conda: 4.4.11
pytest: 3.2.1
IPython: 6.2.1
sphinx: 1.6.3
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the xr.open_dataset call using the attached NetCDF file and the group="x07" argument. Trace how dimensions and coordinates are loaded for a sub-group, then compare that behavior with loading the root group. Done means root-group coordinates are available when opening the sub-group, matching the expected output shown in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100