Versions Compared

Key

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

...

In line 4 we retrieve the data from the specified resource. In this example it's a GRIB file.
Then in line 7 we get the raw bytes from the request which can contain several messages.
In the main loop we start off at the beginning of the stream (offset = 0) and get the first message using codes_new_from_message() which gives us a handle 'h' on the first message.
We can now use the standard codes_get() function to access values of various keys from this message.
In line 15 we advance through the byte data by the length of the first message (by slicing the byte array) so next time when we call codes_new_from_message() we will come across the next message and so on. Note we must call the codes_release() on each handle to free the memory.


Warning

This method will not work with multi-field GRIB messages


Content by Label
showLabelsfalse
max5
spacesUDOC
showSpacefalse
sortmodified
reversetrue
typepage
excludeCurrenttrue
cqllabel in ("decode","python","eccodes-faqs","kb-how-to-article") and label = "python" and type = "page" and space = "UDOC"
labelsdecode python

...