【问题标题】:NetCDF re-ordering dimensionNetCDF 重新排序维度
【发布时间】:2022-05-06 15:59:58
【问题描述】:

我有 1 个带有变量 ppt 和三个维度 ppt(time,lat,lon) 的 netCDF 文件。见下文:

dimensions:
    time = UNLIMITED ; // (756 currently)
    lon = 55 ;
    lat = 60 ;
variables:
    double time(time) ;
        time:standard_name = "time" ;
        time:long_name = "time" ;
        time:units = "days since 1900-01-01 00:00:00" ;
        time:calendar = "gregorian" ;
        time:axis = "T" ;
    double lon(lon) ;
        lon:standard_name = "longitude" ;
        lon:long_name = "longitude" ;
        lon:units = "degrees_east" ;
        lon:axis = "X" ;
    double lat(lat) ;
        lat:standard_name = "latitude" ;
        lat:long_name = "latitude" ;
        lat:units = "degrees_north" ;
        lat:axis = "Y" ;
    int ppt(time, lat, lon) ;
        ppt:standard_name = "precipitation_amount" ;
        ppt:long_name = "precipitation_amount" ;
        ppt:units = "mm" ;
        ppt:add_offset = 0. ;
        ppt:scale_factor = 0.1 ;
        ppt:_FillValue = -2147483648 ;
        ppt:missing_value = -2147483648 ;
        ppt:description = "Accumulated Precipitation" ;
        ppt:dimensions = "lon lat time" ;
        ppt:coordinate_system = "WGS84,EPSG:4326" ;

我想将维度从time,lat,lon 重新排序为lat,lon,time。

我使用命令:ncpdq -a lat,lon,time in.nc out.nc 重新排序变量后,lat 维度变为UNLIMITED,这是错误的。 time 维度应该是 UNLIMITED 维度。

dimensions:
    time = 756 ;
    lon = 55 ;
    lat = UNLIMITED ; // (60 currently)

...
...

    int ppt(lat, lon, time) ;

然后我尝试使用下面的ncks 命令修复成为UNLIMITED 的lat 维度:

ncks --fix_rec_dmn lat out.nc out1.nc

成功了,见下图:

dimensions:
    lat = 60 ;
    lon = 55 ;
    time = 756 ;

现在我想再次使用下面的 ncks 命令将时间维度设为 UNLIMITED:

ncks --fix_rec_dmn time out1.nc out2.nc

不幸的是,没有发生任何事情,结果保持不变。见下文:

dimensions:
    lat = 60 ;
    lon = 55 ;
    time = 756 ;

我的问题,如何再次制作 UNLIMITED 时间维度?

【问题讨论】:

    标签: netcdf nco


    【解决方案1】:

    我从https://stackoverflow.com/a/55883675/10874805发现了类似的问题和答案

    我的错误,要使 UNLIMITED 时间维度,我必须使用 --mk_rec_dmn 而不是 --fix_rec_dmn

    所以代码应该是:ncks --mk_rec_dmn time out1.nc out2.nc

    【讨论】:

      【解决方案2】:

      在 netCDF3 文件中,变量的第一个维度只能是无限维度(如果有)。 netCDF4 放宽了这一限制,因此如果您希望记录维度位于变化最快的维度以外的位置,则必须确保输出是 netCDF4 文件。

      【讨论】:

        猜你喜欢
        • 2022-01-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-08-11
        • 1970-01-01
        • 2023-04-04
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多