Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dimension names are lost in mode nczarr,noxarray #2647

Open
malmans2 opened this issue Mar 1, 2023 · 4 comments
Open

Dimension names are lost in mode nczarr,noxarray #2647

malmans2 opened this issue Mar 1, 2023 · 4 comments

Comments

@malmans2
Copy link

malmans2 commented Mar 1, 2023

>> nc-config --version
netCDF 4.9.1

When I write a file in mode "nczarr,noxarray" the attributes describing the dimension names are lost.

>> ncdump -h file://test-nczarr-noxarray#mode=nczarr

netcdf test-nczarr-noxarray {
dimensions:
	_zdim_9 = 9 ;
	_zdim_10 = 10 ;
	_zdim_20 = 20 ;
	_zdim_8 = 8 ;
variables:
	double dim2(_zdim_9) ;
		dim2:_FillValue = NaN ;
	int64 numbers(_zdim_10) ;
	int64 time(_zdim_20) ;
		time:units = "days since 2000-01-01 00:00:00" ;
		time:calendar = "proleptic_gregorian" ;
	double var1(_zdim_8, _zdim_9) ;
		var1:_FillValue = NaN ;
		var1:foo = "variable" ;
	double var2(_zdim_8, _zdim_9) ;
		var2:_FillValue = NaN ;
		var2:foo = "variable" ;
	double var3(_zdim_10, _zdim_8) ;
		var3:_FillValue = NaN ;
		var3:foo = "variable" ;
		var3:coordinates = "numbers" ;
}
This is the same file written in mode `"nczarr"`
>> ncdump -h file://test-nczarr#mode=nczarr

netcdf test-nczarr {
dimensions:
	dim2 = 9 ;
	time = 20 ;
	dim1 = 8 ;
	dim3 = 10 ;
variables:
	double dim2(dim2) ;
		dim2:_FillValue = NaN ;
	int64 time(time) ;
		time:units = "days since 2000-01-01 00:00:00" ;
		time:calendar = "proleptic_gregorian" ;
	double var1(dim1, dim2) ;
		var1:_FillValue = NaN ;
		var1:foo = "variable" ;
	double var2(dim1, dim2) ;
		var2:_FillValue = NaN ;
		var2:foo = "variable" ;
	double var3(dim3, dim1) ;
		var3:_FillValue = NaN ;
		var3:foo = "variable" ;
		var3:coordinates = "numbers" ;
	int64 numbers(dim3) ;
}
Here is the code and environment to reproduce the MRE
from xarray.tests.test_dataset import create_test_data
ds = create_test_data()
ds = ds.drop_vars("dim3")
for mode in ("nczarr", "nczarr,noxarray"):
    ds.to_netcdf(f"file://test-{mode.replace(',', '-')}#mode={mode}")
