{"action":"created","issue":{"url":"https://api.github.com/repos/pydata/xarray/issues/2547","repository_url":"https://api.github.com/repos/pydata/xarray","labels_url":"https://api.github.com/repos/pydata/xarray/issues/2547/labels{/name}","comments_url":"https://api.github.com/repos/pydata/xarray/issues/2547/comments","events_url":"https://api.github.com/repos/pydata/xarray/issues/2547/events","html_url":"https://github.com/pydata/xarray/issues/2547","id":377947810,"node_id":"MDU6SXNzdWUzNzc5NDc4MTA=","number":2547,"title":"How do I copy my array forwards in time?","user":{"login":"tommylees112","id":21049064,"node_id":"MDQ6VXNlcjIxMDQ5MDY0","avatar_url":"https://avatars1.githubusercontent.com/u/21049064?v=4","gravatar_id":"","url":"https://api.github.com/users/tommylees112","html_url":"https://github.com/tommylees112","followers_url":"https://api.github.com/users/tommylees112/followers","following_url":"https://api.github.com/users/tommylees112/following{/other_user}","gists_url":"https://api.github.com/users/tommylees112/gists{/gist_id}","starred_url":"https://api.github.com/users/tommylees112/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tommylees112/subscriptions","organizations_url":"https://api.github.com/users/tommylees112/orgs","repos_url":"https://api.github.com/users/tommylees112/repos","events_url":"https://api.github.com/users/tommylees112/events{/privacy}","received_events_url":"https://api.github.com/users/tommylees112/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":9,"created_at":"2018-11-06T17:12:00Z","updated_at":"2018-11-07T16:36:09Z","closed_at":null,"author_association":"NONE","body":"I have this `xr.Dataset`:\r\n```\r\n<xarray.Dataset>\r\nDimensions:    (time: 1, x: 200, y: 200)\r\nCoordinates:\r\n  * time       (time) float64 9.505e+17\r\nDimensions without coordinates: x, y\r\nData variables:\r\n    Rg         (time, y, x) float32 ...\r\n    latitude   (y, x) float64 ...\r\n    longitude  (y, x) float64 ...\r\n    time       datetime64[ns] 2000-02-14\r\nAttributes:\r\n    Conventions:     CF-1.0\r\n    content:         HARMONIZED WORLD SOIL DATABASE; first it was aggregated ...\r\n    scaling_factor:  20\r\n```\r\n\r\nI want to copy it through time, adding the time dimension at a given daterange \r\n\r\nSomething like this:\r\n```python\r\ntimes = pd.date_range('2000-01-01', '2000-12-31', name='time')\r\n\r\nds.time = times[0]\r\n\r\nall_data = [ds]\r\nfor i, time in enumerate(times[1:]):\r\n    ds_t1 = ds.copy()\r\n    ds_t1.time = time\r\n\r\n    all_data.append(ds)\r\n    ds = ds_t1\r\n\r\nds = xr.concat(all_data)\r\n```\r\n\r\nSo I should have output data like:\r\n```\r\n<xarray.Dataset>\r\nDimensions:    (time: 366, x: 200, y: 200)\r\nCoordinates:\r\n  * time       (time) float64 ...\r\nDimensions without coordinates: x, y\r\nData variables:\r\n    Rg         (time, y, x) float32 ...\r\n    latitude   (y, x) float64 ...\r\n    longitude  (y, x) float64 ...\r\n    time       datetime64[ns] 2000-02-14\r\nAttributes:\r\n    Conventions:     CF-1.0\r\n    content:         HARMONIZED WORLD SOIL DATABASE; first it was aggregated ...\r\n    scaling_factor:  20\r\n```"},"comment":{"url":"https://api.github.com/repos/pydata/xarray/issues/comments/436688702","html_url":"https://github.com/pydata/xarray/issues/2547#issuecomment-436688702","issue_url":"https://api.github.com/repos/pydata/xarray/issues/2547","id":436688702,"node_id":"MDEyOklzc3VlQ29tbWVudDQzNjY4ODcwMg==","user":{"login":"tommylees112","id":21049064,"node_id":"MDQ6VXNlcjIxMDQ5MDY0","avatar_url":"https://avatars1.githubusercontent.com/u/21049064?v=4","gravatar_id":"","url":"https://api.github.com/users/tommylees112","html_url":"https://github.com/tommylees112","followers_url":"https://api.github.com/users/tommylees112/followers","following_url":"https://api.github.com/users/tommylees112/following{/other_user}","gists_url":"https://api.github.com/users/tommylees112/gists{/gist_id}","starred_url":"https://api.github.com/users/tommylees112/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tommylees112/subscriptions","organizations_url":"https://api.github.com/users/tommylees112/orgs","repos_url":"https://api.github.com/users/tommylees112/repos","events_url":"https://api.github.com/users/tommylees112/events{/privacy}","received_events_url":"https://api.github.com/users/tommylees112/received_events","type":"User","site_admin":false},"created_at":"2018-11-07T16:36:09Z","updated_at":"2018-11-07T16:36:09Z","author_association":"NONE","body":"@spencerkclark Thanks very much that is awesome!\r\n\r\nOne final Q: How do I set the `fill_value` not to `nan` but to `-1` (this is what I need for the Land Surface Model)?\r\n\r\n### The current output of `ncdump -h Rg_dummy.nc` is:\r\n```\r\n...\r\nvariables:\r\n\tdouble time(time) ;\r\n\t\ttime:_FillValue = NaN ;\r\n\t\ttime:standard_name = \"time\" ;\r\n\t\ttime:units = \"day as %Y%m%d.%f\" ;\r\n\t\ttime:calendar = \"proleptic_gregorian\" ;\r\n\tshort Rg(time, y, x) ;\r\n\t\tRg:_FillValue = NaN ;\r\n\t\tRg:long_name = \"HWSD sub sum content\" ;\r\n\t\tRg:units = \"percent wt\" ;\r\n\t\tRg:valid_range = 97., 103. ;\r\n\tdouble latitude(y, x) ;\r\n\t\tlatitude:_FillValue = -99999. ;\r\n\tdouble longitude(y, x) ;\r\n\t\tlongitude:_FillValue = -99999. ;\r\n```\r\n\r\n### What I want is:\r\n`ncdump -h Rg_dummy.nc`\r\n```\r\n...\r\nvariables:\r\n\tdouble time(time) ;\r\n\t\ttime:_FillValue = -1s ;\r\n\t\ttime:standard_name = \"time\" ;\r\n\t\ttime:units = \"day as %Y%m%d.%f\" ;\r\n\t\ttime:calendar = \"proleptic_gregorian\" ;\r\n\tshort Rg(time, y, x) ;\r\n\t\tRg:_FillValue = -1s ;\r\n\t\tRg:long_name = \"HWSD sub sum content\" ;\r\n\t\tRg:units = \"percent wt\" ;\r\n\t\tRg:valid_range = 97., 103. ;\r\n\tdouble latitude(y, x) ;\r\n\t\tlatitude:_FillValue = -99999. ;\r\n\tdouble longitude(y, x) ;\r\n\t\tlongitude:_FillValue = -99999. ;\r\n```\r\n\r\nI want to do something like:\r\n```\r\nds2.to_netcdf(filename, set_fill_value=-1)\r\n```\r\n\r\nThank you so much for helping me out with xarray. It's crazy powerful. It's also just very big!"}}
{"actor":{"display_login":"tommylees112"}}