I have an xarray.Dataset that looks like this, which is available here: https://psl.noaa.gov/thredds/dodsC/Datasets/NARR/Dailies/monolevel/acpcp.1979.nc:
<xarray.Dataset>
Dimensions: (time: 365, y: 277, x: 349, nbnds: 2)
Coordinates:
* time (time) datetime64[ns] 1979-01-01 ... 1979-12-31
* y (y) float32 0.0 3.246e+04 ... 8.927e+06 8.96e+06
* x (x) float32 0.0 3.246e+04 ... 1.126e+07 1.13e+07
lat (y, x) float32 1.0 1.104 1.208 ... 46.93 46.64 46.35
lon (y, x) float32 -145.5 -145.3 -145.1 ... -2.644 -2.57
Dimensions without coordinates: nbnds
Data variables:
Lambert_Conformal int32 ...
time_bnds (time, nbnds) float64 ...
acpcp (time, y, x) float32 ...
Attributes: (12/17)
Conventions: CF-1.2
centerlat: 50.0
centerlon: -107.0
comments:
institution: National Centers for Environmental Predi...
latcorners: [ 1.000001 0.897945 46.3544 46.63433 ]
... ...
history: created Mon Mar 21 17:56:47 MDT 2016 by ...
dataset_title: NCEP North American Regional Reanalysis ...
references: https://www.esrl.noaa.gov/psd/data/gridd...
source: http://www.emc.ncep.noaa.gov/mmb/rreanl/...
_NCProperties: version=2,netcdf=4.6.3,hdf5=1.10.5
DODS_EXTRA.Unlimited_Dimension: time
And I want to be able to select a given point using .sel based on the lat and lon coordinates like:
ds.sel(lat=point_lat, lon=point_lon, method='nearest')
But I get KeyError: 'no index found for coordinate lat'. I think this makes sense because lat is a coordinate but not a dimension.
So, what would be the best way to be able to use .sel in this case - is there a way to simply add lat and lon to the set of dimensions?