0

我是初学者,nco我希望能对我的工作流程提供一些建议,并为我遇到的问题提供一些帮助。

我有这些数据,其中包含两个不同时间步长的 3D 盐度值:

dimensions:
    t = 780 ;
    z = 54 ;
    y = 450 ;
    x = 3600 ;
variables:
    double time(t) ;
        time:units = "days since 1-1-1 00:00:0.0" ;
    float level(z) ;
        level:units = "[m]" ;
    float lat(y) ;
    float lon(x) ;
    float salt(x, y, z) ;
        salt:units = "psu * 1000 + 35" ;
        salt:missingvalue = "-1.0E34" ;
        salt:longname = "salinity" ;

我想连接两个 netcdf 文件。

为此,我首先使用ncecat *.nc -O merged.nc

dimensions:
    record = UNLIMITED ; // (2 currently)
    t = 780 ;
    z = 54 ;
    y = 450 ;
    x = 3600 ;
variables:
    double time(record, t) ;
        time:units = "days since 1-1-1 00:00:0.0" ;
    float level(record, z) ;
        level:units = "[m]" ;
    float lat(record, y) ;
    float lon(record, x) ;
    float salt(record, x, y, z) ;
        salt:units = "psu * 1000 + 35" ;
        salt:missingvalue = "-1.0E34" ;
        salt:longname = "salinity" ;

现在变量time和维度t是虚假的。所以,我删除它们ncks -O -x -v time merged.nc merged.nc

    record = UNLIMITED ; // (2 currently)
    y = 450 ;
    z = 54 ;
    x = 3600 ;
variables:
    float lat(record, y) ;
    float level(record, z) ;
        level:units = "[m]" ;
    float lon(record, x) ;
    float salt(record, x, y, z) ;
        salt:units = "psu * 1000 + 35" ;
        salt:missingvalue = "-1.0E34" ;
        salt:longname = "salinity" ;

现在,我想record用:重命名维度ncrename -d record,time merged.nc。该命令运行时没有错误或警告。但是当我这样做时,ncdump -h merged.nc我得到了这个错误

ncdump:merged.nc:NetCDF:HDF错误

这是什么意思?我哪里做错了?

编辑

遵循查理·赞德( Charlie Zender )发布的答案

ncecat -O -u time *.nc merged.nc
ncks -O -x -v time merged.nc merged.nc

导致:

dimensions:
    time = UNLIMITED ; // (2 currently)
    y = 450 ;
    z = 54 ;
    x = 3600 ;
    t = 780 ;
variables:
    float lat(time, y) ;
    float level(time, z) ;
        level:units = "[m]" ;
    float lon(time, x) ;
    float salt(time, x, y, z) ;
        salt:units = "psu * 1000 + 35" ;
        salt:missingvalue = "-1.0E34" ;
        salt:longname = "salinity" ;
    double time(time, t) ;
        time:units = "days since 1-1-1 00:00:0.0" ;

// global attributes:
        :history = "Tue Jun  5 09:08:25 2018: ncks -O -x -v time merged.nc merged.nc\nTue Jun  5 09:08:19 2018: ncecat -O -u time OFES_salt_mmean_607.nc OFES_salt_mmean_608.nc merged.nc" ;
        :NCO = "netCDF Operators version 4.7.4 (http://nco.sf.net)" ;
        :nco_openmp_thread_number = 1 ;
4

1 回答 1

4

首先,我推荐的命令是

ncecat -O -u time *.nc merged.nc

这样可以避免重命名recordtime. 然后

ncks -O -x -v time merged.nc merged.nc

那样有用吗?

回答编辑的问题:

关于 ncrename 收到的错误,您可能遇到了此处描述的 netCDF4 库错误。推荐的解决方案是转换为 netCDF3,重命名,然后在需要时转换回 netCDF4:

ncks -3 in.nc out.nc
ncrename -d record,time out.nc
ncks -4 out.nc out.nc
于 2018-06-04T11:27:16.147 回答