issues: 1552701403
This data as json
id | node_id | number | title | user | state | locked | assignee | milestone | comments | created_at | updated_at | closed_at | author_association | active_lock_reason | draft | pull_request | body | reactions | performed_via_github_app | state_reason | repo | type |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1552701403 | I_kwDOAMm_X85cjFfb | 7468 | Provide default APIs and functions for getting variable at a given location, based on some criteria / extrema conditions on other variables | 8382834 | open | 0 | 0 | 2023-01-23T08:35:43Z | 2023-01-23T08:35:43Z | CONTRIBUTOR | Is your feature request related to a problem?No, this is related to a need that comes regularly when working with netCDF files in geosciences. Describe the solution you'd likewhat is neededThere are many cases with netcdf files when one wants to find some location, or get variable(s) at some location, where the location is determined by a condition on some variables. A classical example, around which there are many stack overflow questions, online discussions, suggested "hacky" solution, snippets etc, available, is something like the following. Given a file that looks like this:
answer a question like:
I do not think there is a recommended, standard, simple / one liner to do this with xarray in general (in particular if the (latval, lonval) falls out of the discrete set of mesh nodes). This means that a there are plenty of ad hoc hacked solutions getting shared around to solve this. Having a default recommended way would likely help users quite a bit and save quite some work. the existing ways to solve the needAs soon as the TLAT and TLON are not "aligned" with the ni and nj coordinates (if they exactly match a mesh point, then likely some
There are many more examples of questions that revolve around this kind of "query", and the answers are usually ad-hoc, though a lot of the logics repeat themselves, which make me believe a general high quality / standard solution would be useful:
Also note that most of these answers use simple / relatively naive / inefficient algorithms, but I wonder if there are some examples of code that could be used to build this in an efficient way, see the discussions in:
It looks like there are some snippets available that can be use to do this more or less exactly, when the netcdf file follows some conventions: It looks like there is no dedicated / recommended / default xarray solution to do this though. It would be great if xarray could offer a (set of) well tested, well implemented, efficient way(s) to solve this kind of needs. I guess this is such a common need that providing a default solution with a default API, even if it is not optimal for all use cases, would be better than providing nothing at all and have users hack their own helper functions. what xarray could implementIt would be great if xarray could offer support for this built in. A few thoughts of how this could be done:
I wonder if thinking about a few APIs and agreeing on these would be helpful before implementing anything. Just for the sake of brainstorming, maybe some functions with this kind of "API pseudocode" on datasets could make sense / would be a nice standardization to offer to users? Any thoughts / ideas of better solution?
(note: for this last function, consider also providing a variant that performs interpolation outside of mesh points?) Maybe providing a few specializations for working with finding specific points in space would be useful? Like:
Describe alternatives you've consideredWriting my own small function, or re-using some snippet circulating on internet. Additional contextNo response |
{ "url": "https://api.github.com/repos/pydata/xarray/issues/7468/reactions", "total_count": 1, "+1": 1, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
13221727 | issue |