Closed
Description
MCVE Code Sample
import numpy as np
import xarray as xr
tstr='2019-07-25_00:00:00'
Times = xr.DataArray(np.array([" ".join(tstr).split()], dtype = 'S1'), dims = ['Time', 'DateStrLen'])
ds = xr.Dataset({'Times':Times})
ds.to_netcdf('test.nc', format='NETCDF4',encoding={'Times': {'zlib':True, 'complevel':5}}, unlimited_dims={'Time':True})
Expected Output
Because I want to use the nc file as the input of WRF model,
I just need Time
and DateStrLen
two dimensions.
ncdump -h test.nc
:
netcdf test {
dimensions:
Time = UNLIMITED ; // (1 currently)
DateStrLen = 19 ;
variables:
char Times(Time, DateStrLen) ;
}
Although it's possible to set the exact char_dim_name
to Time
like #2895,
but I need the unlimited Time
dimension as the first one.
Problem Description
This is the actual output of ncdump -h test.nc
:
netcdf test {
dimensions:
Time = UNLIMITED ; // (1 currently)
DateStrLen = 19 ;
string1 = 1 ;
variables:
char Times(Time, DateStrLen, string1) ;
}
Output of xr.show_versions()
INSTALLED VERSIONS
------------------
commit: None
python: 3.6.9 |Anaconda, Inc.| (default, Jul 30 2019, 19:07:31)
[GCC 7.3.0]
python-bits: 64
OS: Linux
OS-release: 3.0.76-0.11-default
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
libhdf5: 1.10.1
libnetcdf: 4.4.1.1
xarray: 0.13.0
pandas: 0.25.1
numpy: 1.17.2
scipy: 1.3.1
netCDF4: 1.3.1
pydap: None
h5netcdf: None
h5py: 2.8.0
Nio: None
zarr: 2.3.2
cftime: None
nc_time_axis: None
PseudoNetCDF: None
rasterio: None
cfgrib: None
iris: None
bottleneck: None
dask: 2.5.0
distributed: 2.5.2
matplotlib: 3.1.1
cartopy: 0.17.0
seaborn: None
numbagg: None
setuptools: 41.2.0
pip: 19.2.3
conda: None
pytest: None
IPython: 7.8.0
sphinx: None
Metadata
Metadata
Assignees
Labels
No labels