迄今为止在 netCDF4 中的“proleptic_gregorian”

问题描述

我有一个带有时间变量的 netcdf 文件,它表示为“proleptic_gregorian”。我想使用 num2date 函数将其转换为公历日期。

我正在尝试这个

import netCDF4 as nc
from netCDF4 import num2date,date2num

#read in the file
ncfile_o = Dataset(input_netcdf_file,'r',format="NETCDF4")

这有变量:

odict_keys(['time','time_bnds','lon','lat','landCoverFrac'])

我现在将获取时间信息:

#time dimension
nctime = ncfile_o.variables['time'][:]
t_unit = ncfile_o.variables['time'].units   

t_cal = ncfile_o.variables['time'].calendar

此处 t_cal 是 'proleptic_gregorian' 而 t_unit 是'years since 1860-1-15 00:00:00'。 nctime 看起来像这样:

array([1.45698925,2.45698925,151.45698925,152.45698925)]

然后我试着把它变成这样的日期:

datevar = []

datevar.append(num2date(nctime,units = t_unit,calendar = t_cal))

但这失败了:

ValueError: unsupported time units

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...