You have a URL which contains a GRIB/BUFR message and you want to read it directly from the web

Step-by-step guide

Let's say you have a stream of in-memory bytes rather than a file which contains one or more GRIB or BUFR messages. The following python script shows you how you can decode those messages:

import requests
from eccodes import codes_new_from_message, codes_get, codes_release

url='https://some.gov/pub/data/temperature.grib2'
print('Started downloading...')
r = requests.get(url)
data = r.content # raw bytes

# Convert each field to a handle in turn
offset = 0
while offset < len(data):
    h = codes_new_from_message(data[offset:])
    print(offset, codes_get(h, 'step'), codes_get(h, 'shortName'))
    # Advance through the bytes by the length of the message
    offset += codes_get(h, 'totalLength')
    codes_release(h)



You may also want to use visual panels to communicate related information, tips or things users need to be aware of.

Related articles

Related articles appear here based on the labels you select. Click to edit the macro and add or change labels.



Related issues