将坐标分配给没有坐标的 Xarray 数据集

发布于 2025-01-16 12:13:16 字数 785 浏览 3 评论 0原文

我有一个 netcdf,我想按坐标进行切片,但是当我打开它时,数据集似乎没有任何关联的坐标。它有尺寸和纬度/经度变量,但有任何坐标,所以它看起来像这样:

<xarray.Dataset>
Dimensions:             (y: 10980, x: 10980)
Dimensions without coordinates: y, x
Data variables: (12/20)
    lon                 (y, x) float32 ...
    lat                 (y, x) float32 ...

但我需要这样的东西:

<xarray.Dataset>
Dimensions:              (x: 7861, y: 7981)
Coordinates:
  * x                    (x) float64 1.992e+05 1.992e+05 ... 4.35e+05 4.35e+05
  * y                    (y) float64 4.586e+06 4.586e+06 ... 4.347e+06 4.347e+06
Data variables: (12/15)
    lon                  (y, x) float32 ...
    lat                  (y, x) float32 ...

我无法上传 netcdf 文件,因为它们非常重,对此感到抱歉。

任何了解如何做到这一点的人都将非常感激!

I have a netcdf that I want to slice by coordinates, but when I open it, the dataset appears not to have any coordinates associated. It has dimmensions and lat/lon variables, but any coordinates, so it looks like this:

<xarray.Dataset>
Dimensions:             (y: 10980, x: 10980)
Dimensions without coordinates: y, x
Data variables: (12/20)
    lon                 (y, x) float32 ...
    lat                 (y, x) float32 ...

But I need something like this:

<xarray.Dataset>
Dimensions:              (x: 7861, y: 7981)
Coordinates:
  * x                    (x) float64 1.992e+05 1.992e+05 ... 4.35e+05 4.35e+05
  * y                    (y) float64 4.586e+06 4.586e+06 ... 4.347e+06 4.347e+06
Data variables: (12/15)
    lon                  (y, x) float32 ...
    lat                  (y, x) float32 ...

I cannot upload the netcdf files as they're extremely heavy, sorry about that.

Any grasp of how it can possibly be done would be very appreciated!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文