使用R的Era-Interim NetCDF文件:错误的时间维度

时间:2016-10-22 14:17:37

标签: r time extraction netcdf

我已将ERA-Interim数据集中的温度数据(t2m)下载为NetCDF文件。从1979年1月1日到2016年7月31日,这些数据每天两次:

1 variables (excluding dimension variables):
        short t2m[longitude,latitude,time]   
            scale_factor: 0.00208082029268055
            add_offset: 258.514370966807
            _FillValue: -32767
            missing_value: -32767
            units: K
            long_name: 2 metre temperature

     3 dimensions:
        longitude  Size:480
            units: degrees_east
            long_name: longitude
        latitude  Size:241
            units: degrees_north
            long_name: latitude
        time  Size:27454   *** is unlimited ***
            units: hours since 1900-01-01 00:00:0.0
            long_name: time
            calendar: gregorian

我已经能够使用ncvar_get代码读取经度和纬度,但是当使用以下时间执行此操作时:

t <- ncvar_get(ncin, "time")
length(t) 
27454 # this should be 37.608(years)*365(days)*2(timesperday)

我明白了:

head(t)
692508 692520 692532 692544 692556 692568 #hours since 1900-01-01 00:00:0.0

tail(t)
0 0 0 0 0 0 #hours since 1900-01-01 00:00:0.0

然后我将时间单位字符串拆分为字段,将它们作为&#34; d-m-y&#34;

tunits <- ncatt_get(ncin, "time", "units")
tustr <- strsplit(tunits$value, " ")
tdstr <- strsplit(unlist(tustr)[3], "-")
tmonth = as.integer(unlist(tdstr)[2])
tday = as.integer(unlist(tdstr)[3])
tyear = as.integer(unlist(tdstr)[1])
chron(t, origin = c(tmonth, tday, tyear))
realtime <- chron(t, origin = c(tmonth, tday, tyear), format = c("d-m-y"))
realtime <- as.character(realtime)

head(realtime)
"09-01-96" "21-01-96" "02-02-96" "14-02-96" "26-02-96" "09-03-96"

tail(realtime)
"01-01-00" "01-01-00" "01-01-00" "01-01-00" "01-01-00" "01-01-00"

这对我来说没有意义,因为这些数据从1979年1月到现在可用,并且tail(t)和tail(实时)都告诉我们某些数据是指1900-01-01:t等于零18563次。有什么我做错了吗?

0 个答案:

没有答案