【发布时间】:2021-10-21 00:12:58
【问题描述】:
我目前正在处理 netcdf 文件。我想为某个位置绘制时间序列。 到目前为止我用过:
ds = xr.open_dataset('testing.nc')
lon_name = "lon"
lat_name = "lat"
time_name = "time"
point1 = {'x': 8.807176, 'y': 53.913996}
# Gets the closest point to the coordinates
df = ds.sel(lat=point1['y'], lon=point1['x'], method='nearest').to_dataframe()
这很好用,但现在我得到了一个使用二维坐标的数据集。 使用 info() 给了我这个:
xarray.Dataset {
dimensions:
ny = 536 ;
nx = 532 ;
variables:
datetime64[ns] time() ;
time:standard_name = time ;
float32 lat(ny, nx) ;
lat:units = degrees_north ;
lat:long_name = latitude ;
lat:standard_name = latitude ;
float32 lon(ny, nx) ;
lon:units = degrees_east ;
lon:long_name = longitude ;
lon:standard_name = longitude ;
那么我现在如何以最简单的方式提取我的数据?使用上面的代码给我“KeyError:'找不到坐标纬度的索引'”。 我选择的坐标在数据的边界内。我认为问题在于坐标现在是二维的。
【问题讨论】:
标签: python-xarray