Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Era临时NetCDF文件使用R:错误的时间维度_R_Time_Extraction_Netcdf - Fatal编程技术网

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

Era临时NetCDF文件使用R:错误的时间维度,r,time,extraction,netcdf,R,Time,Extraction,Netcdf,我已经从ERA临时数据集下载了温度数据(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

我已经从ERA临时数据集下载了温度数据(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)
然后,我将时间单位字符串拆分为字段,使其成为“d-m-y”


t开始之前,您是否检查过文件中的日期是否与您认为的日期相符?Try:cdo showdate file.nc
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
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"