home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 1352337857

This data as json

html_url issue_url id node_id user created_at updated_at author_association body reactions performed_via_github_app issue
https://github.com/pydata/xarray/issues/7354#issuecomment-1352337857 https://api.github.com/repos/pydata/xarray/issues/7354 1352337857 IC_kwDOAMm_X85QmwnB 2443309 2022-12-14T23:04:58Z 2022-12-14T23:04:58Z MEMBER

I took a minute to look into this and think I understand what is going on. First, a little debugging:

python for name in [files[0], files[1], path]: print(name) ds = xr.open_zarr(name, decode_cf=False) print(' > time.attrs', ds.time.attrs) print(' > time.encoding', ds.time.encoding)

``` tmp_dir/2022-09-01T03:00:00.zarr.zip

time.attrs {'calendar': 'proleptic_gregorian', 'units': 'days since 2022-09-01 03:00:00'} time.encoding {'chunks': (1,), 'preferred_chunks': {'time': 1}, 'compressor': Blosc(cname='lz4', clevel=5, shuffle=SHUFFLE, blocksize=0), 'filters': None, 'dtype': dtype('int64')} tmp_dir/2022-09-01T04:00:00.zarr.zip time.attrs {'calendar': 'proleptic_gregorian', 'units': 'days since 2022-09-01 04:00:00'} time.encoding {'chunks': (1,), 'preferred_chunks': {'time': 1}, 'compressor': Blosc(cname='lz4', clevel=5, shuffle=SHUFFLE, blocksize=0), 'filters': None, 'dtype': dtype('int64')} tmp.zarr.zip time.attrs {'calendar': 'proleptic_gregorian', 'units': 'days since 2022-09-01'} time.encoding {'chunks': (1,), 'preferred_chunks': {'time': 1}, 'compressor': Blosc(cname='lz4', clevel=5, shuffle=SHUFFLE, blocksize=0), 'filters': None, 'dtype': dtype('int64')} ```

A few things that I noticed: - the dtype of the time variable is int64. - the units attr is days since ....

open_mfdataset tends to take the units of the first file and doesn't check if all the others agree. It also does not clear out the dtype encoding.

One quick solution here is that you could add

python del dataset['time'].encoding['units'] to the line right after your open_mfdataset call. You could also update the dtype of your time variable to be a float64.

{
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  1474785646
Powered by Datasette · Queries took 2.734ms · About: xarray-datasette