Versions Compared

Key

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

In addition to the low-level C-like interface, there are now Python classes that can be used to represent the objects of interest whilst processing GRIB and BUFR messages.

GribFile and BufrFile: Classes that implement a GRIB/BUFR file that closes itself and its messages when it is no longer needed.

GribMessage and BufrMessage: Classes that implement a GRIB/BUFR message that allows access to the message's key-value pairs in a dictionary-like manner and closes the message when it is no longer needed, coordinating this with its host file.

 

GribFiles and BufrFiles can be treated mostly as regular files and used as context managers, as can GribMessages/BufrMessages. Each of these classes destructs itself and any child instances appropriately.

 

Details

 

Tabs Container
directionhorizontal
Tabs Page
titleGribFile

class GribFile(eccodes.high_level.codesfile.CodesFile)

A GRIB file handle meant for use in a context manager. Individual messages can be accessed using the ``next`` method. Of course,

it is also possible to iterate over each message in the file::

>>> with GribFile(filename) as grib:

...     # Print number of messages in file

...     len(grib)

...     # Open all messages in file

...     for msg in grib:

...         print(msg[key_name])

...     len(grib.open_messages)

>>> # When the file is closed, any open messages are closed

>>> len(grib.open_messages)

In addition to the low-level C-like interface, there are now Python classes that can be used to represent the objects of interest whilst processing GRIB and BUFR messages.

GribFile and BufrFile: Classes that implement a GRIB/BUFR file that closes itself and its messages when it is no longer needed.

GribMessage and BufrMessage: Classes that implement a GRIB/BUFR message that allows access to the message's key-value pairs in a dictionary-like manner and closes the message when it is no longer needed, coordinating this with its host file.

 

GribFiles and BufrFiles can be treated mostly as regular files and used as context managers, as can GribMessages/BufrMessages. Each of these classes destructs itself and any child instances appropriately.

 

Details

...