Skip to end of metadata
Go to start of metadata

A BUFR message is made of some headers and a data section. The structure of the data section is defined in the headers by a sequence of BUFR descriptors, which are sequences of six digit numbers having a particular meaning (see  BUFR tables). To modify this sequence of descriptors ecCodes provides the key unexpandedDescriptors. As an example to change the structure of a message to obtain an upper air report (TEMP) the unexpanded descriptors have to be set as:

unexpandedDescriptors=309052

according to what is reported in the Manual on Codes. 

This can be done using any of the language interfaces (Fortran 90, python or C), and also using the command line tools.

In particular using the bufr_filter tool, we can write the following simple instructions in the change_structure.filter file

change_structure.filter
set unexpandedDescriptors=309052;
write;

and execute the filter instructions with bufr_filter:

bufr_filter -o temp.bufr change_structure.filter seed.bufr

we are setting the value of unexpandedDescriptors to 309052 and writing the new message to the file temp.bufr.

The output file temp.bufr will be significantly different from the input message seed.bufr because it will have a data structure defined by the sequence 309052. The values in the new data structure will be all missing and the structure will be ready to accept values from the user.

The key unexpandeDescriptors can be set to an array of integers representing a sequence of BUFR descriptors. If we need to set a sequence which is a variation from a standard sequence or is not included in the table of official WMO sequences, we can explicitly set unexpandedDescriptors with the full sequence. As an example a sequence for aircraft reports including the seconds and pressure as non-coordinate parameter can be obtained by slightly modifying the sequence 311001–> 301051, 007002, 012001, 011001, 011002, 011031, 011032, 011033, 020041 and introducing the elements 004006 (second) and 10004 (pressure non-coordinate) in the sequence of descriptors.

The following filter rules will generate the required message (note the difference between the sequence 311001 and this newly defined sequence):

set unexpandedDescriptors={301051, 4006,7002, 10004,12001, 11001, 11002, 11031, 11032, 11033, 20041};
write;

Using BUFR descriptors to choose the appropriate message structure requires some knowledge of the BUFR format. ecCodes provides a simple way to define the structure of a BUFR message using the key "bufrTemplate".

This key can be set to a string representing the template. The filter rules above can be replaced by

set bufrTemplate="aircraftReportWithSecondsAndPressure";
write;

or to set an upper air report (temp) we can just set bufrTemplate="temp";

A list of all the available values for the bufrTemplate key is provided in BUFR templates