Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

DESCRIPTION

Dump the content of a grib GRIB file in different formats.

...

grib_dump [options] grib_file grib_file ...

OPTIONS


-O

Octet mode. WMO documentation style dump.


-D

Debug mode.


-d

Print all data values.


-j

JSON mode (JavaScript Object Notation).


-

...

C code mode. A C code program generating the message is dumped.

...

t

Print type information.


-H

Print octet content in hexadecimal format.


-a

Dump aliases.


-w key[:{s

...

|d

...

|i}]{=

...

|!=}value,key[:{s

...

|d

...

|i}]{=

...

|!=}value,...

Where clause. Messages are processed only if they match all the key/value constraints. A valid constraint is of type key=value or key!=value. For each key a string (key:s) or , a double (key:d) or a long an integer (key:li) type can be specified. Default type is string. In the value you can also use the forward-slash character '/' to specify an OR condition (i.e. a logical disjunction) Note: only one -w clause is allowed.


-s key[:{s

...

|d

...

|i}]=value,key[:{s

...

|d

...

|i}]=value,...

Key/values to set. For each key a string (key:s) or , a double (key:d) or a long an integer (key:li) type can be defined. By default the native type is set.


-M

Multi-field support off. Turn off support for multiple fields in single grib GRIB message.


-T T | B | M | A

Message type. T->GTS, B->BUFR, M->METAR (Experimental),A->Any (Experimental). The input file is interpreted according to the message type.


-7

Does not fail when the message has wrong length


-V

Version


-p key1,key2,...
Declaration of keys to dump. Only those keys are dumped (not the whole message).


-X offset

Input file offset in bytes. Processing of the input file will start from "offset".


-x

Fast parsing option, only headers are loaded.

