我试图将 netCDF 文件中的时间单位转换为正确的格式,但是,我得到了错误的输出。
我正在使用的数据的时间格式如下:
1 dimensions:
time Size:193458 *** is unlimited ***
units: seconds since 1970-1-1 00:00:00
Run Code Online (Sandbox Code Playgroud)
我使用包中的函数ncdf.tools来提取时间并将其转换为日期以进行时间序列分类,但得到了错误的结果:
convertDateNcdf2R(id_579$dim$time$vals, units="seconds")
[75] "1846-07-03 05:04:51 UTC"
[76] "1846-07-03 05:05:01 UTC"
[77] "1846-07-03 05:05:06 UTC"
[78] "1846-07-03 05:05:11 UTC"
[79] "1846-07-03 05:05:16 UTC"
Run Code Online (Sandbox Code Playgroud)
该日期不应超过 1970 年。是否有更好的替代方案?
创建这个的函数是:
convertDateNcdf2R = function(
##title<< Convert netCDF time vector to POSIXct R date object
time.source ##<< numeric vector or netCDF connection: either a number of time units since
## origin or a netCDF file connection, …Run Code Online (Sandbox Code Playgroud)