dl.meteo
dl.meteo

Reputation: 1766

xarray select on 2 dimensional coordinates

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?

Upvotes: 3

Views: 1651

Answers (1)

jhamman
jhamman

Reputation: 6434

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).

Upvotes: 3

Related Questions