You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

Accessing subsets

Step-by-step guide

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. 
  1. 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')

There is no content with the specified labels



  • No labels