{"action":"created","comment":{"url":"https://api.github.com/repos/pydata/xarray/pulls/comments/191643217","pull_request_review_id":124250814,"id":191643217,"diff_hunk":"@@ -895,10 +895,47 @@ def reindex(self, method=None, tolerance=None, copy=True, **indexers):\n             method=method, tolerance=tolerance, copy=copy, **indexers)\n         return self._from_temp_dataset(ds)\n \n+    def interp(self, method='linear', kwargs={}, assume_sorted=False,\n+               **coords):","path":"xarray/core/dataarray.py","position":null,"original_position":5,"commit_id":"21d4390ffc1ee9e5a12007c16df3bab2d8b5004b","original_commit_id":"c0d796a6e3860913bfa397581588bf5ffb313c2c","user":{"login":"fujiisoup","id":6815844,"avatar_url":"https://avatars2.githubusercontent.com/u/6815844?v=4","gravatar_id":"","url":"https://api.github.com/users/fujiisoup","html_url":"https://github.com/fujiisoup","followers_url":"https://api.github.com/users/fujiisoup/followers","following_url":"https://api.github.com/users/fujiisoup/following{/other_user}","gists_url":"https://api.github.com/users/fujiisoup/gists{/gist_id}","starred_url":"https://api.github.com/users/fujiisoup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fujiisoup/subscriptions","organizations_url":"https://api.github.com/users/fujiisoup/orgs","repos_url":"https://api.github.com/users/fujiisoup/repos","events_url":"https://api.github.com/users/fujiisoup/events{/privacy}","received_events_url":"https://api.github.com/users/fujiisoup/received_events","type":"User","site_admin":false},"body":"done","created_at":"2018-05-30T05:06:40Z","updated_at":"2018-05-30T05:06:40Z","html_url":"https://github.com/pydata/xarray/pull/2104#discussion_r191643217","pull_request_url":"https://api.github.com/repos/pydata/xarray/pulls/2104","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/pydata/xarray/pulls/comments/191643217"},"html":{"href":"https://github.com/pydata/xarray/pull/2104#discussion_r191643217"},"pull_request":{"href":"https://api.github.com/repos/pydata/xarray/pulls/2104"}},"in_reply_to_id":191303909},"pull_request":{"url":"https://api.github.com/repos/pydata/xarray/pulls/2104","id":185983977,"html_url":"https://github.com/pydata/xarray/pull/2104","diff_url":"https://github.com/pydata/xarray/pull/2104.diff","patch_url":"https://github.com/pydata/xarray/pull/2104.patch","issue_url":"https://api.github.com/repos/pydata/xarray/issues/2104","number":2104,"state":"open","locked":false,"title":"implement interp()","user":{"login":"fujiisoup","id":6815844,"avatar_url":"https://avatars2.githubusercontent.com/u/6815844?v=4","gravatar_id":"","url":"https://api.github.com/users/fujiisoup","html_url":"https://github.com/fujiisoup","followers_url":"https://api.github.com/users/fujiisoup/followers","following_url":"https://api.github.com/users/fujiisoup/following{/other_user}","gists_url":"https://api.github.com/users/fujiisoup/gists{/gist_id}","starred_url":"https://api.github.com/users/fujiisoup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fujiisoup/subscriptions","organizations_url":"https://api.github.com/users/fujiisoup/orgs","repos_url":"https://api.github.com/users/fujiisoup/repos","events_url":"https://api.github.com/users/fujiisoup/events{/privacy}","received_events_url":"https://api.github.com/users/fujiisoup/received_events","type":"User","site_admin":false},"body":" - [x] Closes #2079 (remove if there is no corresponding issue, which should only be the case for minor changes)\r\n - [x] Tests added (for all bug fixes or enhancements)\r\n - [x] Tests passed (for all non-documentation changes)\r\n - [x] Fully documented, including `whats-new.rst` for all changes and `api.rst` for new API (remove if this change should not be visible to users, e.g., if it is an internal clean-up, or if this is part of a larger project that will be documented later)\r\n\r\nI started working to add `interpolate_at` to xarray, as discussed in issue #2079 (but without caching).\r\n\r\nI think I need to take care of more edge cases, but before finishing up this PR, I want to discuss what the best API is.\r\n\r\nI would like to this method working similar to `isel`, which may support *vectorized* interpolation.\r\nCurrently, this works as follwos\r\n\r\n```python\r\nIn [1]: import numpy as np\r\n   ...: import xarray as xr\r\n   ...: \r\n   ...: da = xr.DataArray([0, 0.1, 0.2, 0.1], dims='x', coords={'x': [0, 1, 2, 3]})\r\n   ...: \r\n\r\nIn [2]: # simple linear interpolation\r\n   ...: da.interpolate_at(x=[0.5, 1.5])\r\n   ...: \r\nOut[2]: \r\n<xarray.DataArray (x: 2)>\r\narray([0.05, 0.15])\r\nCoordinates:\r\n  * x        (x) float64 0.5 1.5\r\n\r\nIn [3]: # with cubic spline interpolation\r\n   ...: da.interpolate_at(x=[0.5, 1.5], method='cubic')\r\n   ...: \r\nOut[3]: \r\n<xarray.DataArray (x: 2)>\r\narray([0.0375, 0.1625])\r\nCoordinates:\r\n  * x        (x) float64 0.5 1.5\r\n\r\nIn [4]: # interpolation at one single position\r\n   ...: da.interpolate_at(x=0.5)\r\n   ...: \r\nOut[4]: \r\n<xarray.DataArray ()>\r\narray(0.05)\r\nCoordinates:\r\n    x        float64 0.5\r\n\r\nIn [5]: # interpolation with broadcasting\r\n   ...: da.interpolate_at(x=xr.DataArray([[0.5, 1.0], [1.5, 2.0]], dims=['y', 'z']))\r\n   ...: \r\nOut[5]: \r\n<xarray.DataArray (y: 2, z: 2)>\r\narray([[0.05, 0.1 ],\r\n       [0.15, 0.2 ]])\r\nCoordinates:\r\n    x        (y, z) float64 0.5 1.0 1.5 2.0\r\nDimensions without coordinates: y, z\r\n\r\nIn [6]: da = xr.DataArray([[0, 0.1, 0.2], [1.0, 1.1, 1.2]], \r\n   ...:                   dims=['x', 'y'], \r\n   ...:                   coords={'x': [0, 1], 'y': [0, 10, 20]})\r\n   ...: \r\n\r\nIn [7]: # multidimensional interpolation\r\n   ...: da.interpolate_at(x=[0.5, 1.5], y=[5, 15])\r\n   ...: \r\nOut[7]: \r\n<xarray.DataArray (x: 2, y: 2)>\r\narray([[0.55, 0.65],\r\n       [ nan,  nan]])\r\nCoordinates:\r\n  * x        (x) float64 0.5 1.5\r\n  * y        (y) int64 5 15\r\n\r\nIn [8]: # multidimensional interpolation with broadcasting\r\n   ...: da.interpolate_at(x=xr.DataArray([0.5, 1.5], dims='z'), \r\n   ...:                   y=xr.DataArray([5, 15], dims='z'))\r\n   ...: \r\nOut[8]: \r\n<xarray.DataArray (z: 2)>\r\narray([0.55,  nan])\r\nCoordinates:\r\n    x        (z) float64 0.5 1.5\r\n    y        (z) int64 5 15\r\nDimensions without coordinates: z\r\n```\r\n\r\n#### Design question\r\n\r\n1. How many interpolate methods should we support?\r\n  Currently, I only implemented [scipy.interpolate.interp1d](https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.interp1d.html) for 1dimensional interpolation and [scipy.interpolate.RegularGridInterpolator](https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.RegularGridInterpolator.html) for multidimensional interpolation.\r\nI think 90% usecases are linear, but there are more methods in scipy.\r\n\r\n2. How do we handle `nan`?\r\n  Currently this raises ValueError if nan is present. It may be possible to carry out the interpolation with skipping nan, but in this case the performance would be significantly drops because it cannot be vectorized.\r\n\r\n3. Do we support interpolation along *dimension without coordinate*?\r\n  In that case, do we attach new coordinate to the object?\r\n\r\n4. How should we do if new coordinate has the dimensional coordinate for the dimension to be interpolated?\r\ne.g. in the following case, \r\n```python\r\nda = xr.DataArray([0, 0.1, 0.2, 0.1], dims='x', coords={'x': [0, 1, 2, 3]})\r\nrslt = da.interpolate_at(x=xr.DataArray([0.5, 1.5], dims=['x'], coords={'x': [1, 3]})\r\n```\r\nwhat would be `rslt['x']`?\r\n\r\nI appreciate any comments.","created_at":"2018-05-04T13:28:38Z","updated_at":"2018-05-30T05:06:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"43805f82c4b15853a69c254a1fdfeb33dc2f23e6","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":508507365,"url":"https://api.github.com/repos/pydata/xarray/labels/needs%20review","name":"needs review","color":"fbca04","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/pydata/xarray/pulls/2104/commits","review_comments_url":"https://api.github.com/repos/pydata/xarray/pulls/2104/comments","review_comment_url":"https://api.github.com/repos/pydata/xarray/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pydata/xarray/issues/2104/comments","statuses_url":"https://api.github.com/repos/pydata/xarray/statuses/21d4390ffc1ee9e5a12007c16df3bab2d8b5004b","head":{"label":"fujiisoup:interp_at","ref":"interp_at","sha":"21d4390ffc1ee9e5a12007c16df3bab2d8b5004b","user":{"login":"fujiisoup","id":6815844,"avatar_url":"https://avatars2.githubusercontent.com/u/6815844?v=4","gravatar_id":"","url":"https://api.github.com/users/fujiisoup","html_url":"https://github.com/fujiisoup","followers_url":"https://api.github.com/users/fujiisoup/followers","following_url":"https://api.github.com/users/fujiisoup/following{/other_user}","gists_url":"https://api.github.com/users/fujiisoup/gists{/gist_id}","starred_url":"https://api.github.com/users/fujiisoup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fujiisoup/subscriptions","organizations_url":"https://api.github.com/users/fujiisoup/orgs","repos_url":"https://api.github.com/users/fujiisoup/repos","events_url":"https://api.github.com/users/fujiisoup/events{/privacy}","received_events_url":"https://api.github.com/users/fujiisoup/received_events","type":"User","site_admin":false},"repo":{"id":82444894,"name":"xarray","full_name":"fujiisoup/xarray","owner":{"login":"fujiisoup","id":6815844,"avatar_url":"https://avatars2.githubusercontent.com/u/6815844?v=4","gravatar_id":"","url":"https://api.github.com/users/fujiisoup","html_url":"https://github.com/fujiisoup","followers_url":"https://api.github.com/users/fujiisoup/followers","following_url":"https://api.github.com/users/fujiisoup/following{/other_user}","gists_url":"https://api.github.com/users/fujiisoup/gists{/gist_id}","starred_url":"https://api.github.com/users/fujiisoup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fujiisoup/subscriptions","organizations_url":"https://api.github.com/users/fujiisoup/orgs","repos_url":"https://api.github.com/users/fujiisoup/repos","events_url":"https://api.github.com/users/fujiisoup/events{/privacy}","received_events_url":"https://api.github.com/users/fujiisoup/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/fujiisoup/xarray","description":"N-D labeled arrays and datasets in Python","fork":true,"url":"https://api.github.com/repos/fujiisoup/xarray","forks_url":"https://api.github.com/repos/fujiisoup/xarray/forks","keys_url":"https://api.github.com/repos/fujiisoup/xarray/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fujiisoup/xarray/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fujiisoup/xarray/teams","hooks_url":"https://api.github.com/repos/fujiisoup/xarray/hooks","issue_events_url":"https://api.github.com/repos/fujiisoup/xarray/issues/events{/number}","events_url":"https://api.github.com/repos/fujiisoup/xarray/events","assignees_url":"https://api.github.com/repos/fujiisoup/xarray/assignees{/user}","branches_url":"https://api.github.com/repos/fujiisoup/xarray/branches{/branch}","tags_url":"https://api.github.com/repos/fujiisoup/xarray/tags","blobs_url":"https://api.github.com/repos/fujiisoup/xarray/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fujiisoup/xarray/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fujiisoup/xarray/git/refs{/sha}","trees_url":"https://api.github.com/repos/fujiisoup/xarray/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fujiisoup/xarray/statuses/{sha}","languages_url":"https://api.github.com/repos/fujiisoup/xarray/languages","stargazers_url":"https://api.github.com/repos/fujiisoup/xarray/stargazers","contributors_url":"https://api.github.com/repos/fujiisoup/xarray/contributors","subscribers_url":"https://api.github.com/repos/fujiisoup/xarray/subscribers","subscription_url":"https://api.github.com/repos/fujiisoup/xarray/subscription","commits_url":"https://api.github.com/repos/fujiisoup/xarray/commits{/sha}","git_commits_url":"https://api.github.com/repos/fujiisoup/xarray/git/commits{/sha}","comments_url":"https://api.github.com/repos/fujiisoup/xarray/comments{/number}","issue_comment_url":"https://api.github.com/repos/fujiisoup/xarray/issues/comments{/number}","contents_url":"https://api.github.com/repos/fujiisoup/xarray/contents/{+path}","compare_url":"https://api.github.com/repos/fujiisoup/xarray/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fujiisoup/xarray/merges","archive_url":"https://api.github.com/repos/fujiisoup/xarray/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fujiisoup/xarray/downloads","issues_url":"https://api.github.com/repos/fujiisoup/xarray/issues{/number}","pulls_url":"https://api.github.com/repos/fujiisoup/xarray/pulls{/number}","milestones_url":"https://api.github.com/repos/fujiisoup/xarray/milestones{/number}","notifications_url":"https://api.github.com/repos/fujiisoup/xarray/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fujiisoup/xarray/labels{/name}","releases_url":"https://api.github.com/repos/fujiisoup/xarray/releases{/id}","deployments_url":"https://api.github.com/repos/fujiisoup/xarray/deployments","created_at":"2017-02-19T08:15:17Z","updated_at":"2017-02-19T08:15:19Z","pushed_at":"2018-05-30T04:59:07Z","git_url":"git://github.com/fujiisoup/xarray.git","ssh_url":"git@github.com:fujiisoup/xarray.git","clone_url":"https://github.com/fujiisoup/xarray.git","svn_url":"https://github.com/fujiisoup/xarray","homepage":"http://xarray.pydata.org","size":13137,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"pydata:master","ref":"master","sha":"5ddfee6b194f8bdce8bb42cddfabe3e1c142ef16","user":{"login":"pydata","id":1284191,"avatar_url":"https://avatars0.githubusercontent.com/u/1284191?v=4","gravatar_id":"","url":"https://api.github.com/users/pydata","html_url":"https://github.com/pydata","followers_url":"https://api.github.com/users/pydata/followers","following_url":"https://api.github.com/users/pydata/following{/other_user}","gists_url":"https://api.github.com/users/pydata/gists{/gist_id}","starred_url":"https://api.github.com/users/pydata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pydata/subscriptions","organizations_url":"https://api.github.com/users/pydata/orgs","repos_url":"https://api.github.com/users/pydata/repos","events_url":"https://api.github.com/users/pydata/events{/privacy}","received_events_url":"https://api.github.com/users/pydata/received_events","type":"Organization","site_admin":false},"repo":{"id":13221727,"name":"xarray","full_name":"pydata/xarray","owner":{"login":"pydata","id":1284191,"avatar_url":"https://avatars0.githubusercontent.com/u/1284191?v=4","gravatar_id":"","url":"https://api.github.com/users/pydata","html_url":"https://github.com/pydata","followers_url":"https://api.github.com/users/pydata/followers","following_url":"https://api.github.com/users/pydata/following{/other_user}","gists_url":"https://api.github.com/users/pydata/gists{/gist_id}","starred_url":"https://api.github.com/users/pydata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pydata/subscriptions","organizations_url":"https://api.github.com/users/pydata/orgs","repos_url":"https://api.github.com/users/pydata/repos","events_url":"https://api.github.com/users/pydata/events{/privacy}","received_events_url":"https://api.github.com/users/pydata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pydata/xarray","description":"N-D labeled arrays and datasets in Python","fork":false,"url":"https://api.github.com/repos/pydata/xarray","forks_url":"https://api.github.com/repos/pydata/xarray/forks","keys_url":"https://api.github.com/repos/pydata/xarray/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pydata/xarray/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pydata/xarray/teams","hooks_url":"https://api.github.com/repos/pydata/xarray/hooks","issue_events_url":"https://api.github.com/repos/pydata/xarray/issues/events{/number}","events_url":"https://api.github.com/repos/pydata/xarray/events","assignees_url":"https://api.github.com/repos/pydata/xarray/assignees{/user}","branches_url":"https://api.github.com/repos/pydata/xarray/branches{/branch}","tags_url":"https://api.github.com/repos/pydata/xarray/tags","blobs_url":"https://api.github.com/repos/pydata/xarray/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pydata/xarray/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pydata/xarray/git/refs{/sha}","trees_url":"https://api.github.com/repos/pydata/xarray/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pydata/xarray/statuses/{sha}","languages_url":"https://api.github.com/repos/pydata/xarray/languages","stargazers_url":"https://api.github.com/repos/pydata/xarray/stargazers","contributors_url":"https://api.github.com/repos/pydata/xarray/contributors","subscribers_url":"https://api.github.com/repos/pydata/xarray/subscribers","subscription_url":"https://api.github.com/repos/pydata/xarray/subscription","commits_url":"https://api.github.com/repos/pydata/xarray/commits{/sha}","git_commits_url":"https://api.github.com/repos/pydata/xarray/git/commits{/sha}","comments_url":"https://api.github.com/repos/pydata/xarray/comments{/number}","issue_comment_url":"https://api.github.com/repos/pydata/xarray/issues/comments{/number}","contents_url":"https://api.github.com/repos/pydata/xarray/contents/{+path}","compare_url":"https://api.github.com/repos/pydata/xarray/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pydata/xarray/merges","archive_url":"https://api.github.com/repos/pydata/xarray/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pydata/xarray/downloads","issues_url":"https://api.github.com/repos/pydata/xarray/issues{/number}","pulls_url":"https://api.github.com/repos/pydata/xarray/pulls{/number}","milestones_url":"https://api.github.com/repos/pydata/xarray/milestones{/number}","notifications_url":"https://api.github.com/repos/pydata/xarray/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pydata/xarray/labels{/name}","releases_url":"https://api.github.com/repos/pydata/xarray/releases{/id}","deployments_url":"https://api.github.com/repos/pydata/xarray/deployments","created_at":"2013-09-30T17:21:10Z","updated_at":"2018-05-29T04:43:53Z","pushed_at":"2018-05-30T04:59:09Z","git_url":"git://github.com/pydata/xarray.git","ssh_url":"git@github.com:pydata/xarray.git","clone_url":"https://github.com/pydata/xarray.git","svn_url":"https://github.com/pydata/xarray","homepage":"http://xarray.pydata.org","size":12391,"stargazers_count":826,"watchers_count":826,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":256,"mirror_url":null,"archived":false,"open_issues_count":467,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":256,"open_issues":467,"watchers":826,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pydata/xarray/pulls/2104"},"html":{"href":"https://github.com/pydata/xarray/pull/2104"},"issue":{"href":"https://api.github.com/repos/pydata/xarray/issues/2104"},"comments":{"href":"https://api.github.com/repos/pydata/xarray/issues/2104/comments"},"review_comments":{"href":"https://api.github.com/repos/pydata/xarray/pulls/2104/comments"},"review_comment":{"href":"https://api.github.com/repos/pydata/xarray/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pydata/xarray/pulls/2104/commits"},"statuses":{"href":"https://api.github.com/repos/pydata/xarray/statuses/21d4390ffc1ee9e5a12007c16df3bab2d8b5004b"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"fujiisoup"}}