ncatted
参数周围放置的单引号会导致双引号变成文字,这不是您想要的。参数中没有文字,空格或特殊字符,因此请删除所有引号:[我正在尝试将netcdf文件中时间变量的日历类型从GREGORIAN
更改为gregorian
,因为我认为在以后的分析中尝试访问时间变量时会引起问题。] >
double Time(Time) ; Time:long_name = "Time" ; Time:units = "days since 1979-01-01 00:00:00" ; Time:cartesian_axis = "T" ; Time:calendar_type = "GREGORIAN" ; Time:calendar = "GREGORIAN" ; Time:bounds = "Time_bounds" ; Time:_ChunkSizes = 1 ;
到
double Time(Time) ; Time:long_name = "Time" ; Time:units = "days since 1979-01-01 00:00:00" ; Time:cartesian_axis = "T" ; Time:calendar_type = "gregorian" ; Time:calendar = "gregorian" ; Time:bounds = "Time_bounds" ; Time:_ChunkSizes = 1 ;
我曾尝试使用nco函数nccat,但似乎语法不正确。我尝试过:
ncatted -a 'calendar,time,o,c,"gregorian"' Ocean_v_1994_01.nc out.nc
[我正在尝试修改netcdf文件中时间变量的日历类型,以从GREGORIAN更改为gregorian,因为我认为当我尝试在...内访问时间变量时,这会引起问题。] >>> < [
ncatted
参数周围放置的单引号会导致双引号变成文字,这不是您想要的。参数中没有文字,空格或特殊字符,因此请删除所有引号:ncatted -a calendar,time,o,c,gregorian Ocean_v_1994_01.nc out.nc
library(ncdf4)
mydata <- nc_open("Ocean_v_1994_01.nc", write = TRUE)
ncatt_put(mydata, "Time", 'calendar', attval = 'gregorian', prec = 'text')
ncatt_put(mydata, "Time", 'calendar_type', attval = 'gregorian', prec = 'text')
# check result
ncatt_get(mydata, "Time")
nc_sync(mydata)
nc_close(mydata)
我想您也可以使用cdo setcalendar命令对此进行排序:
cdo setcalendar,proleptic_gregorian in.nc out.nc
ncatted
参数周围放置的单引号会导致双引号变成文字,这不是您想要的。参数中没有文字,空格或特殊字符,因此请删除所有引号:library(ncdf4)
mydata <- nc_open("Ocean_v_1994_01.nc", write = TRUE)
ncatt_put(mydata, "Time", 'calendar', attval = 'gregorian', prec = 'text')
ncatt_put(mydata, "Time", 'calendar_type', attval = 'gregorian', prec = 'text')
# check result
ncatt_get(mydata, "Time")
nc_sync(mydata)
nc_close(mydata)
cdo setcalendar,proleptic_gregorian in.nc out.nc