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?
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With