issues: 437418525
This data as json
id | node_id | number | title | user | state | locked | assignee | milestone | comments | created_at | updated_at | closed_at | author_association | active_lock_reason | draft | pull_request | body | reactions | performed_via_github_app | state_reason | repo | type |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
437418525 | MDU6SXNzdWU0Mzc0MTg1MjU= | 2921 | to_netcdf with decoded time can create file with inconsistent time:units and time_bounds:units | 15570875 | closed | 0 | 4 | 2019-04-25T22:08:52Z | 2019-06-25T00:24:42Z | 2019-06-25T00:24:42Z | NONE | Code Sample, a copy-pastable example if possible```python import numpy as np import xarray as xr create time and time_bounds DataArrays for Jan-1850 and Feb-1850time_bounds_vals = np.array([[0.0, 31.0], [31.0, 59.0]]) time_vals = time_bounds_vals.mean(axis=1) time_var = xr.DataArray(time_vals, dims='time', coords={'time':time_vals}) time_bounds_var = xr.DataArray(time_bounds_vals, dims=('time', 'd2'), coords={'time':time_vals}) create Dataset of time and time_boundsds = xr.Dataset(coords={'time':time_var}, data_vars={'time_bounds':time_bounds_var}) ds.time.attrs = {'bounds':'time_bounds', 'calendar':'noleap', 'units':'days since 1850-01-01'} write Jan-1850 values to fileds.isel(time=slice(0,1)).to_netcdf('Jan-1850.nc', unlimited_dims='time') write Feb-1850 values to fileds.isel(time=slice(1,2)).to_netcdf('Feb-1850.nc', unlimited_dims='time') use open_mfdataset to read in files, combining into 1 Datasetdecode_times = True decode_cf = True ds = xr.open_mfdataset(['Jan-1850.nc', 'Feb-1850.nc'], decode_cf=decode_cf, decode_times=decode_times) write combined Dataset outds.to_netcdf('JanFeb-1850.nc', unlimited_dims='time') ``` Problem descriptionThe above code initially creates 2 netCDF files, for Jan-1850 and Feb-1850, that have the variables time = 0, 708 ; time_bounds =
0, 31,
31, 59 ;
}
The final call to While the change to This inconsistency goes away if either of The inconsistency also goes away if I think that the desired behavior is to either not apply the units and type transformations to
INSTALLED VERSIONS
------------------
commit: None
python: 3.6.8 |Anaconda, Inc.| (default, Dec 30 2018, 01:22:34)
[GCC 7.3.0]
python-bits: 64
OS: Linux
OS-release: 3.12.62-60.64.8-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.4
libnetcdf: 4.6.2
xarray: 0.12.1
pandas: 0.24.2
numpy: 1.16.2
scipy: 1.2.1
netCDF4: 1.4.2
pydap: None
h5netcdf: None
h5py: None
Nio: None
zarr: None
cftime: 1.0.3.4
nc_time_axis: None
PseudonetCDF: None
rasterio: None
cfgrib: None
iris: None
bottleneck: None
dask: 1.1.5
distributed: 1.26.1
matplotlib: 3.0.3
cartopy: None
seaborn: None
setuptools: 40.8.0
pip: 19.0.3
conda: None
pytest: 4.3.1
IPython: 7.4.0
sphinx: None
|
{ "url": "https://api.github.com/repos/pydata/xarray/issues/2921/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
completed | 13221727 | issue |