3

I am using xarray to work with gridded data and the coordinates latitude and longitude are 2dimensional arrays. It is quite similar to on of the tutorial datasets coming along with xarray.

ds = xarray.tutorial.open_dataset('rasm').load() 

Now I want to use the sel feature to access data from specific points.

ds.sel(yc=50, xc=50, method='nearest') 

In this example DataArray the coordinates xc and yc are no dimensions, so It is necessary to define them as an index. Does any one know how to do this?

1 Answer 1

3

Unfortunately, this is not currently possible. The reasons why (and path forward) are detailed in this GitHub issue: https://github.com/pydata/xarray/issues/475.

There are various work arounds available though. You may try using the groupby_bins method (e.g. http://xarray.pydata.org/en/stable/examples/multidimensional-coords.html).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.