BUFR has two different ways of encoding information in the data section:

  • Compressed: Each item of information is encoded as a vector with as many elements as the numberOfSubsets in the message
  • Uncompressed: In the message there are as many similar data structures as there are numberOfSubsets.
    Each subset is a repetition of the template defined with the unexpandedDescriptors in section 3

The key compressedData indicates whether the data are compressed (value is 1) or uncompressed (value is 0).

When the BUFR data are compressed each element in the data section is an array with:

  • numberOfSubset elements. Therefore, a single subset can be accessed as an element of the array.
  • one single element because the value is the same for all the subsets encoded in the message.

When the BUFR data are uncompressed a key subsetNumber is made available by ecCodes to search the elements belonging to a specific subset by condition.

The following Python code is an example of getting the airTemperature from the third subset of a SYNOP message:

compressed = codes_get(bufr, 'compressedData')
if compressed:
    t = codes_get(bufr, 'airTemperature')
    t3 = t[3]
else:
    t3 = codes_get(bufr, '/subsetNumber=3/airTemperature')