>> conda list
# packages in environment at /Users/mattia/mambaforge/envs/xarray-new:
#
# Name                    Version                   Build  Channel
appnope                   0.1.3              pyhd8ed1ab_0    conda-forge
asciitree                 0.3.3                      py_2    conda-forge
asttokens                 2.2.1              pyhd8ed1ab_0    conda-forge
attrs                     22.2.0             pyh71513ae_0    conda-forge
backcall                  0.2.0              pyh9f0ad1d_0    conda-forge
backports                 1.0                pyhd8ed1ab_3    conda-forge
backports.functools_lru_cache 1.6.4              pyhd8ed1ab_0    conda-forge
bzip2                     1.0.8                h0d85af4_4    conda-forge
c-ares                    1.18.1               h0d85af4_0    conda-forge
ca-certificates           2022.12.7            h033912b_0    conda-forge
cftime                    1.6.2           py311hd5badaa_1    conda-forge
colorama                  0.4.6              pyhd8ed1ab_0    conda-forge
curl                      7.88.1               h6df9250_0    conda-forge
decorator                 5.1.1              pyhd8ed1ab_0    conda-forge
entrypoints               0.4                pyhd8ed1ab_0    conda-forge
exceptiongroup            1.1.0              pyhd8ed1ab_0    conda-forge
executing                 1.2.0              pyhd8ed1ab_0    conda-forge
fasteners                 0.17.3             pyhd8ed1ab_0    conda-forge
hdf4                      4.2.15               h7aa5921_5    conda-forge
hdf5                      1.12.2          nompi_h48135f9_101    conda-forge
icu                       70.1                 h96cf925_0    conda-forge
iniconfig                 2.0.0              pyhd8ed1ab_0    conda-forge
ipython                   8.11.0             pyhd1c38e8_0    conda-forge
jedi                      0.18.2             pyhd8ed1ab_0    conda-forge
jpeg                      9e                   hb7f2c08_3    conda-forge
krb5                      1.20.1               h049b76e_0    conda-forge
libaec                    1.0.6                hf0c8a7f_1    conda-forge
libblas                   3.9.0           16_osx64_openblas    conda-forge
libcblas                  3.9.0           16_osx64_openblas    conda-forge
libcurl                   7.88.1               h6df9250_0    conda-forge
libcxx                    15.0.7               h71dddab_0    conda-forge
libedit                   3.1.20191231         h0678c8f_2    conda-forge
libev                     4.33                 haf1e3a3_1    conda-forge
libffi                    3.4.2                h0d85af4_5    conda-forge
libgfortran               5.0.0           10_4_0_h97931a8_28    conda-forge
libgfortran5              11.3.0              h082f757_28    conda-forge
libiconv                  1.17                 hac89ed1_0    conda-forge
liblapack                 3.9.0           16_osx64_openblas    conda-forge
libnetcdf                 4.9.1           nompi_h56690a0_101    conda-forge
libnghttp2                1.51.0               he2ab024_0    conda-forge
libopenblas               0.3.21          openmp_h429af6e_3    conda-forge
libsqlite                 3.40.0               ha978bb4_0    conda-forge
libssh2                   1.10.0               h47af595_3    conda-forge
libxml2                   2.10.3               hb9e07b5_0    conda-forge
libzip                    1.9.2                h6db710c_1    conda-forge
libzlib                   1.2.13               hfd90126_4    conda-forge
llvm-openmp               15.0.7               h61d9ccf_0    conda-forge
matplotlib-inline         0.1.6              pyhd8ed1ab_0    conda-forge
msgpack-python            1.0.4           py311hd2070f0_1    conda-forge
ncurses                   6.3                  h96cf925_1    conda-forge
netcdf4                   1.6.2           nompi_py311he6f34b2_101    conda-forge
numcodecs                 0.11.0          py311h814d153_1    conda-forge
numpy                     1.24.2          py311ha9d2c9f_0    conda-forge
openssl                   3.0.8                hfd90126_0    conda-forge
packaging                 23.0               pyhd8ed1ab_0    conda-forge
pandas                    1.5.3           py311hd84f3f5_0    conda-forge
parso                     0.8.3              pyhd8ed1ab_0    conda-forge
pexpect                   4.8.0              pyh1a96a4e_2    conda-forge
pickleshare               0.7.5                   py_1003    conda-forge
pip                       23.0.1             pyhd8ed1ab_0    conda-forge
pluggy                    1.0.0              pyhd8ed1ab_5    conda-forge
prompt-toolkit            3.0.38             pyha770c72_0    conda-forge
prompt_toolkit            3.0.38               hd8ed1ab_0    conda-forge
ptyprocess                0.7.0              pyhd3deb0d_0    conda-forge
pure_eval                 0.2.2              pyhd8ed1ab_0    conda-forge
pygments                  2.14.0             pyhd8ed1ab_0    conda-forge
pytest                    7.2.1              pyhd8ed1ab_0    conda-forge
python                    3.11.0          he7542f4_1_cpython    conda-forge
python-dateutil           2.8.2              pyhd8ed1ab_0    conda-forge
python_abi                3.11                    3_cp311    conda-forge
pytz                      2022.7.1           pyhd8ed1ab_0    conda-forge
readline                  8.1.2                h3899abd_0    conda-forge
setuptools                67.4.0             pyhd8ed1ab_0    conda-forge
six                       1.16.0             pyh6c4a22f_0    conda-forge
stack_data                0.6.2              pyhd8ed1ab_0    conda-forge
tk                        8.6.12               h5dbffcc_0    conda-forge
tomli                     2.0.1              pyhd8ed1ab_0    conda-forge
traitlets                 5.9.0              pyhd8ed1ab_0    conda-forge
tzdata                    2022g                h191b570_0    conda-forge
wcwidth                   0.2.6              pyhd8ed1ab_0    conda-forge
wheel                     0.38.4             pyhd8ed1ab_0    conda-forge
xarray                    2023.2.0           pyhd8ed1ab_0    conda-forge
xz                        5.2.6                h775f41a_0    conda-forge
zarr                      2.13.6             pyhd8ed1ab_0    conda-forge
zlib                      1.2.13               hfd90126_4    conda-forge
zstd                      1.5.2                hbc0c0cd_6    conda-forge
@DennisHeimbigner
Copy link
Collaborator

Currently, it is the case that (no)xarray implies pure Zarr.
So it is the case that one cannot have NCZarr and XARRAY at the same time.

@malmans2
Copy link
Author

malmans2 commented Mar 1, 2023

Thanks, I think I misunderstood the usage of xarray/noxarray.

To recap, there are 3 scenarios:

  • (mode=nczarr): write both _ARRAY_DIMENSIONS and _nczarr_attr
  • (mode=zarr; mode=zarr,xarray; mode=nczarr,xarray): write _ARRAY_DIMENSIONS only
  • (mode=zarr,noxarray; mode=nczarr,noxarray): do NOT write _ARRAY_DIMENSIONS nor _nczarr_attr

Therefore it is not possible to write _nczarr_attr only?

@DennisHeimbigner
Copy link
Collaborator

I think that is correct.
I suppose there is no harm in writing _ARRAY_DIMENSIONS in all cases (unless noxarray), so in effect
that would separate any connection between the (nczarr,zarr) choice and the (xarray,noxarray) choice.
Any opinion on that?b

@malmans2
Copy link
Author

malmans2 commented Mar 1, 2023

Yes, I think that would make it more clear.

Maybe it would be even better to make nczarr and noxarray mutually exclusive, meaning that mode=nczarr,noxarray would raise an error and nczarr is always compatible with xarray by definition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants