小编Vig*_*ran的帖子

如何在使用 xarray 加载 NETCDF 文件时解码时间变量

我有一个 netcdf 文件,给出了从 1948 年到 2008 年的月降水值。时间变量的格式如下:

float time(time) ;
        time:units = "months since 1948-01-01 00:00:00" ;
        time:time_origin = "01-JAN-1948:00:00:00" ;
Run Code Online (Sandbox Code Playgroud)

当我尝试使用 Xarray 使用以下命令打开数据集时

ds=xr.open_dataset("C:/Users/vsri/Downloads/prcp_monthly_1948-2008.nc")
Run Code Online (Sandbox Code Playgroud)

我收到以下错误

ValueError: unable to decode time units 'months since 1948-01-01 00:00:00' with the default calendar. Try opening your dataset with decode_times=False.
Run Code Online (Sandbox Code Playgroud)

如果我使用 decode_Times=False 参数,则时间变量会分配一个浮点值(如下所示)

 Coordinates:
      * longitude  (longitude) float32 0.25 0.75 1.25 1.75 ... 358.75 359.25 359.75
      * latitude   (latitude) float32 -89.75 -89.25 -88.75 ... 88.75 89.25 89.75
      * z       (z) float32 0.0
      * time …
Run Code Online (Sandbox Code Playgroud)

datetime netcdf python-xarray

0
推荐指数
1
解决办法
1911
查看次数

标签 统计

datetime ×1

netcdf ×1

python-xarray ×1