{"action":"created","issue":{"url":"https://api.github.com/repos/JiaweiZhuang/xESMF/issues/24","repository_url":"https://api.github.com/repos/JiaweiZhuang/xESMF","labels_url":"https://api.github.com/repos/JiaweiZhuang/xESMF/issues/24/labels{/name}","comments_url":"https://api.github.com/repos/JiaweiZhuang/xESMF/issues/24/comments","events_url":"https://api.github.com/repos/JiaweiZhuang/xESMF/issues/24/events","html_url":"https://github.com/JiaweiZhuang/xESMF/issues/24","id":340829407,"node_id":"MDU6SXNzdWUzNDA4Mjk0MDc=","number":24,"title":"Comparison with xarray's built-in interp()","user":{"login":"JiaweiZhuang","id":25473287,"node_id":"MDQ6VXNlcjI1NDczMjg3","avatar_url":"https://avatars1.githubusercontent.com/u/25473287?v=4","gravatar_id":"","url":"https://api.github.com/users/JiaweiZhuang","html_url":"https://github.com/JiaweiZhuang","followers_url":"https://api.github.com/users/JiaweiZhuang/followers","following_url":"https://api.github.com/users/JiaweiZhuang/following{/other_user}","gists_url":"https://api.github.com/users/JiaweiZhuang/gists{/gist_id}","starred_url":"https://api.github.com/users/JiaweiZhuang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JiaweiZhuang/subscriptions","organizations_url":"https://api.github.com/users/JiaweiZhuang/orgs","repos_url":"https://api.github.com/users/JiaweiZhuang/repos","events_url":"https://api.github.com/users/JiaweiZhuang/events{/privacy}","received_events_url":"https://api.github.com/users/JiaweiZhuang/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-07-12T23:13:59Z","updated_at":"2018-07-13T17:53:13Z","closed_at":null,"author_association":"OWNER","body":"Recently realized that xarray has [a nice new interpolation module](http://xarray.pydata.org/en/stable/interpolation.html) added by @crusaderky and @fujiisoup in pydata/xarray#2079 (also cc @shoyer, @rabernat).\r\n\r\nIt does have some overlap with xESMF (fortunately not too much), so I think it would be necessary to:\r\n- Compare their advantages & limitations\r\n- Identify their proper use cases \r\n- Better define the development roadmap and avoid duplication of effort\r\n\r\n`interp()` wraps `scipy.interpolate`; while xESMF wraps ESMPy's regridding functionality. The subtle difference between \"interpolation\" and \"regridding\" is that, the former often refers to traditional 1D interpolation (sometime N-D), mostly in Cartesian space; while the latter specifically means geospatial data on Earth's sphere.\r\n\r\nI personally think `interp()` is a great fit for:\r\n- Interpolation over 1D coordinate (e.g. vertical layers, time). I've been using Scipy for vertical interpolation, too. ESMPy does support [3D grid](http://www.earthsystemmodeling.org/esmf_releases/last_built/esmpy_doc/html/examples.html#create-a-3d-grid), but this is generally an overkill.\r\n- Data that are not on Earth's sphere. Say the output from any other physical models. ESMPy can actually [handle Cartesian coordinates](http://www.earthsystemmodeling.org/esmf_releases/last_built/esmpy_doc/html/CoordSys.html#ESMF.api.constants.CoordSys.CART), but everyone seems to only use spherical coordinates\r\n- High-dimensional regular grid (>=4D? rarely seen in Earth science but can occur in other physical sciences or machine learning). Seems like `interp`'s API tries to generalize to arbitrary dimensions, while xESMF is specific to horizontal regridding on the sphere.\r\n- Sampling over a trajectory via [\"Advanced Interpolation\"](http://xarray.pydata.org/en/stable/interpolation.html#advanced-interpolation). ESMPy does have a similar support via [LocStream¶](http://www.earthsystemmodeling.org/esmf_releases/last_built/esmpy_doc/html/locstream.html) but I personally don't use it. Glad that xarray has native support for this feature.\r\n\r\nFor geospatial regridding tasks, xESMF has some important strengths. Many already reviewed in the [docs](http://xesmf.readthedocs.io/en/latest/why.html), but more specifically: \r\n\r\n- Performance, especially with large data. xESMF reuses weights but `scipy.interpolate` does not.\r\n[This simple test](https://gist.github.com/JiaweiZhuang/b097f17bf85f9a0d34763d5cc9ce9b07) shows that xESMF is 16x faster than `interp()`, once the weights are computed (computing weights is also faster than `interp`). Indeed, this performance gap will be narrowed down on distributed cloud platforms, where the I/O time dominates (pangeo-data/pangeo#334). \r\n- Curvilinear grid (pydata/xarray#2281). This is the major reason why I wrote xESMF...\r\n- Conservative algorithm, to conserve the integral for density-like fields such as air density, heat flux, emission intensity... (This algorithm is used everywhere in Earth science but is never taught in numerical analysis classes. Scipy is basically \"everything in a numerical analysis textbook\", so unsurprisingly it has no conservative scheme.)\r\n\r\nIn short, `interp` is a general-purpose **interpolation** module; xESMF is a **geospatial regridding** package targeting at Earth science needs. Looks like their objectives can be distinguished. Should we consider merging some efforts? Or just perhaps let them evolve independently?"},"comment":{"url":"https://api.github.com/repos/JiaweiZhuang/xESMF/issues/comments/404906598","html_url":"https://github.com/JiaweiZhuang/xESMF/issues/24#issuecomment-404906598","issue_url":"https://api.github.com/repos/JiaweiZhuang/xESMF/issues/24","id":404906598,"node_id":"MDEyOklzc3VlQ29tbWVudDQwNDkwNjU5OA==","user":{"login":"JiaweiZhuang","id":25473287,"node_id":"MDQ6VXNlcjI1NDczMjg3","avatar_url":"https://avatars1.githubusercontent.com/u/25473287?v=4","gravatar_id":"","url":"https://api.github.com/users/JiaweiZhuang","html_url":"https://github.com/JiaweiZhuang","followers_url":"https://api.github.com/users/JiaweiZhuang/followers","following_url":"https://api.github.com/users/JiaweiZhuang/following{/other_user}","gists_url":"https://api.github.com/users/JiaweiZhuang/gists{/gist_id}","starred_url":"https://api.github.com/users/JiaweiZhuang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JiaweiZhuang/subscriptions","organizations_url":"https://api.github.com/users/JiaweiZhuang/orgs","repos_url":"https://api.github.com/users/JiaweiZhuang/repos","events_url":"https://api.github.com/users/JiaweiZhuang/events{/privacy}","received_events_url":"https://api.github.com/users/JiaweiZhuang/received_events","type":"User","site_admin":false},"created_at":"2018-07-13T17:53:13Z","updated_at":"2018-07-13T17:53:13Z","author_association":"OWNER","body":"@crusaderky Got it -- just realized that the actually PR is pydata/xarray#2104"}}
{"actor":{"display_login":"JiaweiZhuang"}}