home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 586978341

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/3739#issuecomment-586978341 https://api.github.com/repos/pydata/xarray/issues/3739 586978341 MDEyOklzc3VlQ29tbWVudDU4Njk3ODM0MQ== 10194086 2020-02-17T12:48:55Z 2020-02-17T12:48:55Z MEMBER

The following works (using assign_coords() instead of time.values=). I think you also forgot a str in date_range.

```python import numpy as np import xarray as xr import pandas as pd

files = ['ds_1.nc', 'ds_2.nc']

ds_test = xr.open_mfdataset(files, combine='nested', concat_dim='time', decode_cf=False) yr = 1988 # year dates = pd.date_range(start=str(yr), end=str(yr+1), freq='6H', closed='left') ds_test.assign_coords(time=dates[:2]) ds_test.time.encoding['units'] = "seconds since 1970-01-01 00:00:00" ds_test.time.encoding['calendar'] = "proleptic_gregorian" ds_test.to_netcdf('ds_1_2.nc')

```

The following works as well: python ds_test = xr.open_mfdataset(files, combine='nested', concat_dim='time') ds_test.time.encoding['units'] = "seconds since 1970-01-01 00:00:00" ds_test.to_netcdf('ds_1_2.nc')


However, what does indeed not work is the following

python ds_test = xr.open_mfdataset(files, combine='nested', concat_dim='time') ds_test.time.attrs['units'] = "seconds since 1970-01-01 00:00:00" ds_test.to_netcdf('ds_1_2.nc') which I don't entirely understand, because ds_test.time.encoding is empty. So maybe there is an encoding hidden somewhere, but I couldn't find it.

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