...

  1. To dump in a WMO documentation style with hexadecimal octet values (-H).

    Code Block
    > grib_dump -OH ../data/reduced_gaussian_model_level.grib1
    



  2. To add key aliases and type information.

    Code Block
    > grib_dump -OtaH ../data/reduced_gaussian_model_level.grib1
    



  3. To obtain all the key names (computed keys included) available in a grib file.

    Code Block
     
    >  grib_dump -D ../data/regular_latlon_surface
    .grib1 To obtain a C code example from a grib file. Code Block > grib_dump -C ../data/regular_latlon_surface.grib1 #include <grib_api.h> /* This code was generated automatically */ int main(int argc,const char** argv) { grib_handle *h = NULL; size_t size = 0; double* vdouble = NULL; long* vlong = NULL; FILE* f = NULL; const char* p = NULL; const void* buffer = NULL; if(argc != 2) { fprintf(stderr,"usage: %s out",argv[0]); exit(1); } h = grib_handle_new_from_samples(NULL,"GRIB1"); if(!h) { fprintf(stderr,"Cannot create grib handle"); exit(1); } GRIB_CHECK(grib_set_long(h,"parametersVersion",1),0); GRIB_CHECK(grib_set_long(h,"truncateLaplacian",0),0); GRIB_CHECK(grib_set_long(h,"truncateDegrees",0),0); GRIB_CHECK(grib_set_long(h,"dummy",1),0); GRIB_CHECK(grib_set_long(h,"changingPrecision",0),0); GRIB_CHECK(grib_set_long(h,"unitsFactor",1),0); GRIB_CHECK(grib_set_long(h,"unitsBias",0),0); GRIB_CHECK(grib_set_long(h,"timeRangeIndicatorFromStepRange",-1),0); GRIB_CHECK(grib_set_long(h,"eps",0),0); GRIB_CHECK(grib_set_long(h,"editionNumber",1),0); GRIB_CHECK(grib_set_long(h,"productionStatusOfProcessedData",0),0); GRIB_CHECK(grib_set_long(h,"table2Version",128),0); /* 98 = European Centre for Medium-Range Weather Forecasts (grib1/0.table) */ GRIB_CHECK(grib_set_long(h,"centre",98),0); GRIB_CHECK(grib_set_long(h,"generatingProcessIdentifier",130),0); GRIB_CHECK(grib_set_long(h,"gridDefinition",255),0); /* 128 = 10000000 (1=1) Section 2 included (2=0) Section 3 omited See grib1/1.table */ GRIB_CHECK(grib_set_long(h,"section1Flags",128),0); /* 167 = 2 metre temperature (K) (grib1/2.98.128.table) */ GRIB_CHECK(grib_set_long(h,"indicatorOfParameter",167),0); /* 1 = Surface (of the Earth, which includes sea surface) (grib1/local/ecmf/3.table , grib1/3.table) */ GRIB_CHECK(grib_set_long(h,"indicatorOfTypeOfLevel",1),0); GRIB_CHECK(grib_set_long(h,"level",0),0); GRIB_CHECK(grib_set_long(h,"yearOfCentury",8),0); GRIB_CHECK(grib_set_long(h,"month",2),0); GRIB_CHECK(grib_set_long(h,"day",6),0); GRIB_CHECK(grib_set_long(h,"hour",12),0); GRIB_CHECK(grib_set_long(h,"minute",0),0); GRIB_CHECK(grib_set_long(h,"second",0),0); /* 1 = Hour (grib1/4.table) */ GRIB_CHECK(grib_set_long(h,"unitOfTimeRange",1),0); GRIB_CHECK(grib_set_long(h,"P1",0),0); GRIB_CHECK(grib_set_long(h,"P2",0),0); /* 0 = Forecast product valid at reference time + P1 (P1>0) (grib1/local/ecmf/5.table , grib1/5.table) */ GRIB_CHECK(grib_set_long(h,"timeRangeIndicator",0),0); GRIB_CHECK(grib_set_long(h,"numberIncludedInAverage",0),0); GRIB_CHECK(grib_set_long(h,"numberMissingFromAveragesOrAccumulations",0),0); GRIB_CHECK(grib_set_long(h,"centuryOfReferenceTimeOfData",21),0); /* 0 = Unknown code table entry (grib1/0.ecmf.table) */ GRIB_CHECK(grib_set_long(h,"subCentre",0),0); GRIB_CHECK(grib_set_long(h,"decimalScaleFactor",0),0); GRIB_CHECK(grib_set_long(h,"setLocalDefinition",0),0); GRIB_CHECK(grib_set_long(h,"dataDate",20080206),0); GRIB_CHECK(grib_set_long(h,"dataTime",1200),0); /* 1 = Hour (stepUnits.table) */ GRIB_CHECK(grib_set_long(h,"stepUnits",1),0); GRIB_CHECK(grib_set_long(h,"startStep",0),0); GRIB_CHECK(grib_set_long(h,"endStep",0),0); GRIB_CHECK(grib_set_long(h,"deleteLocalDefinition",0),0); /* 1 = MARS labelling or ensemble forecast data (grib1/localDefinitionNumber.98.table) */ GRIB_CHECK(grib_set_long(h,"localDefinitionNumber",1),0); /* 1 = Operational archive (mars/class.table) */ GRIB_CHECK(grib_set_long(h,"marsClass",1),0); /* 2 = Analysis (mars/type.table) */ GRIB_CHECK(grib_set_long(h,"marsType",2),0); /* 1025 = Atmospheric model (mars/stream.table) */ GRIB_CHECK(grib_set_long(h,"marsStream",1025),0); p = "0001"; size = strlen(p); GRIB_CHECK(grib_set_string(h,"experimentVersionNumber",p,&size),0); GRIB_CHECK(grib_set_long(h,"perturbationNumber",0),0); GRIB_CHECK(grib_set_long(h,"numberOfForecastsInEnsemble",0),0); /* x */ GRIB_CHECK(grib_set_long(h,"ifsParam",167),0); GRIB_CHECK(grib_set_long(h,"gridDescriptionSectionPresent",1),0); GRIB_CHECK(grib_set_long(h,"GDSPresent",1),0); GRIB_CHECK(grib_set_long(h,"bitmapPresent",0),0); GRIB_CHECK(grib_set_long(h,"angularPrecision",1000),0); GRIB_CHECK(grib_set_long(h,"radius",6367470),0); GRIB_CHECK(grib_set_long(h,"shapeOfTheEarth",6),0); GRIB_CHECK(grib_set_long(h,"numberOfVerticalCoordinateValues",0),0); GRIB_CHECK(grib_set_long(h,"pvlLocation",255),0); /* 0 = Latitude/Longitude Grid (grib1/6.table) */ GRIB_CHECK(grib_set_long(h,"dataRepresentationType",0),0); GRIB_CHECK(grib_set_long(h,"Ni",16),0); GRIB_CHECK(grib_set_long(h,"Nj",31),0); GRIB_CHECK(grib_set_long(h,"latitudeOfFirstGridPoint",60000),0); GRIB_CHECK(grib_set_long(h,"longitudeOfFirstGridPoint",0),0); /* 128 = 10000000 (1=1) Direction increments given (2=0) Earth assumed spherical with radius = 6367
    .
    47 km (5=0) u and v components resolved relative to easterly and northerly directions See
    grib1
    /7.table */ GRIB_CHECK(grib_set_long(h,"resolutionAndComponentFlags",128),0); GRIB_CHECK(grib_set_long(h,"ijDirectionIncrementGiven",1),0); GRIB_CHECK(grib_set_long(h,"earthIsOblate",0),0); GRIB_CHECK(grib_set_long(h,"uvRelativeToGrid",0),0); GRIB_CHECK(grib_set_long(h,"latitudeOfLastGridPoint",0),0); GRIB_CHECK(grib_set_long(h,"longitudeOfLastGridPoint",30000),0); GRIB_CHECK(grib_set_long(h,"iDirectionIncrement",2000),0); GRIB_CHECK(grib_set_long(h,"jDirectionIncrement",2000),0); /* 0 = 00000000 (1=0) Points scan in +i direction (2=0) Points scan in -j direction (3=0) Adjacent points in i direction are consecutive See grib1/8.table */ GRIB_CHECK(grib_set_long(h,"scanningMode",0),0); GRIB_CHECK(grib_set_long(h,"iScansNegatively",0),0); GRIB_CHECK(grib_set_long(h,"jScansPositively",0),0); GRIB_CHECK(grib_set_long(h,"jPointsAreConsecutive",0),0); GRIB_CHECK(grib_set_long(h,"iScansPositively",1),0); GRIB_CHECK(grib_set_long(h,"swapScanningX",0),0); /* Error accessing swapScanningX (Function not yet implemented) */ GRIB_CHECK(grib_set_long(h,"swapScanningY",0),0); /* Error accessing swapScanningY (Function not yet implemented) */ /* ITERATOR */ /* NEAREST */ GRIB_CHECK(grib_set_long(h,"PVPresent",0),0); GRIB_CHECK(grib_set_long(h,"PLPresent",0),0); GRIB_CHECK(grib_set_long(h,"missingValue",9999),0); GRIB_CHECK(grib_set_long(h,"sphericalHarmonics",0),0); GRIB_CHECK(grib_set_long(h,"complexPacking",0),0); GRIB_CHECK(grib_set_long(h,"integerPointValues",0),0); GRIB_CHECK(grib_set_long(h,"additionalFlagPresent",0),0); GRIB_CHECK(grib_set_long(h,"orderOfSPD",2),0); GRIB_CHECK(grib_set_long(h,"boustrophedonic",0),0); GRIB_CHECK(grib_set_long(h,"hideThis",0),0); GRIB_CHECK(grib_set_long(h,"bitsPerValue",16),0); GRIB_CHECK(grib_set_long(h,"dirty_statistics",1),0); GRIB_CHECK(grib_set_long(h,"dataLength",124),0); GRIB_CHECK(grib_set_long(h,"changeDecimalPrecision",0),0); GRIB_CHECK(grib_set_long(h,"decimalPrecision",0),0); GRIB_CHECK(grib_set_long(h,"bitsPerValueAndRepack",16),0); /* Save the message */ f = fopen(argv[1],"w"); if(!f) { perror(argv[1]); exit(1); } GRIB_CHECK(grib_get_message(h,&buffer,&size),0); if(fwrite(buffer,1,size,f) != size) { perror(argv[1]); exit(1); } if(fclose(f)) { perror(argv[1]); exit(1); } grib_handle_delete(h); return 0; }