{"action":"created","issue":{"url":"https://api.github.com/repos/xgcm/xmitgcm/issues/76","repository_url":"https://api.github.com/repos/xgcm/xmitgcm","labels_url":"https://api.github.com/repos/xgcm/xmitgcm/issues/76/labels{/name}","comments_url":"https://api.github.com/repos/xgcm/xmitgcm/issues/76/comments","events_url":"https://api.github.com/repos/xgcm/xmitgcm/issues/76/events","html_url":"https://github.com/xgcm/xmitgcm/issues/76","id":304937025,"number":76,"title":"Time read as iter number and not seconds in Matlab only","user":{"login":"mmazloff","id":34174904,"avatar_url":"https://avatars0.githubusercontent.com/u/34174904?v=4","gravatar_id":"","url":"https://api.github.com/users/mmazloff","html_url":"https://github.com/mmazloff","followers_url":"https://api.github.com/users/mmazloff/followers","following_url":"https://api.github.com/users/mmazloff/following{/other_user}","gists_url":"https://api.github.com/users/mmazloff/gists{/gist_id}","starred_url":"https://api.github.com/users/mmazloff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mmazloff/subscriptions","organizations_url":"https://api.github.com/users/mmazloff/orgs","repos_url":"https://api.github.com/users/mmazloff/repos","events_url":"https://api.github.com/users/mmazloff/events{/privacy}","received_events_url":"https://api.github.com/users/mmazloff/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-03-13T21:11:00Z","updated_at":"2018-03-13T23:53:33Z","closed_at":null,"author_association":"NONE","body":"Hello\r\n\r\nI am writing variables to netcdf and finding that the time is being read in Matlab as the iteration number instead of time in seconds. \r\n\r\nHere is what I do\r\n\r\nfrom xmitgcm import open_mdsdataset\r\ngrid_dir = 'BIN2/'\r\ndata_dir = 'OUTPUT/'\r\nds = open_mdsdataset(data_dir, grid_dir, iters='all', delta_t=3600, ignore_unknown_vars=False, prefix=['diag_state'], ref_date=\"2008-1-1 0:0:0\",geometry='sphericalpolar')\r\n\r\n print(ds)\r\n<xarray.Dataset>\r\nDimensions:  (XC: 1080, XG: 1080, YC: 315, YG: 315, Z: 52, Zl: 52, Zp1: 53, Zu: 52, time: 60)\r\nCoordinates:\r\n    iter     (time) int64 dask.array<shape=(60,), chunksize=(1,)>\r\n  * time     (time) datetime64[ns] 2008-01-31T10:00:00 2008-03-01T20:00:00 ...\r\n  * XC       (XC) float32 0.166667 0.5 0.833333 1.16667 1.5 1.83333 2.16667 ...\r\n  * YC       (YC) float32 -77.9652 -77.8956 -77.8255 -77.755 -77.6841 ...\r\n...\r\n    THETA    (time, Z, YC, XC) float32 dask.array<shape=(60, 52, 315, 1080), chunksize=(1, 52, 315, 1080)>\r\n\r\nds['THETA'].to_netcdf('Theta.nc')\r\n\r\nNote time is correct here:\r\nds.time\r\n<xarray.DataArray 'time' (time: 60)>\r\narray(['2008-01-31T10:00:00.000000000', '2008-03-01T20:00:00.000000000',\r\n       '2008-04-01T07:00:00.000000000', '2008-05-01T17:00:00.000000000',\r\n       '2008-06-01T03:00:00.000000000', '2008-07-01T13:00:00.000000000',\r\n       '2008-07-31T23:00:00.000000000', '2008-08-31T10:00:00.000000000',\r\n       '2008-09-30T20:00:00.000000000', '2008-10-31T06:00:00.000000000',\r\n...\r\n\r\nBut matlab shows\r\n ncdisp('Theta.nc')\r\nSource:\r\n             Theta.nc\r\nFormat:\r\n             netcdf4\r\nGlobal Attributes:\r\n             _NCProperties = 'version=1|netcdflibversion=4.4.1|hdf5libversion=1.8.17'\r\nDimensions:\r\n             time = 609\r\n             XC   = 1080\r\n             YC   = 315\r\n             Z    = 52\r\nVariables:\r\n     iter \r\n             Size:       609x1\r\n             Dimensions: time\r\n             Datatype:   int64\r\n             Attributes:\r\n                           long_name     = 'model timestep number'\r\n                           standard_name = 'timestep'\r\n     time \r\n             Size:       609x1\r\n             Dimensions: time\r\n             Datatype:   int64\r\n             Attributes:\r\n                           long_name     = 'Time'\r\n                           standard_name = 'time'\r\n                           axis          = 'T'\r\n                           units         = 'days since 2008-01-04 00:00:00'\r\n                           calendar      = 'proleptic_gregorian'\r\n\r\nand when I read this time gives iter:\r\n\r\nt = ncread('Theta.nc','time')'\r\n\r\nt =\r\n\r\n  Columns 1 through 8\r\n\r\n                    0                  730                 1461                 2191          ....  \r\n\r\n\r\nAny advice?\r\n\r\n\r\nThanks\r\nMatt\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/xgcm/xmitgcm/issues/comments/372858355","html_url":"https://github.com/xgcm/xmitgcm/issues/76#issuecomment-372858355","issue_url":"https://api.github.com/repos/xgcm/xmitgcm/issues/76","id":372858355,"user":{"login":"mmazloff","id":34174904,"avatar_url":"https://avatars0.githubusercontent.com/u/34174904?v=4","gravatar_id":"","url":"https://api.github.com/users/mmazloff","html_url":"https://github.com/mmazloff","followers_url":"https://api.github.com/users/mmazloff/followers","following_url":"https://api.github.com/users/mmazloff/following{/other_user}","gists_url":"https://api.github.com/users/mmazloff/gists{/gist_id}","starred_url":"https://api.github.com/users/mmazloff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mmazloff/subscriptions","organizations_url":"https://api.github.com/users/mmazloff/orgs","repos_url":"https://api.github.com/users/mmazloff/repos","events_url":"https://api.github.com/users/mmazloff/events{/privacy}","received_events_url":"https://api.github.com/users/mmazloff/received_events","type":"User","site_admin":false},"created_at":"2018-03-13T23:53:33Z","updated_at":"2018-03-13T23:53:33Z","author_association":"NONE","body":"A clue! If I only read one record it does write time as time!\r\n\r\n ds = open_mdsdataset(data_dir, grid_dir, iters='all', delta_t=3600, ignore_unknown_vars=False, prefix=['diag_state'], ref_date=\"2008-1-1 0:0:0\",geometry='sphericalpolar')\r\nds['THETA'].to_netcdf('/data/mmazloff/TEST.nc')\r\ntime = 0, 730, 1461, 2191, 2921, 3651, 4381, 5112, 5842, 6572, 7302, 8032, \r\n    8763, 9493, 10223, 10953, 11683, 12414, 13144, 13874, 14604, 15334, \r\n    16065, 16795, 17525, 18255, 18985, 19716, 20446, 21176, 21906, 22636, \r\n    23367, 24097, 24827, 25557, 26287, 27018, 27748, 28478, 29208, 29938, \r\n    30669, 31399, 32129, 32859, 33589, 34320, 35050, 35780, 36510, 37240, \r\n    37971, 38701, 39431, 40161, 40891, 41622, 42352, 43082 ;\r\n\r\nBUT\r\n\r\nds = open_mdsdataset(data_dir, grid_dir, iters=1460, delta_t=3600, ignore_unknown_vars=False, prefix=['diag_state'], ref_date=\"2008-1-1 0:0:0\",geometry='sphericalpolar')\r\n ds['THETA'].to_netcdf('/data/mmazloff/TEST.nc')\r\n time = 5256000 ;\r\n\r\nSo  iters='all' fails but  iters=1460 works"}}
{"actor":{"display_login":"mmazloff"}}