我正在使用Eccodes API转换GRIB2文件。当我使用C ++ API提取所有paramIdshortName时,查询结果中不存在wind的V分量(paramId为132,shortName为v),如下所示:

ids=730 31 43 54 59 130 131 133 134 135 156 157 165 167 168 172 173 3020 3024 3041 3045 3046 3054 3063 3066 3086 228001 228002 228139 228164 228228 260002 260003 260029 260030 260031 260032 260038 260056 260065 260072 260073 260074 260083 260087 260088 260097 260098 260125 260127 260128 260155 260180 260185 260187 260189 260190 260205 260206 260207 260208 260209 260238 260242 260256 260317 260389 260390 260391260439 260442 260509 7001353names=7310u 2d 2r 2t 4lftx VRATE absv acpcp al bmixl cape cd cfrzr ci cicep cin cnwat crain csnow dlwrf dswrf fricv gh gust hindex hlcy hpbl lftx lhtfl lsm ltng mslet mstav orog pli poros pres prmsl pwat q r refc refd rlyrs sde sdwe shtfl slt smdry smref snowc soill soilw sp sr ssw st t tcc tke tp u ulwrf unknown uswrf veg vgtyp vis vucsh vvcsh w wilt wz

程序代码如下:

/*
 * Copyright 2005-2017 ECMWF.
 *
 * This software is licensed under the terms of the Apache Licence Version 2.0
 * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
 *
 * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
 * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
 */

/*
 * C Implementation: grib_index
 *
 * Description: How to create and use an index to access GRIB messages from a file
 *
 */

#include "eccodes.h"

int main(int argc,char* argv[])
{
    codes_index* index = NULL;
    codes_handle* h = NULL;
    int ret;
    size_t size, i;
    char** names;
    long* ids;

    index = codes_index_new_from_file(0, argv[argc - 1], "paramId,shortName", &ret);
    CODES_CHECK(ret, 0);

    CODES_CHECK(codes_index_get_size(index, "shortName", &size),0);
    ids=(long*)malloc(sizeof(long)*size);
    CODES_CHECK(codes_index_get_long(index,"paramId",ids,&size),0);
    printf("ids=%ld\n",(long)size);
    for (i=0;i<size;i++) printf("%ld ",ids[i]);
    printf("\n");

    CODES_CHECK(codes_index_get_size(index, "shortName", &size),0);
    names=(char**)malloc(sizeof(char*)*size);
    CODES_CHECK(codes_index_get_string(index,"shortName",names,&size),0);
    printf("names=%ld\n",(long)size);
    for (i=0;i<size;i++) printf("%s ",names[i]);
    printf("\n");
    return 0;
}


但是,如果我使用grib_ls查询参数,它将显示:

wuh20@sapphire:~/github/test$ grib_ls -w paramId=132 -p paramId,level,shortName,name ~/Desktop/test/nam_218_20180701_0000_000.grb2/home/graduate/wuh20/Desktop/test/nam_218_20180701_0000_000.grb2paramId level shortName name132 0 v V component of wind132 50 v V component of wind132 75 v V component of wind132 100 v V component of wind132 125 v V component of wind132 150 v V component of wind132 175 v V component of wind132 200 v V component of wind132 225 v V component of wind132 250 v V component of wind132 275 v V component of wind132 300 v V component of wind132 325 v V component of wind132 350 v V component of wind132 375 v V component of wind132 400 v V component of wind132 425 v V component of wind132 450 v V component of wind132 475 v V component of wind132 500 v V component of wind132 525 v V component of wind132 550 v V component of wind132 575 v V component of wind132 600 v V component of wind132 625 v V component of wind132 650 v V component of wind132 675 v V component of wind132 700 v V component of wind132 725 v V component of wind132 750 v V component of wind132 775 v V component of wind132 800 v V component of wind132 825 v V component of wind132 850 v V component of wind132 875 v V component of wind132 900 v V component of wind132 925 v V component of wind132 950 v V component of wind132 975 v V component of wind132 1000 v V component of wind132 0 v V component of wind132 0 v V component of wind132 80 v V component of wind132 3000 v V component of wind132 6000 v V component of wind132 9000 v V component of wind132 12000 v V component of wind132 15000 v V component of wind132 18000 v V component of wind49 of 446 messages in /home/graduate/wuh20/Desktop/test/nam_218_20180701_0000_000.grb2

有人可以帮我解决这个问题吗?

如果需要或有帮助,我可以提供我的数据。谢谢。

最佳答案

这是一个隐藏但简单的过程。我必须打开所有工具默认情况下都处于启用状态的多重支持。


  对于所有工具,defalut均启用多支持。


referece

关于c++ - 使用不同的工具时,Eccodes会产生不同的结果,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52565239/

10-12 21:28