使用R在NC文件中传输到日期的小时数
我尝试使用ncdf软件包读取NC数据,其中读取时间维度使用R在NC文件中传输到日期的小时数,r,date,R,Date,我尝试使用ncdf软件包读取NC数据,其中读取时间维度 ti<-get.var.ncdf(nc,varid="time") nc$dim$time$unit "hours since 1-1-1 00:00:0.0" ti您可以执行以下操作: hours <- 17645592 # e.g. this is the number of hours from 01-01-01 to 2014-01-01 DATE <- as.POSIXct(x='01-01-01',tz='G
ti<-get.var.ncdf(nc,varid="time")
nc$dim$time$unit
"hours since 1-1-1 00:00:0.0"
ti您可以执行以下操作:
hours <- 17645592 # e.g. this is the number of hours from 01-01-01 to 2014-01-01
DATE <- as.POSIXct(x='01-01-01',tz='GMT',format='%Y-%m-%d') + (hours*60*60)
# > DATE
#[1] "2014-01-01 GMT
hours如果你能知道1-1-1是什么时候开始的,那么就使用像as.POSIXct(“2001-01-01 00:00:00”,tz=“GMT”)+ti*3600这样的东西,没有人能猜到开始日期,尽管你经常会交叉检查以增加信心。