I have a netcdf file that has the following (example) variables:
latitude
longitude
temperature
The dimensions are in [x, y] (pixel coordinates) primarily because both the latitude and longitude are both 2-D arrays of an irregular grid.
I want to extract pixel values of temperature in eg. 53.55, 3.5 (lat/lon degree decimal coordinates). Typically, for a 1-D array of latitude/longitude, I would be able to use numpy.argmin() to find the index of both lat/lon and thus, the pixel coordinate for the temperature variable.
Alternatively, in xarray, I could use eg.
import xarray as xr
ds = open_dataset(some_file)
ds.close()
ds.temperature.sel(lat=53.55, lon=3.5, method='nearest')
Except my dimensions are now in (x, y). Perhaps due to an insufficient knowledge of the netcdf data format, but I have trouble coming up with ways to extract the data I need. How can I extract the pixel value I need? Let me know if I can clarify the question better.