【问题标题】:Using two dimensional coordinates for a time series in xarray [duplicate]在xarray中使用时间序列的二维坐标[重复]
【发布时间】: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


    【解决方案1】:

    刚刚看到有人问过这个问题(我之前没有找到):xarray select nearest lat/lon with multi-dimension coordinates

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-01-14
      • 1970-01-01
      • 2021-12-17
      • 2019-06-28
      • 1970-01-01
      • 2018-01-11
      • 1970-01-01
      • 2020-09-14
      相关资源
      最近更新 更多